首页 > 其他分享 >网络层协议注册

网络层协议注册

时间:2023-06-01 10:36:50浏览次数:29  
标签:协议 head struct list 网络层 ptype packet 注册 type

static DEFINE_SPINLOCK(ptype_lock); 

struct list_head ptype_base[PTYPE_HASH_SIZE] ; 
struct list_head ptype_all ; /* Taps */

struct packet_type {
__be16  type; /* This is really htons(ether_type). */
struct net_device *dev; /* NULL is wildcarded here     */
int (*func) (struct sk_buff *,
struct net_device *,
struct packet_type *,
struct net_device *);
bool (*id_match)(struct packet_type *ptype,
   struct sock *sk);
void *af_packet_priv;
struct list_head list;
 };
void dev_add_pack(struct packet_type *pt)
 {
struct list_head *head = ptype_head(pt);


spin_lock(&ptype_lock);
list_add_rcu(&pt->list, head);
spin_unlock(&ptype_lock);
 }
 EXPORT_SYMBOL(dev_add_pack);
void __dev_remove_pack(struct packet_type *pt)
 {
struct list_head *head = ptype_head(pt);
struct packet_type *pt1;


spin_lock(&ptype_lock);


list_for_each_entry(pt1, head, list) {
if (pt == pt1) {
list_del_rcu(&pt->list);
goto out;
}
}


pr_warn("dev_remove_pack: %p not found\n", pt);
 out:
spin_unlock(&ptype_lock);
 }
 EXPORT_SYMBOL(__dev_remove_pack);
void dev_remove_pack(struct packet_type *pt)
 {
__dev_remove_pack(pt);


synchronize_net();
 }
 EXPORT_SYMBOL(dev_remove_pack);
static struct packet_type ip_packet_type = {
.type = cpu_to_be16(ETH_P_IP),
.func = ip_rcv,
 };static struct packet_type ipv6_packet_type  = {
.type = cpu_to_be16(ETH_P_IPV6),
.func = ipv6_rcv,
 };static struct packet_type can_packet __read_mostly = {
.type = cpu_to_be16(ETH_P_CAN),
.func = can_rcv,
 };


 static struct packet_type canfd_packet __read_mostly = {
.type = cpu_to_be16(ETH_P_CANFD),
.func = canfd_rcv,
 };static struct packet_type rarp_packet_type = {
.type =  cpu_to_be16(ETH_P_RARP),
.func =  ic_rarp_recv,
 };
static struct packet_type llc_packet_type __read_mostly = {
.type = cpu_to_be16(ETH_P_802_2),
.func = llc_rcv,
 };


 static struct packet_type llc_tr_packet_type __read_mostly = {
.type = cpu_to_be16(ETH_P_TR_802_2),
.func = llc_rcv,
 };

标签:协议,head,struct,list,网络层,ptype,packet,注册,type
From: https://blog.51cto.com/u_11860992/6392695

相关文章

  • 发送IP封包到高层协议
    intip_local_deliver(structsk_buff*skb){/**ReassembleIPfragments.*/structnet*net=dev_net(skb->dev);if(ip_is_fragment(ip_hdr(skb))){if(ip_defrag(net,skb,IP_DEFRAG_LOCAL_DELIVER))return0;}returnNF_HOOK......
  • Linux 内核时钟架构之时钟事件设备注册
    voidclockevents_register_device(structclock_event_device*dev);voidclockevents_config_and_register(structclock_event_device*dev,u32freq,unsignedlongmin_delta,unsignedlongmax_delta);相关的一个是配置函数voidclocke......
  • 授权码 + PKCE 模式|OIDC & OAuth2.0 认证协议最佳实践系列【03】
    在上一篇文章中,我们介绍了 OIDC 授权码模式(点击下方链接查看),本次我们将重点围绕授权码+PKCE模式(AuthorizationCodeWithPKCE)进行介绍,从而让你的系统快速具备接入用户认证的标准体系。OIDC&OAuth2.0认证协议最佳实践系列02-授权码模式(AuthorizationCode)接入Authing......
  • 一文通吃:从 ZooKeeper 一致性,Leader选举讲到 ZAB 协议与 PAXOS 算法(下)
    本文首发自「慕课网」,想了解更多IT干货内容,程序员圈内热闻,欢迎关注"慕课网"或慕课网公众号!作者:大能|慕课网讲师上篇文章,我们介绍了ZooKeeper集群保证数据一致性和Zookeeper集群Leader选举,这边文章我们接着介绍ZAB协议和Paxos算法ZAB协议在ZooKeeper在处理事务型请求的时候有提到......
  • (转)微服务注册中心:Consul——服务发现
    原文:https://xie.infoq.cn/article/4fe6f02b220fb009844861b56https://www.cnblogs.com/myitnews/p/13655000.html一概述说完了Consul的服务注册,那么就该到服务发现了。大家有过rpc框架使用经验的,例如nacos、eureka、dubbo等,就会了解服务中的角色,也就是生产者和消费者,也......
  • TCPIP详解-地址解析协议ARP
    TCP/IP详解-地址解析协议ARPIP协议的设计目标是为跨越不同类型物理网络的分组交换提供互操作。这需要网络层软件使用的地址和底层网络硬件使用的地址之间进行转换。网络接口硬件通常有一个主要的硬件地址定位到正确的接口;否则,无法传输数据。但是,一个传统IPv4网路偶需要使用自己的......
  • SD协议-基本概念
    1.SD协议版本SD1.1SD2.0SD3.0在看协议的时候,需要注意协议的版本,注意版本之间的差别SD协议是常见的数据通信和存储卡之间的协议HDMI是显示相关的协议,遵循HDMI协议USB遵循USB协议,USB3.0协议的复杂度高于USB2.0主要学习的是协议的分析方法2.systemfeatureSD存储......
  • 针对HTTP协议-弱点分析
     ......
  • SSH协议-漏洞渗透挖掘
     ......
  • 云南中茶茶业有限公司与大连联中茶业有限公司成功签订合作协议
        2023年5月18日,央企中粮旗下云南中茶茶业有限公司、中茶普洱茶叶有限公司、中茶(勐海)茶业有限公司与大连联中茶业有限公司在大连新天百茶城举办了《云南中茶茶业有限公司特殊渠道经销合同》的签约仪式。云南中茶茶业有限公司东北大区负责人马洪浩、大连联中茶业有限公司董......