VxWorks Reference Manual : Libraries
if_sl - Serial Line IP (SLIP) network interface driver
slipInit( ) - initialize a SLIP interface
slipBaudSet( ) - set the baud rate for a SLIP interface
slattach( ) - publish the sl network interface and initialize the driver and device
slipDelete( ) - delete a SLIP interface
This module implements the VxWorks Serial Line IP (SLIP) network interface driver. Support for compressed TCP/IP headers (CSLIP) is included.
The SLIP driver enables VxWorks to talk to other machines over serial connections by encapsulating IP packets into streams of bytes suitable for serial transmission.
SLIP devices are initialized using slipInit( ). Its parameters specify the Internet address for both sides of the SLIP point-to-point link, the name of the tty device on the local host, and options to enable CSLIP header compression. The slipInit( ) routine calls slattach( ) to attach the SLIP interface to the network. The slipDelete( ) routine deletes a specified SLIP interface.
SLIP is a simple protocol that uses four token characters to delimit each packet:
- END (0300)
- ESC (0333)
- TRANS_END (0334)
- TRANS_ESC (0335)The END character denotes the end of an IP packet. The ESC character is used with TRANS_END and TRANS_ESC to circumvent potential occurrences of END or ESC within a packet. If the END character is to be embedded, SLIP sends "ESC TRANS_END" to avoid confusion between a SLIP-specific END and actual data whose value is END. If the ESC character is to be embedded, then SLIP sends "ESC TRANS_ESC" to avoid confusion. (Note that the SLIP ESC is not the same as the ASCII ESC.)
On the receiving side of the connection, SLIP uses the opposite actions to decode the SLIP packets. Whenever an END character is received, SLIP assumes a full IP packet has been received and sends it up to the IP layer.
The global flag slipLoopBack is set to 1 by default. This flag enables the packets to be sent to the loopback interface if they are destined to to a local slip interface address. By setting this flag, any packets sent to a local slip interface address will not be seen on the actual serial link. Set this flag to 0 to turn off this facility. If this flag is not set any packets sent to the local slip interface address will actually be sent out on the link and it is the peer's responsibility to loop the packet back.
The write side of a SLIP connection is an independent task. Each SLIP interface has its own output task that sends SLIP packets over a particular tty device channel. Whenever a packet is ready to be sent out, the SLIP driver activates this task by giving a semaphore. When the semaphore is available, the output task performs packetization (as explained above) and writes the packet to the tty device.
The receiving side is implemented as a "hook" into the tty driver. A tty ioctl( ) request, FIOPROTOHOOK, informs the tty driver to call the SLIP interrupt routine every time a character is received from a serial port. By tracking the number of characters and watching for the END character, the number of calls to read( ) and context switching time have been reduced. The SLIP interrupt routine will queue a call to the SLIP read routine only when it knows that a packet is ready in the tty driver's ring buffer. The SLIP read routine will read a whole SLIP packet at a time and process it according to the SLIP framing rules. When a full IP packet is decoded out of a SLIP packet, it is queued to IP's input queue.
CSLIP compression is implemented to decrease the size of the TCP/IP header information, thereby improving the data to header size ratio. CSLIP manipulates header information just before a packet is sent and just after a packet is received. Only TCP/IP headers are compressed and uncompressed; other protocol types are sent and received normally. A functioning CSLIP driver is required on the peer (destination) end of the physical link in order to carry out a CSLIP "conversation."
Multiple units are supported by this driver. Each individual unit may have CSLIP support disabled or enabled, independent of the state of other units.
No hardware is directly associated with this driver; therefore, a jumpering diagram is not applicable.
if_sl, ifLib, tyLib, John Romkey: RFC-1055, A Nonstandard for Transmission of IP Datagrams Over Serial Lines: SLIP, Van Jacobson: RFC-1144, entitled Compressing TCP/IP Headers for Low-Speed Serial Links
This program is based on original work done by Rick Adams of The Center for Seismic Studies and Chris Torek of The University of Maryland. The CSLIP enhancements are based on work done by Van Jacobson of University of California, Berkeley for the "cslip-2.7" release.
slipInit( ) - initialize a SLIP interface
STATUS slipInit ( int unit, /* SLIP device unit number (0 - 19) */ char * devName, /* name of the tty device to be initialized */ char * myAddr, /* address of the SLIP interface */ char * peerAddr, /* address of the remote peer SLIP interface */ int baud, /* baud rate of SLIP device: 0=don't set rate */ BOOL compressEnable, /* explicitly enable CSLIP compression */ BOOL compressAllow, /* enable CSLIP compression on Rx */ int mtu /* user set-able MTU */ )
This routine initializes a SLIP device. Its parameters specify the name of the tty device, the Internet addresses of both sides of the SLIP point-to-point link (i.e., the local and remote sides of the serial line connection), and CSLIP options.
The Internet address of the local side of the connection is specified in myAddr and the name of its tty device is specified in devName. The Internet address of the remote side is specified in peerAddr. If baud is not zero, the baud rate will be the specified value; otherwise, the default baud rate will be the rate set by the tty driver. The unit parameter specifies the SLIP device unit number. Up to twenty units may be created.
The CLSIP options parameters compressEnable and compressAllow determine support for TCP/IP header compression. If compressAllow is TRUE (1), then CSLIP will be enabled only if a CSLIP type packet is received by this device. If compressEnable is TRUE (1), then CSLIP compression will be enabled explicitly for all transmitted packets, and compressed packets can be received.
The MTU option parameter allows the setting of the MTU for the link.
For example, the following call initializes a SLIP device, using the console's second port, where the Internet address of the local host is 192.10.1.1 and the address of the remote host is 192.10.1.2. The baud rate will be the default rate for /tyCo/1. CLSIP is enabled if a CSLIP type packet is received. The MTU of the link is 1006.
slipInit (0, "/tyCo/1", "192.10.1.1", "192.10.1.2", 0, 0, 1, 1006);
OK, or ERROR if the device cannot be opened, memory is insufficient, or the route is invalid.
slipBaudSet( ) - set the baud rate for a SLIP interface
STATUS slipBaudSet ( int unit, /* SLIP device unit number */ int baud /* baud rate */ )
This routine adjusts the baud rate of a tty device attached to a SLIP interface. It provides a way to modify the baud rate of a tty device being used as a SLIP interface.
OK, or ERROR if the unit number is invalid or uninitialized.
slattach( ) - publish the sl network interface and initialize the driver and device
STATUS slattach ( int unit, /* SLIP device unit number */ int fd, /* fd of tty device for SLIP interface */ BOOL compressEnable, /* explicitly enable CSLIP compression */ BOOL compressAllow, /* enable CSLIP compression on Rx */ int mtu /* user setable MTU */ )
This routine publishes the sl interface by filling in a network interface record and adding this record to the system list. It also initializes the driver and the device to the operational state.
This routine is usually called by slipInit( ).
OK or ERROR.
slipDelete( ) - delete a SLIP interface
STATUS slipDelete ( int unit /* SLIP unit number */ )
This routine resets a specified SLIP interface. It detaches the tty from the sl unit and deletes the specified SLIP interface from the list of network interfaces. For example, the following call will delete the first SLIP interface from the list of network interfaces:
slipDelete (0);
OK, or ERROR if the unit number is invalid or uninitialized.