version 1.1.1.1, 2012/02/21 22:14:23
|
version 1.1.1.3, 2023/09/27 11:11:38
|
Line 29
|
Line 29
|
* |
* |
*/ |
*/ |
|
|
#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_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t *src, u_int8_t dsap, | libnet_build_fddi(uint8_t fc, const uint8_t *dst, const uint8_t *src, uint8_t dsap, |
u_int8_t ssap, u_int8_t cf, u_int8_t *org, u_int16_t type, u_int8_t *payload, | uint8_t ssap, uint8_t cf, const uint8_t *org, uint16_t type, const uint8_t *payload, |
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag) | uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
u_int16_t protocol_type; | uint16_t protocol_type; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_fddi_hdr fddi_hdr; |
struct libnet_fddi_hdr fddi_hdr; |
|
|
Line 90 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
|
Line 83 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
|
protocol_type = htons(type); |
protocol_type = htons(type); |
memcpy(&fddi_hdr.fddi_type, &protocol_type, sizeof(int16_t)); /* Protocol Type */ |
memcpy(&fddi_hdr.fddi_type, &protocol_type, sizeof(int16_t)); /* Protocol Type */ |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&fddi_hdr, LIBNET_FDDI_H); | n = libnet_pblock_append(l, p, (uint8_t *)&fddi_hdr, LIBNET_FDDI_H); |
if (n == -1) |
if (n == -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, LIBNET_PBLOCK_FDDI_H)); |
return (ptag ? ptag : libnet_pblock_update(l, p, h, LIBNET_PBLOCK_FDDI_H)); |
bad: |
bad: |
Line 120 bad:
|
Line 100 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_autobuild_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t dsap, u_int8_t ssap, | libnet_autobuild_fddi(uint8_t fc, const uint8_t *dst, uint8_t dsap, uint8_t ssap, |
u_int8_t cf, u_int8_t *org, u_int16_t type, libnet_t *l) | uint8_t cf, const uint8_t *org, uint16_t type, libnet_t *l) |
{ |
{ |
u_int32_t n, h; | uint32_t n, h; |
u_int16_t protocol_type; | uint16_t protocol_type; |
struct libnet_fddi_addr *src; |
struct libnet_fddi_addr *src; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
libnet_ptag_t ptag; |
libnet_ptag_t ptag; |
Line 164 libnet_autobuild_fddi(u_int8_t fc, u_int8_t *dst, u_in
|
Line 144 libnet_autobuild_fddi(u_int8_t fc, u_int8_t *dst, u_in
|
return (-1); |
return (-1); |
} |
} |
|
|
memset(&fddi_hdr, 0, sizeof(fddi_hdr)); | memset(&fddi_hdr, 0, sizeof(fddi_hdr)); |
fddi_hdr.fddi_frame_control = fc; /* Class/Format/Priority */ | fddi_hdr.fddi_frame_control = fc; /* Class/Format/Priority */ |
memcpy(fddi_hdr.fddi_dhost, dst, FDDI_ADDR_LEN); /* destination fddi address */ | memcpy(fddi_hdr.fddi_dhost, dst, FDDI_ADDR_LEN); /* destination fddi addr */ |
memcpy(fddi_hdr.fddi_shost, src, FDDI_ADDR_LEN); /* source fddi address */ | memcpy(fddi_hdr.fddi_shost, src, FDDI_ADDR_LEN); /* source fddi addr */ |
fddi_hdr.fddi_llc_dsap = dsap; /* */ | fddi_hdr.fddi_llc_dsap = dsap; /* */ |
fddi_hdr.fddi_llc_ssap = ssap; /* */ | fddi_hdr.fddi_llc_ssap = ssap; /* */ |
fddi_hdr.fddi_llc_control_field = cf; /* Class/Format/Priority */ | fddi_hdr.fddi_llc_control_field = cf; /* Class/Format/Priority */ |
memcpy(&fddi_hdr.fddi_llc_org_code, org, LIBNET_ORG_CODE_SIZE); |
memcpy(&fddi_hdr.fddi_llc_org_code, org, LIBNET_ORG_CODE_SIZE); |
|
|
/* Deal with unaligned int16_t for type */ |
/* Deal with unaligned int16_t for type */ |
protocol_type = htons(type); |
protocol_type = htons(type); |
memcpy(&fddi_hdr.fddi_type, &protocol_type, sizeof(int16_t)); /* Protocol Type */ | memcpy(&fddi_hdr.fddi_type, &protocol_type, sizeof(int16_t)); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&fddi_hdr, LIBNET_FDDI_H); | n = libnet_pblock_append(l, p, (uint8_t *)&fddi_hdr, LIBNET_FDDI_H); |
if (n == -1) |
if (n == -1) |
{ |
{ |
goto bad; |
goto bad; |
Line 188 bad:
|
Line 168 bad:
|
libnet_pblock_delete(l, p); |
libnet_pblock_delete(l, p); |
return (-1); |
return (-1); |
} |
} |
/* EOF */ | |
| /** |
| * Local Variables: |
| * indent-tabs-mode: nil |
| * c-file-style: "stroustrup" |
| * End: |
| */ |