开发者

how to use VxWorks etherOutputHookAdd

开发者 https://www.devze.com 2023-03-04 11:40 出处:网络
I\'m stumped trying to get etherOutputHookAdd() to work. Its counterpart, etherInputHookAdd(), seems to work fine. The OS version in question is VxWorks 5.4 .

I'm stumped trying to get etherOutputHookAdd() to work. Its counterpart, etherInputHookAdd(), seems to work fine. The OS version in question is VxWorks 5.4 .

The hook code looks like so (the code I intend to actually run is more complicated, but this serves for an example.)

int anCounter;
STATUS etherHook(struct ifnet *pif, char *buf, int size)
{
    anCounter += 1;
    return FALSE;
}

I can hook up etherInputHookAdd from the vxworks shell like so

etherInputHookAdd etherHook,"fei",0

This returns 0 (STATUS OK), after which examination of the 'anCounter' variable will indicate activity as expected. However, no such luck with the output direction. I've tried both of these command lines

etherOutputHookAdd etherHook,"fei",0
etherOutputHookAdd etherHook

Both of these return OK, but the hook routine doesn't seem to be getting called at all. My best hypotheses are (1) I'm missing an initialization step, or calling it wrong, (2) the etherOutputHookAdd implementation is just a stub, (3) you just can't call it from the shell, or (4) maybe my nic driver imple开发者_如何学运维mentation is buggy.

Any ideas that solve the central problem - how do I see what's being sent off my board - are welcome.


The following VxWorks network drivers support both the input-hook and output-hook routines:

if_cpm - Motorola MC68EN360 QUICC network interface driver 
if_eex - Intel EtherExpress 16 
if_ei - Intel 82596 ethernet driver
if_elc - SMC 8013WC Ethernet driver
if_elt - 3Com 3C509 Ethernet driver
if_ene - Novell/Eagle NE2000 network driver
if_fn - Fujitsu MB86960 NICE Ethernet driver
if_ln - Advanced Micro Devices Am7990 LANCE Ethernet driver
if_sm - shared memory backplane network interface driver
if_sn - National Semiconductor DP83932B SONIC Ethernet driver
if_ultra - SMC Elite Ultra Ethernet network interface driver

if_gn - generic MUX interface layer

The following drivers support only the input-hook routines:

if_nic - National Semiconductor SNIC Chip (for HKV30)
if_sl - Serial Line IP (SLIP) network interface driver

The following drivers support only the output-hook routines:

if_ulip - network interface driver for User Level IP (VxSim)

The following drivers do not support either the input-hook or output-hook routines:

if_loop - software loopback network interface driver


To those few who might stumble this way .. It was the horrible 'hypothesis 4'!

It turns out that in order for etherOutputHookAdd() to work correctly, it is incumbent on the NIC device driver writer to include a call to the function pointed to by etherOutputHookRtn. All etherOutputHookAdd() does is add your proffered packet handler to a list, so that when a NIC driver calls etherOutputHookRtn, you get a copy of what's being transmitted. Sadly, there are many drivers where for whatever reason, this was simply not done.

So in cases such as this one, there are only two courses of action.

  • find a patch for your driver, or patch it yourself
  • change tactics entirely, e.g., try using etherInputHookAdd() on the other side.


In case you migrate to a newer version (>6.x) of VxWorks , etherLib is no longer supported. Instead, one can use muxLib for a similar purpose.

  • Hook inbound traffic: Use muxBind with MUX_PROTO_PROMISC or MUX_PROTO_OUTPUT.
  • Hook outbound traffic: Use muxBind with MUX_PROTO_OUTPUT.

You should provide a callback routine in both cases.

0

精彩评论

暂无评论...
验证码 换一张
取 消