VxWorks Reference Manual : Libraries

ipFilterLib

NAME

ipFilterLib - ip filter hooks library

ROUTINES

ipFilterLibInit( ) - initialize ip filter facility
ipFilterHookAdd( ) - add a routine to receive all internet protocol packets
ipFilterHookDelete( ) - delete a ip filter hook routine

DESCRIPTION

This library provides utilities that give direct access to IP packets. Incoming raw IP packets can be examined or processed using the hooks ipFilterHookAdd( ). The input hook can be used to receive raw IP packets that are a part of IP (Internet Protocol) protocols. The filter hook can also be used to build IP traffic monitoring and testing tools.

Normally, the network should be accessed through the higher-level socket interface provided in sockLib. The routines in ipFilterLib should rarely, if ever, be necessary for applications.

The ipFilterLibInit( ) routine links the ip filtering facility into the VxWorks system. This is performed automatically if INCLUDE_IP_FILTER is defined in configAll.h.

SEE ALSO

ipFilterLib, VxWorks Programmer's Guide: Network


Libraries : Routines

ipFilterLibInit( )

NAME

ipFilterLibInit( ) - initialize ip filter facility

SYNOPSIS


void ipFilterLibInit (void)

DESCRIPTION

This routine links the ip filter facility into the VxWorks system. These routines are included automatically if INCLUDE_IP_FILTER is defined in configAll.h.

RETURNS

N/A

SEE ALSO

ipFilterLib


Libraries : Routines

ipFilterHookAdd( )

NAME

ipFilterHookAdd( ) - add a routine to receive all internet protocol packets

SYNOPSIS

STATUS ipFilterHookAdd
    (
    FUNCPTR ipFilterHook /* routine to receive raw ip packets */
    )

DESCRIPTION

This routine adds a hook routine that will be called for every IP packet that is received.

The calling sequence of the filter hook routine is:

    BOOL ipFilterHook
         (
         struct ifnet *pIf,        /* interface packet was received on */
         struct mbuf **pPtrMbuf,   /* pointer to pointer to an mbuf chain */
         struct ip   **pPtrIpHdr,  /* pointer to pointer to ip header */ 
         int          ipHdrLen,    /* ip packet header length */
         )
The hook routine should return TRUE if it has handled the input packet and no further action should be taken with it. If returning TRUE the ipFilterHook is responsible for freeing the mbuf chain by calling m_freem(*pPtrMbuf). It should return FALSE if it has not handled the ipFilterHook and normal processing (e.g., Internet) should take place.

The packet is in a mbuf chain of which a pointer to a pointer is passed as one of the arguments. The pointer to the mbuf should be accessed by dereferencing the pointer to pointer, pPtrMbuf. This mbuf chain will be reused upon return from the hook. If the hook routine needs to retain the input packet, it should copy it elsewhere. by using the macro copy_from_mbufs (buffer, *pPtrMbuf, len). copy_from_mbufs is defined "net/mbuf.h"

pPtrIpHdr is a pointer to a pointer to a IP header. The pointer to the ip header is obtained by dereferencing pPtrIpHdr. The ip header is used to examine and process the fields in the ip header. The fields ip_len, ip_id and ip_offset in the ip header are converted to the host byte order from the network byte order before a packet is handed to the filter hook.

The pPtrMbuf and pPtrIpHdr are reused upon return from the hook if it is returning FALSE.

Normally you will not be needing to modify pPtrMbuf or the pPtrIpHdr.

RETURNS

OK, always.

SEE ALSO

ipFilterLib


Libraries : Routines

ipFilterHookDelete( )

NAME

ipFilterHookDelete( ) - delete a ip filter hook routine

SYNOPSIS


void ipFilterHookDelete (void)

DESCRIPTION

This routine deletes an ip filter hook.

RETURNS

N/A

SEE ALSO

ipFilterLib