Diff for /embedaddon/libnet/src/libnet_build_802.1q.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_802_1q(u_int8_t *dst, u_int8_t *src, u_int16_t tpi, libnet_build_802_1q(const uint8_t *dst, const uint8_t *src, uint16_t tpi, 
u_int8_t priority, u_int8_t cfi, u_int16_t vlan_id, u_int16_t len_proto,uint8_t priority, uint8_t cfi, uint16_t vlan_id, uint16_t len_proto,
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)const uint8_t* payload, uint32_t payload_s, 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_802_1q_hdr _802_1q_hdr;      struct libnet_802_1q_hdr _802_1q_hdr;
   
Line 66  u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l Line 66  u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
         return (-1);          return (-1);
     }      }
                   
        memset(&_802_1q_hdr, 0, sizeof(_802_1q_hdr));    memset(&_802_1q_hdr, 0, sizeof(_802_1q_hdr));
        memcpy(_802_1q_hdr.vlan_dhost, dst, ETHER_ADDR_LEN);    memcpy(_802_1q_hdr.vlan_dhost, dst, ETHER_ADDR_LEN);
     memcpy(_802_1q_hdr.vlan_shost, src, ETHER_ADDR_LEN);      memcpy(_802_1q_hdr.vlan_shost, src, ETHER_ADDR_LEN);
     _802_1q_hdr.vlan_tpi = htons(tpi);      _802_1q_hdr.vlan_tpi = htons(tpi);
     _802_1q_hdr.vlan_priority_c_vid = htons((priority << 13) | (cfi << 12)      _802_1q_hdr.vlan_priority_c_vid = htons((priority << 13) | (cfi << 12)
             | (vlan_id & LIBNET_802_1Q_VIDMASK));              | (vlan_id & LIBNET_802_1Q_VIDMASK));
     _802_1q_hdr.vlan_len = htons(len_proto);      _802_1q_hdr.vlan_len = htons(len_proto);
   
    n = libnet_pblock_append(l, p, (u_int8_t *)&_802_1q_hdr, LIBNET_802_1Q_H);    n = libnet_pblock_append(l, p, (uint8_t *)&_802_1q_hdr, LIBNET_802_1Q_H);
    if (n == -1)    if (n == (uint32_t)-1)
     {      {
         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; 
        } 
    } 
     
     /*      /*
      *  The link offset is actually 4 bytes further into the header than       *  The link offset is actually 4 bytes further into the header than

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


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