linux内核网络学习记录

  1. 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);

  1. 然后需要了解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;
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值