Diff for /embedaddon/libnet/src/libnet_build_cdp.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 22:14:23 version 1.1.1.2, 2013/07/22 11:54:42
Line 40 Line 40
 #endif  #endif
   
 libnet_ptag_t  libnet_ptag_t
libnet_build_cdp(u_int8_t version, u_int8_t ttl, u_int16_t sum, u_int16_t type,libnet_build_cdp(uint8_t version, uint8_t ttl, uint16_t sum, uint16_t type,
u_int16_t len, u_int8_t *value, u_int8_t *payload, u_int32_t payload_s,uint16_t len, const uint8_t *value, const uint8_t *payload, uint32_t payload_s,
 libnet_t *l, libnet_ptag_t ptag)  libnet_t *l, libnet_ptag_t ptag)
 {  {
    u_int32_t n,h;    uint32_t n,h;
     libnet_pblock_t *p;      libnet_pblock_t *p;
     struct libnet_cdp_hdr cdp_hdr;      struct libnet_cdp_hdr cdp_hdr;
   
Line 53  libnet_t *l, libnet_ptag_t ptag) Line 53  libnet_t *l, libnet_ptag_t ptag)
         return (-1);           return (-1); 
     }      }
   
    n = LIBNET_CDP_H + len + payload_s;    n = LIBNET_CDP_H + LIBNET_CDP_H + len + payload_s;
    h = LIBNET_CDP_H + len + payload_s;    h = LIBNET_CDP_H + LIBNET_CDP_H + len + payload_s;
   
     /*      /*
      *  Find the existing protocol block if a ptag is specified, or create       *  Find the existing protocol block if a ptag is specified, or create
Line 73  libnet_t *l, libnet_ptag_t ptag) Line 73  libnet_t *l, libnet_ptag_t ptag)
     cdp_hdr.cdp_type    = htons(type);      cdp_hdr.cdp_type    = htons(type);
     cdp_hdr.cdp_len     = htons(len + 4);   /* 4 bytes for len and type */      cdp_hdr.cdp_len     = htons(len + 4);   /* 4 bytes for len and type */
   
    n = libnet_pblock_append(l, p, (u_int8_t *)&cdp_hdr, LIBNET_CDP_H);    n = libnet_pblock_append(l, p, (uint8_t *)&cdp_hdr, LIBNET_CDP_H);
     if (n == -1)      if (n == -1)
     {      {
         goto bad;          goto bad;
Line 86  libnet_t *l, libnet_ptag_t ptag) Line 86  libnet_t *l, libnet_ptag_t ptag)
         goto bad;          goto bad;
     }      }
   
    if ((payload && !payload_s) || (!payload && payload_s))    /* boilerplate payload sanity check / append macro */
    {    LIBNET_DO_PAYLOAD(l, p);
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, 
                 "%s(): payload inconsistency\n", __func__); 
        goto bad; 
    } 
   
     if (payload && payload_s)  
     {  
         n = libnet_pblock_append(l, p, payload, payload_s);  
         if (n == -1)  
         {  
             goto bad;  
         }  
     }  
   
     if (sum == 0)      if (sum == 0)
     {      {
         /*          /*
Line 120  bad: Line 107  bad:
   
 int  int
 /* Not Yet Implemented */  /* Not Yet Implemented */
libnet_build_cdp_value(u_int16_t type, u_int16_t len, u_int8_t *value, libnet_t *l,libnet_build_cdp_value(uint16_t type, uint16_t len, uint8_t *value, libnet_t *l,
         libnet_ptag_t ptag)          libnet_ptag_t ptag)
 {  {
    u_int32_t n;    uint32_t n;
     libnet_pblock_t *p;      libnet_pblock_t *p;
     struct libnet_cdp_value_hdr cdp_value_hdr;      struct libnet_cdp_value_hdr cdp_value_hdr;
   
Line 148  libnet_build_cdp_value(u_int16_t type, u_int16_t len,  Line 135  libnet_build_cdp_value(u_int16_t type, u_int16_t len, 
         return (-1);          return (-1);
     }      }
   
        memset(&cdp_value_hdr, 0, sizeof(cdp_value_hdr));    memset(&cdp_value_hdr, 0, sizeof(cdp_value_hdr));
        cdp_value_hdr.cdp_type  = htons(type);    cdp_value_hdr.cdp_type  = htons(type);
    cdp_value_hdr.cdp_len   = htons(len + 4);   /* 4 bytes for len and type */    cdp_value_hdr.cdp_len   = htons(len + LIBNET_CDP_VALUE_H);   /* 4 bytes for len and type */
   
     switch (type)      switch (type)
     {      {
Line 172  libnet_build_cdp_value(u_int16_t type, u_int16_t len,  Line 159  libnet_build_cdp_value(u_int16_t type, u_int16_t len, 
             break;              break;
     }      }
   
    n = libnet_pblock_append(l, p, (u_int8_t *)&cdp_value_hdr, LIBNET_CDP_H);    n = libnet_pblock_append(l, p, (uint8_t *)&cdp_value_hdr, LIBNET_CDP_VALUE_H);
     if (n == -1)      if (n == -1)
     {      {
         return (-1);          return (-1);

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


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