Diff for /embedaddon/libnet/src/libnet_build_ip.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2013/07/22 11:54:42 version 1.1.1.3, 2023/09/27 11:11:38
Line 30 Line 30
  *   *
  */   */
   
#if (HAVE_CONFIG_H)#include "common.h"
#include "../include/config.h" 
#endif 
#if (!(_WIN32) || (__CYGWIN__))  
#include "../include/libnet.h" 
#else 
#include "../include/win32/libnet.h" 
#endif 
   
   
 /* TODO len - should be calculated if -1 */  /* TODO len - should be calculated if -1 */
 libnet_ptag_t  libnet_ptag_t
 libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,  libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag,
Line 134  const uint8_t *payload, uint32_t payload_s, libnet_t * Line 126  const uint8_t *payload, uint32_t payload_s, libnet_t *
         else          else
         {          {
              snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,               snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                     "%s(): IPv4 data pblock not found\n", __func__);                     "%s(): IPv4 data pblock not found", __func__);
         }          }
     }      }
   
     if (payload_s && !payload)      if (payload_s && !payload)
     {      {
          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,           snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                 "%s(): payload inconsistency\n", __func__);                 "%s(): payload inconsistency", __func__);
         goto bad;          goto bad;
     }      }
   
Line 343  libnet_ptag_t ptag) Line 335  libnet_ptag_t ptag)
     if (options_s > LIBNET_MAXOPTION_SIZE)      if (options_s > LIBNET_MAXOPTION_SIZE)
     {      {
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
            "%s(): options list is too large %d\n", __func__, options_s);            "%s(): options list is too large %d", __func__, options_s);
         return (-1);          return (-1);
     }      }
   
Line 433  const uint8_t *payload, uint32_t payload_s, libnet_t * Line 425  const uint8_t *payload, uint32_t payload_s, libnet_t *
     if (LIBNET_IPV6_H + payload_s > IP_MAXPACKET)      if (LIBNET_IPV6_H + payload_s > IP_MAXPACKET)
     {        {  
          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,           snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                 "%s(): IP packet too large\n", __func__);                 "%s(): IP packet too large", __func__);
         return (-1);          return (-1);
     }        }  
                 
Line 450  const uint8_t *payload, uint32_t payload_s, libnet_t * Line 442  const uint8_t *payload, uint32_t payload_s, libnet_t *
     memset(&ip_hdr, 0, sizeof(ip_hdr));      memset(&ip_hdr, 0, sizeof(ip_hdr));
     ip_hdr.ip_flags[0] = (0x06 << 4) | ((tc & 0xF0) >> 4);      ip_hdr.ip_flags[0] = (0x06 << 4) | ((tc & 0xF0) >> 4);
     ip_hdr.ip_flags[1] = ((tc & 0x0F) << 4) | ((fl & 0xF0000) >> 16);      ip_hdr.ip_flags[1] = ((tc & 0x0F) << 4) | ((fl & 0xF0000) >> 16);
    ip_hdr.ip_flags[2] = fl & 0x0FF00 >> 8;    ip_hdr.ip_flags[2] = (fl & 0x0FF00) >> 8;
     ip_hdr.ip_flags[3] = fl & 0x000FF;      ip_hdr.ip_flags[3] = fl & 0x000FF;
     ip_hdr.ip_len      = htons(len);      ip_hdr.ip_len      = htons(len);
     ip_hdr.ip_nh       = nh;      ip_hdr.ip_nh       = nh;
Line 499  libnet_ptag_t ptag) Line 491  libnet_ptag_t ptag)
     if (LIBNET_IPV6_FRAG_H + payload_s > IP_MAXPACKET)      if (LIBNET_IPV6_FRAG_H + payload_s > IP_MAXPACKET)
     {      {
          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,           snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                 "%s(): IP packet too large\n", __func__);                 "%s(): IP packet too large", __func__);
         return (-1);          return (-1);
     }      }
   
Line 568  libnet_ptag_t ptag) Line 560  libnet_ptag_t ptag)
     if (LIBNET_IPV6_ROUTING_H + payload_s > IP_MAXPACKET)      if (LIBNET_IPV6_ROUTING_H + payload_s > IP_MAXPACKET)
     {      {
          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,           snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                 "%s(): IP packet too large\n", __func__);                 "%s(): IP packet too large", __func__);
         return (-1);          return (-1);
     }      }
   
Line 636  uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) Line 628  uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
     if (LIBNET_IPV6_DESTOPTS_H + payload_s > IP_MAXPACKET)      if (LIBNET_IPV6_DESTOPTS_H + payload_s > IP_MAXPACKET)
     {      {
          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,           snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                 "%s(): IP packet too large\n", __func__);                 "%s(): IP packet too large", __func__);
         return (-1);          return (-1);
     }      }
   
Line 702  uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) Line 694  uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
     if (LIBNET_IPV6_HBHOPTS_H + payload_s > IP_MAXPACKET)      if (LIBNET_IPV6_HBHOPTS_H + payload_s > IP_MAXPACKET)
     {      {
          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,           snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                 "%s(): IP packet too large\n", __func__);                 "%s(): IP packet too large", __func__);
         return (-1);          return (-1);
     }      }
   
Line 761  libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct Line 753  libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct
     return libnet_build_ipv6(0, 0, len, nh, 64, src, dst, NULL, 0, l, ptag);      return libnet_build_ipv6(0, 0, len, nh, 64, src, dst, NULL, 0, l, ptag);
 }  }
   
   /**
    * Local Variables:
    *  indent-tabs-mode: nil
    *  c-file-style: "stroustrup"
    * End:
    */

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>