Table des matières
packet_sockets
Using Packet Sockets
To use a packet socket, specify AF_PACKET as the domain in any of the standard socket APIs in the sockLib library. Specify one of the following two values as the socket type:
- SOCK_RAW for raw packets including the link level header
- SOCK_DGRAM for cooked packets with the link level header removed
The link level header information is available in a common format in an Ip_sockaddr_ll. For the sll_protocol field, you can specify any of the IPNET_ETH_P_xxx constants in network order for the Ethernet value. See the following include file for a list of allowed protocols:
- installDir/vxworks-6.x/target/h/wrn/coreip/net/if_ll.h
When a system receives incoming packets of the specified protocol type, it passes them to the packet socket before passing them further to the protocols implemented in the network stack.When protocol is set to ip_htons( IPNET_ETH_P_ALL ), the system receives all protocols.
The connect( ) operation is not supported on packet sockets.
Raw Packets
SOCK_RAW packets are passed to and from the device driver without any changes in the packet data. When the system receives a packet, it parses the address and passes it in a standard Ip_sockaddr_ll address structure. When a system transmits a packet, the user-supplied buffer must contain the physical layer header. That packet is then queued, unmodified, to the network driver of the interface defined by the destination address.
Cooked Packets
SOCK_DGRAM operates on a slightly higher level. The physical header is removed before the packet is passed to the user. Packets sent through a SOCK_DGRAM packet socket get a suitable physical layer header based on the information in the Ip_sockaddr_ll destination address before they are queued.
