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_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 55 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 66 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 108 bad:
|
Line 94 bad:
|
libnet_pblock_delete(l, p); |
libnet_pblock_delete(l, p); |
return (-1); |
return (-1); |
} |
} |
|
|
|
|
/* EOF */ |
/* EOF */ |