📄 etherlib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/etherLib.html - generated by refgen from etherLib.c --> <title> etherLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual : Libraries</i></a></p></blockquote><h1>etherLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>etherLib</strong> - Ethernet raw I/O routines and hooks </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./etherLib.html#etherOutput">etherOutput</a></i>( )</b> - send a packet on an Ethernet interface<br><b><i><a href="./etherLib.html#etherInputHookAdd">etherInputHookAdd</a></i>( )</b> - add a routine to receive all Ethernet input packets<br><b><i><a href="./etherLib.html#etherInputHookDelete">etherInputHookDelete</a></i>( )</b> - delete a network interface input hook routine<br><b><i><a href="./etherLib.html#etherOutputHookAdd">etherOutputHookAdd</a></i>( )</b> - add a routine to receive all Ethernet output packets<br><b><i><a href="./etherLib.html#etherOutputHookDelete">etherOutputHookDelete</a></i>( )</b> - delete a network interface output hook routine<br><b><i><a href="./etherLib.html#etherAddrResolve">etherAddrResolve</a></i>( )</b> - resolve an Ethernet address for a specified Internet address<br><b><i><a href="./etherLib.html#etherTypeGet">etherTypeGet</a></i>( )</b> - get the type from an ethernet packet<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides utilities that give direct access to Ethernet packets.Raw packets can be output directly to an interface using <b><i><a href="./etherLib.html#etherOutput">etherOutput</a></i>( )</b>.Incoming and outgoing packets can be examined or processed using the hooks<b><i><a href="./etherLib.html#etherInputHookAdd">etherInputHookAdd</a></i>( )</b> and <b><i><a href="./etherLib.html#etherOutputHookAdd">etherOutputHookAdd</a></i>( )</b>. The input hook can be used toreceive raw packets that are not part of any of the supported networkprotocols. The input and output hooks can also be used to build networkmonitoring and testing tools.<p>Normally, the network should be accessed through the higher-level socketinterface provided in sockLib. The routines in <b><a href="./etherLib.html#top">etherLib</a></b> should rarely,if ever, be necessary for applications.<p></blockquote><h4>CAVEAT</h4><blockquote><p>The following VxWorks network drivers support both the input-hook andoutput-hook routines:<p> if_cpm - Motorola MC68EN360 QUICC network interface driver <br> if_eex - Intel EtherExpress 16 <br> if_ei - Intel 82596 ethernet driver<br> if_elc - SMC 8013WC Ethernet driver<br> if_elt - 3Com 3C509 Ethernet driver<br> if_ene - Novell/Eagle NE2000 network driver<br> if_fn - Fujitsu MB86960 NICE Ethernet driver<br> if_ln - Advanced Micro Devices Am7990 LANCE Ethernet driver<br> if_sm - shared memory backplane network interface driver<br> if_sn - National Semiconductor DP83932B SONIC Ethernet driver<br> if_ultra - SMC Elite Ultra Ethernet network interface driver<p> if_gn - generic MUX interface layer<p>The following drivers support only the input-hook routines:<p> if_nic - National Semiconductor SNIC Chip (for HKV30)<br> if_sl - Serial Line IP (SLIP) network interface driver<p>The following drivers support only the output-hook routines:<p> if_ulip - network interface driver for User Level IP (VxSim)<p>The following drivers do not support either the input-hook or output-hookroutines:<p> if_loop - software loopback network interface driver<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>etherLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./etherLib.html#top">etherLib</a></b>, <i>VxWorks Programmer's Guide: Network</i><hr><a name="etherOutput"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>etherOutput</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>etherOutput</i>( )</strong> - send a packet on an Ethernet interface</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS etherOutput ( struct ifnet * pIf, /* interface on which to send */ struct ether_header * pEtherHeader, /* Ethernet header to send */ char * pData, /* data to send */ int dataLength /* # of bytes of data to send */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine sends a packet on the specified Ethernet interface bycalling the interface's output routine directly.<p>The first argument <i>pIf</i> is a pointer to a variable of type <b>struct ifnet</b>which contains some useful information about the network interface. Aroutine named <b><i><a href="./ifLib.html#ifunit">ifunit</a></i>( )</b> can retrieve this pointer from the system in thefollowing way:<pre> struct ifnet *pIf; ... pIf = ifunit ("ln0");</pre>If <b><i><a href="./ifLib.html#ifunit">ifunit</a></i>( )</b> returns a non-NULL pointer, it is a valid pointer tothe named network interface device structure of type <b>struct ifnet</b>.In the above example, <i>pIf</i> points to the data structure thatdescribes the first LANCE network interface device if <b><i><a href="./ifLib.html#ifunit">ifunit</a></i>( )</b> issuccessful.<p>The second argument <i>pEtherHeader</i> should contain a valid Ethernet addressof the machine for which the message contained in the argument <i>pData</i> isintended. If the Ethernet address of this machine is fixed and well-knownto the user, filling in the structure <b>ether_header</b> can be accomplished byusing <b><i><a href="./bLib.html#bcopy">bcopy</a></i>( )</b> to copy the six-byte Ethernet address into the <b>ether_dhost</b>field of the structure <b>ether_header</b>. Alternatively, users can make use ofthe routine <b><i><a href="./etherLib.html#etherAddrResolve">etherAddrResolve</a></i>( )</b> which will use ARP (Address ResolutionProtocol) to resolve the Ethernet address for a specified Internetaddress.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the routine runs out of mbufs.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./etherLib.html#top">etherLib</a></b>, <b><i><a href="./etherLib.html#etherAddrResolve">etherAddrResolve</a></i>( )</b><hr><a name="etherInputHookAdd"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>etherInputHookAdd</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>etherInputHookAdd</i>( )</strong> - add a routine to receive all Ethernet input packets</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS etherInputHookAdd ( FUNCPTR inputHook, /* routine to receive Ethernet input */ char* pName, /* name of device if MUX/END is being used */ int unit /* unit of device if MUX/END is being used */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds a hook routine that will be called for every Ethernetpacket that is received.<p>The calling sequence of the input hook routine is:<pre> BOOL inputHook ( struct ifnet *pIf, /* interface packet was received on */ char *buffer, /* received packet */ int length /* length of received packet */ )</pre>The hook routine should return TRUE if it has handled the input packet andno further action should be taken with it. It should return FALSE if ithas not handled the input packet and normal processing (for example, Internet) should take place.<p>The packet is in a temporary buffer when the hook routine is called.This buffer will be reused upon return from the hook. If the hookroutine needs to retain the input packet, it should copy it elsewhere.<p></blockquote><h4>IMPLEMENTATION</h4><blockquote><p>A call to the function pointed to by the global function pointer<b>etherInputHookRtn</b> should be invoked in the receive routine of everynetwork driver providing this service. For example:<pre> ... #include "etherLib.h" ... xxxRecv () ... /* call input hook if any */ if ((etherInputHookRtn != NULL) && (* etherInputHookRtn) (&ls->ls_if, (char *)eh, len)) { return; /* input hook has already processed this packet */ }</pre></blockquote><h4>RETURNS</h4><blockquote><p>OK, always.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./etherLib.html#top">etherLib</a></b><hr><a name="etherInputHookDelete"></a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -