02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

H<br />

Implementing a MUX-Based Network Interface Driver<br />

typedef struct net_protocol<br />

{<br />

NODE node; /* How we stay in a list. */<br />

char name[32]; /* String name for this protocol. */<br />

long type; /* Protocol type from RFC 1700 */<br />

int flags; /* Is protocol in a promiscuous mode? */<br />

BOOL (*stackRcvRtn) (void *, long, M_BLK_ID, M_BLK_ID, void*);<br />

/* The routine to call when we get */<br />

/* a packet. */<br />

STATUS (*stackShutdownRtn) (void*, void*);<br />

/* The routine to call to shutdown */<br />

/* the protocol stack. */<br />

STATUS (*stackTxRestartRtn) (void*, void*);<br />

/* Callback for restarting on blocked tx. */<br />

void (*stackErrorRtn) (END_OBJ*, END_ERR*, void*);<br />

/* Callback for device errors. */<br />

void* pSpare; /* Spare pointer that can be passed to */<br />

/* the protocol. */<br />

} NET_PROTOCOL;<br />

Passing a Packet Up to the Protocol: stackRcvRtn( )<br />

Each protocol must provide the MUX with a routine that the MUX can use to pass<br />

packets up to the protocol. This routine must take the following form:<br />

void stackRcvRtn<br />

(<br />

void* pCookie, /* returned by muxBind() call */<br />

long type, /* protocol type from RFC 1700 */<br />

M_BLK_ID pNetBuff, /* packet with link level info */<br />

LL_HDR_INFO* pLinkHdr, /* link-level header info structure */<br />

void* pSpare /* a void* the protocol can use to get info */<br />

/* on receive. This was passed to muxBind().*/<br />

)<br />

H<br />

Your protocol must declare its stackRcvRtn( ) as void. Thus, this function returns<br />

no value.<br />

The parameters are:<br />

pCookie<br />

Expects the pointer returned from the muxBind( ) call. This pointer identifies<br />

the device to which the MUX has bound this protocol.<br />

type<br />

Expects the protocol type from RFC1700 or the SAP.<br />

pNetBuff<br />

Expects a pointer to an mBlk structure that contains the packet data and the<br />

link-level information.<br />

307

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

Saved successfully!

Ooh no, something went wrong!