version 1.1.1.1, 2012/02/21 22:14:23
|
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 | |
|
|
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 63 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 79 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 106 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: |
Line 163 bad:
|
Line 129 bad:
|
return (-1); |
return (-1); |
} |
} |
|
|
| /** |
/* EOF */ | * Local Variables: |
| * indent-tabs-mode: nil |
| * c-file-style: "stroustrup" |
| * End: |
| */ |