Get a packet from the stack
#include <net/if_vp.h> struct mbuf vp_getpkt( vpid_t id, void * info );
vpack3r.lib, vpack3s.lib
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.
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.
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.
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; };
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. |
A pointer to the beginning of an mbuf chain, or NULL if it can't get a packet.
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |