对五元组的处理

一、数据包的内容

  1. struct ether_header
    1. struct ether_header
      {
          u_int8_t ether_dhost[ETH_ALEN];      // destination eth addr 
          u_int8_t ether_shost[ETH_ALEN];      // source ether addr    
          u_int16_t ether_type;                 // packet type ID field 
      };

  2. struct ip
    1. struct ip {
      #if BYTE_ORDER == LITTLE_ENDIAN 
          u_char  ip_hl:4,        /* header length */
              ip_v:4;         /* version */
      #endif
      #if BYTE_ORDER == BIG_ENDIAN 
          u_char  ip_v:4,         /* version */
              ip_hl:4;        /* header length */
      #endif
          u_char  ip_tos;         /* type of service */
          short   ip_len;         /* total length */
          u_short ip_id;          /* identification */
          short   ip_off;         /* fragment offset field */
      #define IP_DF 0x4000            /* dont fragment flag */
      #define IP_MF 0x2000            /* more fragments flag */
          u_char  ip_ttl;         /* time to live */
          u_char  ip_p;           /* protocol */
          u_short ip_sum;         /* checksum */
          struct  in_addr ip_src,ip_dst;  /* source and dest address */
      };

  3. struct udphdr / struct udphdr
    1. struct tcphdr {
          __be16 source;
          __be16 dest;
          __be32 seq;
          __be32 ack_seq;
      #if defined(__LITTLE_ENDIAN_BITFIELD)
          __u16   res1:4,
                  doff:4,
                  fin:1,
                  syn:1,
                  rst:1,
                  psh:1,
                  ack:1,
                  urg:1,
                  ece:1,
                  cwr:1;
      #elif defined(__BIG_ENDIAN_BITFIELD)
          __u16   doff:4,
                  res1:4,
                  cwr:1,
                  ece:1,
                  urg:1,
                  ack:1,
                  psh:1,
                  rst:1,
                  syn:1,
                  fin:1;
      #else
      #error "Adjust your <asm/byteorder.h> defines"
      #endif
          __be16 window;
          __be16 check;
          __be16 urg_ptr;
      };
    2.  struct udphdr {
              __u16   source;
              __u16   dest;
              __u16   len;
              __u16   check;
       };

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值