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_2(u_int8_t dsap, u_int8_t ssap, u_int8_t control, | libnet_build_802_2(uint8_t dsap, uint8_t ssap, uint8_t control, |
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_2_hdr _802_2_hdr; |
struct libnet_802_2_hdr _802_2_hdr; |
|
|
Line 70 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 70 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
_802_2_hdr.llc_ssap = ssap; |
_802_2_hdr.llc_ssap = ssap; |
_802_2_hdr.llc_control = control; |
_802_2_hdr.llc_control = control; |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&_802_2_hdr, LIBNET_802_2_H); | n = libnet_pblock_append(l, p, (uint8_t *)&_802_2_hdr, LIBNET_802_2_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; | |
} | |
} | |
|
|
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_802_2_H)); |
LIBNET_PBLOCK_802_2_H)); |
Line 99 bad:
|
Line 86 bad:
|
return (-1); |
return (-1); |
} |
} |
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_802_2snap(u_int8_t dsap, u_int8_t ssap, u_int8_t control, u_int8_t *oui, | libnet_build_802_2snap(uint8_t dsap, uint8_t ssap, uint8_t control, |
u_int16_t type, u_int8_t *payload, u_int32_t payload_s, libnet_t *l, | uint8_t *oui, uint16_t type, const uint8_t *payload, uint32_t payload_s, |
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_802_2snap_hdr _802_2_hdr; |
struct libnet_802_2snap_hdr _802_2_hdr; |
|
|
Line 127 libnet_build_802_2snap(u_int8_t dsap, u_int8_t ssap, u
|
Line 113 libnet_build_802_2snap(u_int8_t dsap, u_int8_t ssap, u
|
return (-1); |
return (-1); |
} |
} |
|
|
memset(&_802_2_hdr, 0, sizeof(_802_2_hdr)); | memset(&_802_2_hdr, 0, sizeof(_802_2_hdr)); |
_802_2_hdr.snap_dsap = dsap; | _802_2_hdr.snap_dsap = dsap; |
_802_2_hdr.snap_ssap = ssap; |
_802_2_hdr.snap_ssap = ssap; |
_802_2_hdr.snap_control = control; |
_802_2_hdr.snap_control = control; |
memcpy(_802_2_hdr.snap_oui, oui, 3); |
memcpy(_802_2_hdr.snap_oui, oui, 3); |
_802_2_hdr.snap_type = htons(type); |
_802_2_hdr.snap_type = htons(type); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&_802_2_hdr, LIBNET_802_2SNAP_H); | n = libnet_pblock_append(l, p, (uint8_t *)&_802_2_hdr, LIBNET_802_2SNAP_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
} |
} |
|
|
if ((payload && !payload_s) || (!payload && payload_s)) |
|
{ |
|
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
|
"%s(): payload inconsistency\n", __func__); |
|
goto bad; |
|
} |
|
|
|
if (payload && payload_s) | /* boilerplate payload sanity check / append macro */ |
{ | LIBNET_DO_PAYLOAD(l, p); |
n = libnet_pblock_append(l, p, payload, payload_s); | |
if (n == -1) | |
{ | |
goto bad; | |
} | |
} | |
| |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_802_2SNAP_H)); |
LIBNET_PBLOCK_802_2SNAP_H)); |
bad: |
bad: |