Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ethernet Driver hook functions

110 views
Skip to first unread message

D.K.

unread,
Nov 8, 2000, 3:00:00 AM11/8/00
to
Hi,

I need to receive Ethernet frames before the IP layer receives them and then
decide whether to transfer them to IP, drop them or both copy them to my
application and transfer them to IP.

The "VxWorks Network - programmer's guide" mentions Ethernet Hook functions
(Chap. 14, pg. 209) that can be set for both receive and transmit and thus
solve this problem.

However, there is a note that says that this feature will not be supported
in the future.
I made a simple test and wrote 2 functions with the described prototype,
that just do a "printf" (send or receive). Then I used etherInputHookAdd()
and EtherOutputHookAdd() to install them.
It seems like the output hook is working (although I can't say that for
certain since this is only a very simple test), but I can't get the Input
hook to work. I have tried many combinations, but with no success.

I suspect that these features (or some of them) were already dropped, but I
am not sure.

Has anyone dealt with this problem before or know of another way to achive
the same thing?

My environment is:
OS: VxWorks real time operating system.
Development tool: Tornado 2.
Compiler: Diab-Data 4.3g
Board: MCP750 board with the PowerPC 750 by Motorola

Attached is one sample of the code that I tried:

-------------------- start of code------------------------------------------

BOOL dec_ether_input_hook_func(struct ifnet *pif, char *buffer,int length)
{
printf("dec received\n");
return FALSE;
}


BOOL dec_ether_output_hook_func(struct ifnet *pif,char *buffer,int length)
{
printf("dec sent\n");
return FALSE;
}

STATUS HookDec21140()
{
int flags;

printf("Setting hook input function to Dec Ethernet...\n");
if (etherInputHookAdd(etherInputHookRtn, "dc", 0) == OK)
{
printf("OK\n");
}
else
{
printf("FAILED! error number: %d\n", ERROR);
return ERROR;
};

printf("Setting hook output function to Dec Ethernet...\n");
if (etherOutputHookAdd(dec_ether_output_hook_func, "dc", 0) == OK)
{
printf("OK\n");
}
else
{
printf("FAILED! error number: %d\n", ERROR);
return ERROR;
};

printf("Switching to promiscuous mode DEC...\n");
if (ifFlagChange("dc0", IFF_PROMISC, TRUE) == OK)
{
printf("OK\n");
}
else
{
printf("FAILED! error number: %d\n", ERROR);
return ERROR;
};

printf("Switching driver to UP mode (DEC)...\n");
if (ifFlagChange("dc0", IFF_UP, TRUE) == OK)
{
printf("OK\n");
}
else
{
printf("FAILED! error number: %d\n", ERROR);
return ERROR;
};

printf("Setting driver flags (DEC)...\n");
if (ifFlagSet("dc0", IFF_PROMISC|IFF_UP) == OK)
{
printf("OK\n");
}
else
{
printf("FAILED! error number: %d\n", ERROR);
return ERROR;
};


return 0;
}


--------------------- end of code------------------------------------------

Thanks,
DK

DrDiags

unread,
Nov 8, 2000, 3:00:00 AM11/8/00
to
D.K,

I cannot answer the reason why the EtherInputHook is not working, but I
wanted to mention that you should treat your hook routines as though they were
ISRs. Suggest using logMsg instead of printf in these routines.

>> Some original text removed.

>
>
> I need to receive Ethernet frames before the IP layer receives them and then
> decide whether to transfer them to IP, drop them or both copy them to my
> application and transfer them to IP.
>
> The "VxWorks Network - programmer's guide" mentions Ethernet Hook functions
> (Chap. 14, pg. 209) that can be set for both receive and transmit and thus
> solve this problem.
>
> However, there is a note that says that this feature will not be supported
> in the future.
> I made a simple test and wrote 2 functions with the described prototype,
> that just do a "printf" (send or receive). Then I used etherInputHookAdd()
> and EtherOutputHookAdd() to install them.
> It seems like the output hook is working (although I can't say that for
> certain since this is only a very simple test), but I can't get the Input
> hook to work. I have tried many combinations, but with no success.
>
> I suspect that these features (or some of them) were already dropped, but I
> am not sure.
>

I believe there is a kernel option to add BSD 4.3 support. I thought it was
VxWorks implementation of BSD 4.4 where the support for EtherHooks may be phased
by the MUX layer protocol. I am only winging this one.

Dave Korn

unread,
Nov 9, 2000, 3:00:00 AM11/9/00
to
DrDiags wrote in message <3A0A38AC...@flashcom.net>...

>D.K,
>
> I cannot answer the reason why the EtherInputHook is not working, but I
>wanted to mention that you should treat your hook routines as though they
were
>ISRs. Suggest using logMsg instead of printf in these routines.

Actually, you almost certainly did just answer why the input hook isn't
working. The output functions are called directly by the task that is
sending - that is the control flows from the task through the kernel
send routine and into the device driver output function (through the
hook, if installed, on the way), whereas incoming packets which may
arrive at any time are caught by an ISR. The ISR calls the input hook
before pushing the newly received packet onto the end of a queue
for the tNetTask to deal with at a more convenient time. So output
hooks would be expected to run in a task context and handle printf
OK, but input hooks run in an ISR context and can't use most of
the system calls without trouble.

Presumably the manual advises treating *both* hooks as if they
were ISRs just to be on the safe side. It's certainly good advice,
in case they ever want to implement a mechanism for asynchronous
sends where the foreground task just hands off the outgoing
packet to be sent later by an ISR.

DaveK
--
They laughed at Galileo. They laughed at Copernicus. They laughed at
Columbus. But remember, they also laughed at Bozo the Clown.

Luke Diamand

unread,
Nov 9, 2000, 10:24:11 PM11/9/00
to
I think you want to use the MUX_PROTO_SNARF technique - i.e. you
install a MUX protocol of type 'MUX_PROTO_SNARF' which sees all the
packets and can eat them or pass them on as it sees fit.

The etherhook functions are now implemented as wrappers around the
SNARF stuff now, IIRC.

One buglette is that you can only have one snarfing protocol (or
some such restriction) so if something else is trying to do the same
trick, you will lose. Certainly, the DHCP server (or perhaps the client?)
does this.

HTH!
Luke Diamand

On Wed, 8 Nov 2000 20:48:59 +0200, D.K. <du...@wavion.com> wrote:
>Hi,


>
>I need to receive Ethernet frames before the IP layer receives them and then
>decide whether to transfer them to IP, drop them or both copy them to my
>application and transfer them to IP.
>
>The "VxWorks Network - programmer's guide" mentions Ethernet Hook functions
>(Chap. 14, pg. 209) that can be set for both receive and transmit and thus
>solve this problem.
>
>However, there is a note that says that this feature will not be supported
>in the future.
>I made a simple test and wrote 2 functions with the described prototype,
>that just do a "printf" (send or receive). Then I used etherInputHookAdd()
>and EtherOutputHookAdd() to install them.
>It seems like the output hook is working (although I can't say that for
>certain since this is only a very simple test), but I can't get the Input
>hook to work. I have tried many combinations, but with no success.
>
>I suspect that these features (or some of them) were already dropped, but I
>am not sure.
>

>Has anyone dealt with this problem before or know of another way to achive
>the same thing?
>
>My environment is:
>OS: VxWorks real time operating system.
>Development tool: Tornado 2.
>Compiler: Diab-Data 4.3g
>Board: MCP750 board with the PowerPC 750 by Motorola
>
>Attached is one sample of the code that I tried:
>
>-------------------- start of code------------------------------------------
>
>BOOL dec_ether_input_hook_func(struct ifnet *pif, char *buffer,int length)
>{
> printf("dec received\n");
> return FALSE;
>}
>
>


--

0 new messages