__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
http://yaoyang.blog.51cto.com/7657153/1269713
http://blog.csdn.net/eric_liufeng/article/details/10475583
네트워크 드라이브 가 메 시 지 를 받 으 면 skb - > protocol 필드 를 초기 화하 고 netif 를 통 해rx(skb);3 층 프로 토 콜 에 전송 되 며, 3 층 프로 토 콜 은 skb - > protocol 필드 에 따라 어떤 프로 토 콜 을 사용 할 지 결정 합 니 다.
어떤 mac 프로 토 콜 형식의 모든 네트워크 장 치 는 같은 xx 를 사용 합 니 다.type_trans () 함수 로 protocol 을 가 져 오 는: 이 더 넷 장치 구동 호출 ethtype_trans (), FDDI 네트워크 장치 구동 호출 fdditype_trans().
/**
* eth_type_trans - determine the packet's protocol ID.
* @skb: received socket data
* @dev: receiving network device
*
* The rule here is that we
* assume 802.3 if the type field is short enough to be a length.
* This is normal practice and works for any 'now in use' protocol.
*/
__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
{
unsigned short _service_access_point;
const unsigned short *sap;
const struct ethhdr *eth;
skb->dev = dev;
skb_reset_mac_header(skb);
//
skb_pull_inline(skb, ETH_HLEN);
eth = eth_hdr(skb);
/*
* skb->pkt_type
* PACKET_BROADCAST:
* PACKET_MULTICAST:2
* PACKET_HOST:
* PACKET_OTHERHOST: ,
*/
if (unlikely(is_multicast_ether_addr(eth->h_dest))) {
if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast))
skb->pkt_type = PACKET_BROADCAST;
else
skb->pkt_type = PACKET_MULTICAST;
}
else if (unlikely(!ether_addr_equal_64bits(eth->h_dest,
dev->dev_addr)))
skb->pkt_type = PACKET_OTHERHOST;
/*
* Some variants of DSA tagging don't have an ethertype field
* at all, so we check here whether one of those tagging
* variants has been configured on the receiving interface,
* and if so, set skb->protocol without looking at the packet.
*/
if (unlikely(netdev_uses_dsa(dev)))
return htons(ETH_P_XDSA);
/* 1536( ETH_P_802_3_MIN), 802.3 , eth->h_proto */
if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN))
return eth->h_proto;
/*
* This is a magic hack to spot IPX packets. Older Novell breaks
* the protocol design and runs IPX over 802.3 without an 802.2 LLC
* layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
* won't work for fault tolerant netware but does for the rest.
*/
sap = skb_header_pointer(skb, 0, sizeof(*sap), &_service_access_point);
if (sap && *sap == 0xFFFF)
return htons(ETH_P_802_3);
/*
* Real 802.2 LLC
* 802.2 , ,
* ptype_base , p8022_rcv()
* register_8022_client() p8022_rcv()
* register_8022_client(0xAA, snap_rcv) SNAP
*/
return htons(ETH_P_802_2);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
axios 요청 차단, 응답 차단,router 내비게이션 수위axios 요청 차단: 요청 헤더에 token 등을 통일적으로 추가할 수 있습니다 axios 응답 차단: 로그인 판단 내비게이션 선행 수위beforeEach: 로그인 여부를 판단할 수 있지만, 응답으로 차단하는 것이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.