ip_input.c
来自「一个基于linux的TCP/IP协议栈的实现」· C语言 代码 · 共 63 行
C
63 行
/* ip_input.c * linqianghe@163.com * 2006-09-19 */#include "myip.h"#include "log.h"#include "dummy_ipv4.h"#include "protocol.h"struct net_protocol *myinet_protos[MAX_INET_PROTOS];static inline int myip_local_deliver_finish(struct sk_buff *skb){ int protocol = IPPROTO_DUMMY; int hash = protocol & (MAX_INET_PROTOS - 1); struct net_protocol *ipprot; PR_DEBUG( "myip_local_deliver_finish!\n" ); rcu_read_lock(); if( (ipprot = rcu_dereference(myinet_protos[hash])) != NULL ){ ipprot->handler( skb ); }else{ dev_put( skb->dev ); kfree(skb ); } rcu_read_unlock(); return 0;}int myip_local_deliver(struct sk_buff *skb){ PR_DEBUG( "myip_local_deliver!\n" ); return myip_local_deliver_finish( skb );}static inline int mydst_input(struct sk_buff *skb){ PR_DEBUG( "mydst_input!\n" ); return myip_local_deliver( skb );}static inline int myip_rcv_finish(struct sk_buff *skb){ PR_DEBUG( "myip_rcv_finish!\n"); return mydst_input( skb ); }int myip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev){ PR_DEBUG( "myip_rcv!\n" ); dev_put( dev ); skb->dst = NULL; return myip_rcv_finish( skb );}EXPORT_SYMBOL_GPL( myip_rcv );EXPORT_SYMBOL_GPL( myinet_protos );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?