	This describes an attempt to make the dial backup easier and simpler,
albeit with a little loss of flexibility. Serves the purpose though. We
assume that each PPP port is associated with one primary WAN port and one
secondary (backup) WAN port. On dialing ends, a WAN port can be used to
back two primary ports up. But on the answering ends, a WAN port can backup
only one primary port.

	PPP port operates on the primary/backup WAN port simply by using the
"current" wan port's serial driver. That is, at any point of time, PPP
port i can use WAN port j's serial driver class. So, each PPP port has
an 'active_serial_driver' at any point of time. Actually this scheme permits
any PPP port i to have any WAN port j as the primary port and any WAN port
k as the backup port. But this is an incidental flexibility, that we are
not going to be worried about right now. For our purposes, PPP port i's
primary WAN port is WAN port i ONLY.


Configuration parameters for fine tuning behavior :
-------------------------------------------------
ULONG backup_switch_delay : Duration for which to wait after the primary
	goes down before switching over to backup. A value of zero results
	in immediately attempting to switch over to backup port as soon as
	the primary goes down.
ULONG primary_restore_delay: Duration for which to wait after the primary
	is detected to be up (when on secondary port) before switching back
	to primary.

?????? A small doubt : Do we always restrict that the backup wan port
?????? be an async modem connected port. I feel, it makes sense.


New status variables maintained for each PPP port :
-------------------------------------------------
USHORT primary_wan_port
USHORT secondary_wan_port
ULONG backup_switch_delay_counter
ULONG primary_restore_delay_counter

SERIAL_DRIVER_CLASS *sptr_active_serial_driver :
	During init,
	ppp.port[i].sptr_active_serial_driver = &ppp.port[ppp.port[i].primary_wan_port].serial_driver
	After moving over to the BACKUP state,
	ppp.port[i].sptr_active_serial_driver = &ppp.port[ppp.port[i].secondary_wan_port].serial_driver
	All references to the WAN control, receive, transmit, free, etc. functions
	are to be made thru' this pointer and not thru' serial_driver.
	

enum PORT_STATE port_state :
PRIMARY : Normal operation. This is the state that a port is in during normal
	operation. If this PPP port does not have a backup port, there is no
	reason for the port to move out of this state for any reason.
	sptr_active_serial_driver of PPP port i points to the serial driver
	of primary WAN port (which for our purposes now happens to be WAN port i).
PRIMARY_DOWN_WAIT : If this PPP port has a backup port, and if the primary
	port goes down, we move to this state. Here, we wait for a period
	backup_switch_delay to see if the primary is actually down. After
	this period, we move over to the BACKUP state
BACKUP : It moves over to this state from PRIMARY_DOWN_WAIT after a period
	of backup_switch_delay. By now, the wan port corresponding to the
	backup link is also determined and this PPP port operates on the backup
	WAN port. Basically the sptr_active_serial_driver of PPP port i
	points to the serial driver of WAN port (BACKUP(i)). Note that
	BACKUP(i) for any i is unique.
		An important point to note here is that when the PPP port is
	in this state, the primary port may come up. This can happen in
	two ways, depending on whether the corresponding WAN port is an
	answering port or a dialing port. In case of a dialing port, no
	extra book keeping is necessary. The WAN driver makes a
	LOWER_DEVICE_DRIVER_UP call. All we need to do is, identify that
	the WAN port that has come up happens to be the primary port of
	a port that is currently on backup. In case of answering ports,
	when a PPP port is in this state, we need to call wan_packet_received()
	for both primary and secondary wan ports. Similar to the dialing port,
	even here there is going to be a LOWER_DEVICE_DRIVER_UP call from
	the primary WAN port when it comes up. But wan_packet_received() MUST
	be called for this to happen.
		Once LOWER_DEVICE_DRIVER_UP command comes, we move to a state
	PRIMARY_UP_WAIT for a period primary_restore_delay. We stay in this
	state to make sure that the PRIMARY is actually UP. From here, we
	move back to PRIMARY state. sptr_active_serial_driver has to be
	restored to the correct value. That is, sptr_active_serial_driver for
	port i is set to the serial driver for wan port i.
PRIMARY_UP_WAIT:


Changes to wan driver :
---------------------
	wan_control() needs to support a few new commands :

	FREEZE_MODEM_STATE_MACHINE : sets the modem state machine state to
	MDM_STATE_IDLE. During initialize_wan_controller(), we initialize all
	the enabled WAN ports. But once PPP comes up, it needs to freeze the
	modem state machines of the backup WAN ports (presumably async modem
	connected).

	SET_DIAL_NUMBER : sets the number to be dialed and reconstructs the
	dial string (from the dial prefix and this number). Required because
	we may be dialing different locations from the same WAN port depending
	on which PPP port is being backed up.



PPP changes :
-----------
	During init :
	Set the primary_wan_port, secondary_wan_port and sptr_active_serial_driver,
	port_state fields for each port.
	Zero out all the counters.

	When a LOWER_DEVICE_DRIVER_DOWN command comes on a PPP port,
	check if it has a backup port configured. If it does not have
	one, dont bother to do anything. Make sure that the status of the
	PPP port stays as PRIMARY. Otherwise, init backup_switch_delay_counter
	and move to PRIMARY_DOWN_WAIT state.
		When a port is in PRIMARY_DOWN_WAIT, continue to make the call
	to wan_packet_received() on the primary port but NOT on the backup
	port.

	If the port is in PRIMARY_DOWN_WAIT or in PRIMARY_UP_WAIT, decrement
	the counters and act accordingly as they reach zero. While in PRIMARY_WAIT_DOWN,
	when the backup_switch_delay_counter reaches zero, move to BACKUP
	state. Issue OPEN_SERIAL_PORT command to the secondary WAN port.
	While in this state, make calls to wan_packet_received() for
	both the primary and backup wan ports if it is an answering port. This
	is very very important. On the dialing ends, we have no such problems.
	Once OPEN_SERIAL_PORT is issued, the wan driver goes ahead with the
	whole procedure and issues a LOWER_DEVICE_DRIVER_UP call to PPP. For this
	to happen on the answering ends, we need to continue to call wan_packet_receivet()
	courtesy, the packet analysis, shell menu, et al. So,

when a port is in state PRIMARY :
	Call wan_packet_received() for only the primary WAN port.
when a port is in state PRIMARY_DOWN_WAIT :
	Call wan_packet_received() for for primary (and secondary ?) WAN ports.
	But DO NOT do anything with the packets. Just drop them.
when a port is in BACKUP :
	Call wan_packet_received() for for both primary and secondary WAN ports.
	Process packets received on the secondary_wan_port amd drop packets received
	on the primary_wan_port.
when a port is in PRIMARY_UP_WAIT :
	Call wan_packet_received() for primary_wan_port only.
	????? Is it necessary ?????
	

The switching logic is built into the timer. The counters are decremented in
the timer and from there, commands are given to ppp_device_driver_control().
The functions like transmit, receive, etc. simply operate on the PPP port
as always and the active_serial_driver, which is the only difference. Setting
thye active_serial_driver and other status fields are set on events like
primary going down or primary coming up, etc..



VNV Strings :
-------------
	As of now, the only necessary strings are :

. For each PPP port, the primary WAN port number
. For each PPP port, the backup WAN port number (equal to
  NUMBER_OF_SERIAL_PORTS in case no backup is needed). Note that this string
  MUST be there otherwise WAN 0 becomes a backup.
. Fine tuning parameters like duration to wait for before switching between
  primary and backup (described in greater detail in an earlier paragraph)
. These aside, we may need to have a few extra strings (like phone numbers for
  primary and backup) in cases where we would want to have different parameters
  for a WAN port depending on which PPP port it is serving.
