02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VxWorks 5.5<br />

<strong>BSP</strong> Developer’s <strong>Guide</strong><br />

A protocol writer has to deal only with calls to the MUX. Everything<br />

device-specific is handled in the drivers of the data link layer, the layer below the<br />

MUX.<br />

Protocol Startup<br />

Each protocol that wants to receive packets must first attach itself to the MUX. To<br />

do this, the protocol calls muxBind( ). The returned function value is a “cookie”<br />

that identifies the network interface driver to which the MUX has bound the<br />

protocol. The protocol must save this cookie for use in subsequent calls to the<br />

MUX.<br />

As input to the muxBind( ), you must specify the name of a network device (for<br />

example, ln and 0, ln and 1, ei and 0, and so on), the appropriate receive, restart,<br />

and shutdown functions for the protocol, a protocol type (from RFC 1700), and a<br />

name for the attaching protocol.<br />

The MUX uses the protocol type to prioritize the protocols. This priority<br />

determines which protocol sees packets first. When a driver passes a packet up to<br />

the MUX, the driver includes a pointer to its END_OBJ structure. Included in this<br />

structure is the member, protocols, the head of the list of protocols (a list of<br />

NET_PROTOCOL structures) listening to this device. The order of the protocols in<br />

this list determines the order in which the protocols see the packet. Maintaining<br />

this list is the responsibility of the MUX.<br />

If a protocol specifies a type of MUX_PROTO_SNARF in its muxBind( ), the MUX<br />

adds the protocol to the top of the list in END_OBJ.protocols. At any given<br />

moment, the MUX allows only one active protocol of type MUX_PROTO_SNARF.If<br />

a protocol specifies a type of MUX_PROTO_PROMISC in its muxBind( ), the MUX<br />

adds the protocol to the bottom of the list in END_OBJ.protocols. If a protocol<br />

specifies any other type in its muxBind( ), the MUX adds the protocol to the list just<br />

after the MUX_PROTO_SNARF protocol (or the top of the list if there is no protocol<br />

of type MUX_PROTO_SNARF).<br />

This shuffling of protocols ensures that lower priority protocols cannot steal or<br />

damage a packet before a higher priority protocol gets to see the packet.<br />

Snarfing Protocols Block Packets to Lower Priority Protocols<br />

If the receive routine for a protocol returns TRUE, and, if the protocol is not of type<br />

MUX_PROTO_PROMISC, the MUX lets the protocol snarf the packet (that is, the<br />

MUX lets the protocol take delivery of the packet). If a protocol takes delivery of<br />

302

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!