[Previous] [Contents] [Index] [Next]

vp_getpkt()

Get a packet from the stack

Synopsis:

#include <net/if_vp.h>

struct mbuf vp_getpkt( vpid_t id, 
                       void * info );

Library:

vpack3r.lib, vpack3s.lib

Description:

The vp_getpkt() function returns an mbuf chain that contains one whole IP packet. Every address in the mbuf chain is converted to your application's address space.

id
A virtual packet ID returned by vp_attach().
info
Points to the buffer where information is stored about the packet. The packet information is discarded when NULL is passed.

Whenever inProxy is triggered (it's submitted during the vp_attach() call), your application can call vp_getpkt() to get a packet from the stack.

VPI as a network interface

If the VPI is registered as a network interface, a ni_pktinfo structure is returned:

struct ni_pktinfo
{
    struct sockaddr dst;
};

The ni_pktinfo structure tells the network interface where the packet is to be sent. This information is necessary if the destination IP address in the packet is reachable though a router.

VPI as an IP filter

If the VPI is registered as an IP filter, a flt_pktinfo structure is returned:

struct flt_pktinfo
{
    short flag;
    char ifname[IFNAMSIZ];
    struct timeval tstamp;
};
flag
One of:
PACKET_INPUT
Indicates an inbound packet.
PACKET_OUTPUT
Indicates an outbound packet.
ifname
The name of the interface where the packet came from (inbound) or where it's going to (outbound).
tstamp
The time the packet went through the stack.

Note: We recommend that an IP filter program always catch the above information (even if the filter program itself isn't going to use it) and return it to the stack during a vp_putpkt() call, because other filters that check this packet might require the information.

Returns:

A pointer to the beginning of an mbuf chain, or NULL if it can't get a packet.

Classification:

QNX 4

Safety:
Interrupt handler No
Signal handler No
Thread No

[Previous] [Contents] [Index] [Next]