- 论坛徽章:
- 0
|
为啥这些内容没有一本书提到:
sockaddr_ll 这个类型,在UNP,begin linux programming,GNU/Linux Application Programming中都找不到..
是因为来不及更新吗?
UNP也只是介绍了pcap-对PF_pACKET的封装
man packet
PACKET(7) Linux Programmer's Manual PACKET(7)
NAME
packet, PF_PACKET - packet interface on device level.
SYNOPSIS
#include <sys/socket.h>
#include <netpacket/packet.h>
#include <net/ethernet.h> /* the L2 protocols */
packet_socket = socket(PF_PACKET, int socket_type, int protocol);
DESCRIPTION
Packet sockets are used to receive or send raw packets at the device driver (OSI Layer 2) level. They allow the user to implement protocol modules in user space on top of the physical layer.
The socket_type is either SOCK_RAW for raw packets including the link level header or SOCK_DGRAM for cooked packets with the link level header removed. The link level header information is available in a common format in a
sockaddr_ll. protocol is the IEEE 802.3 protocol number in network order. See the <linux/if_ether.h> include file for a list of allowed protocols. When protocol is set to htons(ETH_P_ALL) then all protocols are received.
All incoming packets of that protocol type will be passed to the packet socket before they are passed to the protocols implemented in the kernel. |
|