PF_PACKET AF_INET raw socket 区别

http://blog.chinaunix.net/uid-305141-id-2133755.html

socket PF_PACKET sock_raw:->packet_create->dev_add_pack Modify ptype_base|ptype_all:二层协议
接收过程:netif_rx->process_backlog->netif_receive_skb:ptype_base|ptype_all
    

socket AF_INET  sock_raw:->inet_create (list_for_each_entry_rcu(answer, &inetsw[sock->type], list) find SOCK_RAW )->hash(raw_hash_sk) Modify raw_v4_hashinfo:IP上层协议    
接收过程: ip_rcv->ip_rcv_finish->ip_route_input->ip_local_deliver->ip_local_deliver_finish
->raw_local_deliver:raw_v4_hashinfo
    
    inet_init->inet_register_protosw:注册inetsw_array
    
    inetsw_array[]包含
  {
           .type =       SOCK_RAW,
           .protocol =   IPPROTO_IP,    /* wild card */
           .prot =       &raw_prot,
           .ops =        &inet_sockraw_ops,
           .no_check =   UDP_CSUM_DEFAULT,
           .flags =      INET_PROTOSW_REUSE,
   }
   AF_INET RAW socket 接口 一直存在
        



你可能感兴趣的:(linux,socket编程)