📄 protocol.c
字号:
/* protocol.c * linqianghe@163.com * 2006-09-05 */#include "af_inet.h"#include "protocol.h"static DEFINE_SPINLOCK(myinet_proto_lock);int myinet_add_protocol( struct net_protocol *prot, unsigned char protocol ){ int hash, ret; hash = protocol & (MAX_INET_PROTOS - 1); spin_lock_bh( &myinet_proto_lock ); if( myinet_protos[hash] ){ ret = -1; }else{ myinet_protos[hash] = prot; ret = 0; } spin_unlock_bh( &myinet_proto_lock ); return ret;}int myinet_del_protocol(struct net_protocol *prot, unsigned char protocol){ int hash, ret; hash = protocol & (MAX_INET_PROTOS - 1); spin_lock_bh( &myinet_proto_lock ); if( myinet_protos[hash] == prot ){ myinet_protos[hash] = NULL; ret = 0; }else{ ret = -1; } spin_unlock_bh( &myinet_proto_lock ); synchronize_net(); return ret;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -