version 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_isl(u_int8_t *dhost, u_int8_t type, u_int8_t user, u_int8_t *shost, | libnet_build_isl(uint8_t *dhost, uint8_t type, uint8_t user, |
u_int16_t len, u_int8_t *snap, u_int16_t vid, u_int16_t index, | uint8_t *shost, uint16_t len, const uint8_t *snap, uint16_t vid, |
u_int16_t reserved, u_int8_t *payload, u_int32_t payload_s, | uint16_t portindex, uint16_t reserved, const uint8_t *payload, |
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; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_isl_hdr isl_hdr; |
struct libnet_isl_hdr isl_hdr; |
|
|
Line 55 libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int
|
Line 48 libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int
|
} |
} |
|
|
n = LIBNET_ISL_H + payload_s; /* size of memory block */ |
n = LIBNET_ISL_H + payload_s; /* size of memory block */ |
h = 0; |
|
|
|
/* |
/* |
* 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 67 libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int
|
Line 59 libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int
|
return (-1); |
return (-1); |
} |
} |
|
|
memset(&isl_hdr, 0, sizeof(isl_hdr)); | memset(&isl_hdr, 0, sizeof (isl_hdr)); |
memcpy(&isl_hdr.isl_dhost, dhost, 5); | memcpy(&isl_hdr.isl_dhost, dhost, sizeof(isl_hdr.isl_dhost)); |
isl_hdr.isl_type = type; |
isl_hdr.isl_type = type; |
isl_hdr.isl_user = user; |
isl_hdr.isl_user = user; |
memcpy(&isl_hdr.isl_shost, shost, 6); | memcpy(&isl_hdr.isl_shost, shost, sizeof(isl_hdr.isl_shost)); |
isl_hdr.isl_len = htons(len); |
isl_hdr.isl_len = htons(len); |
memcpy(&isl_hdr.isl_dhost, snap, 6); | memcpy(&isl_hdr.isl_snap, snap, sizeof(isl_hdr.isl_snap)); |
isl_hdr.isl_vid = htons(vid); |
isl_hdr.isl_vid = htons(vid); |
isl_hdr.isl_index = htons(index); | isl_hdr.isl_index = htons(portindex); |
isl_hdr.isl_reserved= htons(reserved); |
isl_hdr.isl_reserved= htons(reserved); |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&isl_hdr, LIBNET_ISL_H); | n = libnet_pblock_append(l, p, (uint8_t *)&isl_hdr, LIBNET_ISL_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; |
|
} |
|
} |
|
|
|
/* we need to compute the CRC for the ethernet frame and the ISL frame */ |
/* we need to compute the CRC for the ethernet frame and the ISL frame */ |
libnet_pblock_setflags(p, LIBNET_PBLOCK_DO_CHECKSUM); |
libnet_pblock_setflags(p, LIBNET_PBLOCK_DO_CHECKSUM); |
return (ptag ? ptag : libnet_pblock_update(l, p, LIBNET_ISL_H, |
return (ptag ? ptag : libnet_pblock_update(l, p, LIBNET_ISL_H, |
Line 109 bad:
|
Line 88 bad:
|
return (-1); |
return (-1); |
} |
} |
|
|
| /** |
/* EOF */ | * Local Variables: |
| * indent-tabs-mode: nil |
| * c-file-style: "stroustrup" |
| * End: |
| */ |