标签:for multicast reject turn direct 用户态 oop index .net
这个问题其实是我几个月前碰到,只是那时好像还在回忆着什么,心系上海,还没有完全适应这个新环境,加上这个问题也不是什么太深奥的问题,觉得太简单了,就搁置了。今天周末闲来无事就顺便写来来了。加上深圳经常下雨,越来越喜欢了。
本文没什么深度,仅为记录,以及阐述一个“看文档学习原理->猜测并自行实现->对比标准实现确认”的方法。
static int packet_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
{
struct sock *sk;
struct sockaddr_ll *sll = (struct sockaddr_ll*)skb->cb;
/*
* When we registered the protocol we saved the socket in the data
* field for just this event.
*/
sk = (struct sock *) pt->data;
// 注意,PACKET_LOOPBACK只是和multicast相关的,与我们讨论的无关
if (skb->pkt_type == PACKET_LOOPBACK) {
kfree_skb(skb);
return 0;
}
skb->dev = dev;
sll->sll_family = AF_PACKET;
sll->sll_hatype = dev->type;
sll->sll_protocol = skb->protocol;
sll->sll_pkttype = skb->pkt_type;
sll->sll_ifindex = dev->ifindex;
sll->sll_halen = 0;
...
}
void dev_queue_xmit_nit(struct sk_buff *skb, struct device *dev)
{
...
skb2->pkt_type = PACKET_OUTGOING;
ptype->func(skb2, skb->dev, ptype);
...
}
if (sll->sll_pkttype == PACKET_OUTGOING) {
/*
* Outgoing packet.
* If this is from the loopback device, reject it;
* we‘ll see the packet as an incoming packet as well,
* and we don‘t want to see it twice.
*/
if (sll->sll_ifindex == handle->md.lo_ifindex)
goto skip;
/*
* If the user only wants incoming packets, reject it.
*/
if (handle->direction == PCAP_D_IN)
goto skip;
}
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
标签:for multicast reject turn direct 用户态 oop index .net
原文地址:https://www.cnblogs.com/ksiwnhiwhs/p/10390201.html