version 1.1.1.1, 2012/02/21 22:14:23
|
version 1.1.1.2, 2013/07/22 11:54:42
|
Line 42
|
Line 42
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ipsec_esp_hdr(u_int32_t spi, u_int32_t seq, u_int32_t iv, | libnet_build_ipsec_esp_hdr(uint32_t spi, uint32_t seq, uint32_t iv, |
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_esp_hdr esp_hdr; |
struct libnet_esp_hdr esp_hdr; |
|
|
Line 72 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
Line 72 u_int8_t *payload, u_int32_t payload_s, libnet_t *l, l
|
return (-1); |
return (-1); |
} |
} |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&esp_hdr, LIBNET_IPSEC_ESP_HDR_H); | n = libnet_pblock_append(l, p, (uint8_t *)&esp_hdr, LIBNET_IPSEC_ESP_HDR_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, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_IPSEC_ESP_HDR_H)); |
LIBNET_PBLOCK_IPSEC_ESP_HDR_H)); |
bad: |
bad: |
Line 103 bad:
|
Line 90 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ipsec_esp_ftr(u_int8_t len, u_int8_t nh, int8_t *auth, | libnet_build_ipsec_esp_ftr(uint8_t len, uint8_t nh, int8_t *auth, |
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, | const uint8_t *payload, uint32_t payload_s, libnet_t *l, |
libnet_ptag_t ptag) |
libnet_ptag_t ptag) |
{ |
{ |
/* XXX we need to know the size of auth */ |
/* XXX we need to know the size of auth */ |
u_int32_t n, h; | uint32_t n, h; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_esp_ftr esp_ftr; |
struct libnet_esp_ftr esp_ftr; |
|
|
Line 135 libnet_build_ipsec_esp_ftr(u_int8_t len, u_int8_t nh,
|
Line 122 libnet_build_ipsec_esp_ftr(u_int8_t len, u_int8_t nh,
|
return (-1); |
return (-1); |
} |
} |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&esp_ftr, LIBNET_IPSEC_ESP_FTR_H); | n = libnet_pblock_append(l, p, (uint8_t *)&esp_ftr, LIBNET_IPSEC_ESP_FTR_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, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_IPSEC_ESP_FTR_H)); |
LIBNET_PBLOCK_IPSEC_ESP_FTR_H)); |
bad: |
bad: |
Line 166 bad:
|
Line 140 bad:
|
|
|
|
|
libnet_ptag_t |
libnet_ptag_t |
libnet_build_ipsec_ah(u_int8_t nh, u_int8_t len, u_int16_t res, | libnet_build_ipsec_ah(uint8_t nh, uint8_t len, uint16_t res, |
u_int32_t spi, u_int32_t seq, u_int32_t auth, u_int8_t *payload, | uint32_t spi, uint32_t seq, uint32_t auth, 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; |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
struct libnet_ah_hdr ah_hdr; |
struct libnet_ah_hdr ah_hdr; |
|
|
Line 200 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
|
Line 174 u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
|
ah_hdr.ah_seq = htonl(seq); /* AH sequence number */ |
ah_hdr.ah_seq = htonl(seq); /* AH sequence number */ |
ah_hdr.ah_auth = htonl(auth); /* authentication data */ |
ah_hdr.ah_auth = htonl(auth); /* authentication data */ |
|
|
n = libnet_pblock_append(l, p, (u_int8_t *)&ah_hdr, LIBNET_IPSEC_AH_H); | n = libnet_pblock_append(l, p, (uint8_t *)&ah_hdr, LIBNET_IPSEC_AH_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, |
return (ptag ? ptag : libnet_pblock_update(l, p, h, |
LIBNET_PBLOCK_IPSEC_AH_H)); |
LIBNET_PBLOCK_IPSEC_AH_H)); |