packet_type
主要查看的是kernel/msm-5.4/net/ipv4/ip_input.c, 入口函数ip_rcv
但是ip_rcv的配置或者调用地方:
kernel/msm-5.4/net/ipv4/af_inet.c
static struct packet_type ip_packet_type __read_mostly = {
.type = cpu_to_be16(ETH_P_IP),
.func = ip_rcv,
.list_func = ip_list_rcv,
};
dev_add_pack(&ip_packet_type);
然后需要了解packet_type
https://blog.youkuaiyun.com/qq_20817327/article/details/106765450
参考链接里有网络抓包tcpdump的大致原理
重要函数就是:dev_add_pack 和 __dev_remove_pack,netif_receive_skb
netif_receive_skb是从驱动里接收的入口
kernel/msm-5.4/net/core/dev.c
kernel/msm-5.4/include/linux/netdevice.h
struct packet_type {
__be16 type; /* This is really htons(ether_type). */
bool ignore_outgoing;
struct net_device *dev; /* NULL is wildcarded here */
int (*func) (struct sk_buff *,
struct net_device *,
struct packet_type *,
struct net_device *);
void (*list_func) (struct list_head *,
struct packet_type *,
struct net_device *);
bool (*id_match)(struct packet_type *ptype,
struct sock *sk);
void *af_packet_priv;
struct list_head list;
};