VxWorks Reference Manual : Libraries

bpfDrv

NAME

bpfDrv - Berkeley Packet Filter (BPF) I/O driver library

ROUTINES

bpfDrv( ) - initialize the BPF driver
bpfDevCreate( ) - create Berkeley Packet Filter device
bpfDevDelete( ) - destroy Berkeley Packet Filter device

DESCRIPTION

This library provides a driver which supports the customized retrieval of incoming network data that meets the criteria imposed by a user-specified filter.

USER-CALLABLE ROUTINES

The bpfDrv( ) routine initializes the driver and the bpfDevCreate( ) routine creates a packet filter device. Each BPF device allows direct access to the incoming data from one or more network interfaces.

CREATING BPF DEVICES

In order to retrieve incoming network data, a BPF device must be created by calling the bpfDevCreate( ) routine:

    STATUS bpfDevCreate
        (
        char *  pDevName,       /* I/O system device name */
        int     numUnits,       /* number of device units */
        int     bufSize         /* block size for the BPF device */
        )
The numUnits parameter specifies the maximum number of BPF units for the device. Each unit is accessed through a separate file descriptor for use with a unique filter and/or a different network interface. For example, the following call creates the "/bpf0" and "/bpf1" units:
    bpfDevCreate ("/bpf", 2, 4096);

CONFIGURING BPF DEVICES

After opening a device unit, the associated file descriptor must be bound to a specific network interface with the BIOCSETIF ioctl( ) option. The BIOCSETF ioctl( ) option adds any filter instructions. Each file descriptor receives a copy of any data which matches the filter. Different file descriptors may share the same interface. The underlying filters will receive an identical data stream.

IOCTL FUNCTIONS

The BPF driver supports the following ioctl( ) functions:

NOTE

When reading data from BPF units, the supplied buffer must be able to accept an entire block of data as defined by the bufSize parameter to the bpfDevCreate( ) routine. That value is also available with the BIOCGBLEN ioctl( ) option described above.

INCLUDE FILES

bpfDrv.h

SEE ALSO

bpfDrv, ioLib


Libraries : Routines

bpfDrv( )

NAME

bpfDrv( ) - initialize the BPF driver

SYNOPSIS


STATUS bpfDrv (void)

DESCRIPTION

This routine installs the Berkeley Packet Filter driver for access through the I/O system. It is required before performing any I/O operations and is executed automatically if INCLUDE_BPF is defined at the time the system is built. Subsequent calls to the routine just count the number of users with BPF access.

RETURNS

OK, or ERROR if initialization fails.

ERRNO

N/A

SEE ALSO

bpfDrv


Libraries : Routines

bpfDevCreate( )

NAME

bpfDevCreate( ) - create Berkeley Packet Filter device

SYNOPSIS

STATUS bpfDevCreate
    (
    char * pDevName, /* I/O system device name */
    int    numUnits, /* number of device units */
    int    bufSize   /* BPF device block size (0 for default) */
    )

DESCRIPTION

This routine creates a Berkeley Packet Filter device. Each of the numUnits units corresponds to a single available file descriptor for monitoring a network device. The pDevName parameter provides the name of the BPF device to the I/O system. The default name of "/bpf" (assigned if pDevName is NULL) produces units named "/bpf0", "/bpf1", etc., up to the numUnits limit.

RETURNS

OK, or ERROR if device creation failed.

ERRNO

S_ioLib_NO_DRIVER

SEE ALSO

bpfDrv


Libraries : Routines

bpfDevDelete( )

NAME

bpfDevDelete( ) - destroy Berkeley Packet Filter device

SYNOPSIS

STATUS bpfDevDelete
    (
    char * pDevName /* name of BPF device to remove */
    )

DESCRIPTION

This routine removes a Berkeley Packet Filter device and releases all allocated memory. It will close any open files using the device.

RETURNS

OK, or ERROR if device not found

ERRNO

S_ioLib_NO_DRIVER

SEE ALSO

bpfDrv