libnet_build_tcp.c | libnet_build_tcp.c | |||
---|---|---|---|---|
skipping to change at line 146 | skipping to change at line 146 | |||
/* if there is a payload, add it in the context */ | /* if there is a payload, add it in the context */ | |||
if (payload_s) | if (payload_s) | |||
{ | { | |||
/* update ptag_data with the new payload */ | /* update ptag_data with the new payload */ | |||
libnet_pblock_t* p_data = libnet_pblock_probe(l, ptag_data, payload _s, LIBNET_PBLOCK_TCPDATA); | libnet_pblock_t* p_data = libnet_pblock_probe(l, ptag_data, payload _s, LIBNET_PBLOCK_TCPDATA); | |||
if (!p_data) | if (!p_data) | |||
{ | { | |||
goto bad; | goto bad; | |||
} | } | |||
if (libnet_pblock_append(l, p_data, payload, payload_s) == -1) | n = libnet_pblock_append(l, p_data, payload, payload_s); | |||
if (n == -1) | ||||
{ | { | |||
goto bad; | goto bad; | |||
} | } | |||
if (ptag_data == LIBNET_PTAG_INITIALIZER) | if (ptag_data == LIBNET_PTAG_INITIALIZER) | |||
{ | { | |||
int insertbefore = p->ptag; | int insertbefore = p->ptag; | |||
/* Then we created it, and we need to shuffle it back until it' s before | /* Then we created it, and we need to shuffle it back until it' s before | |||
* the tcp header and options. */ | * the tcp header and options. */ | |||
skipping to change at line 191 | skipping to change at line 192 | |||
bad: | bad: | |||
libnet_pblock_delete(l, p); | libnet_pblock_delete(l, p); | |||
return (-1); | return (-1); | |||
} | } | |||
libnet_ptag_t | libnet_ptag_t | |||
libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet _t *l, | libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet _t *l, | |||
libnet_ptag_t ptag) | libnet_ptag_t ptag) | |||
{ | { | |||
static const uint8_t padding[] = { 0 }; | static const uint8_t padding[] = { 0 }; | |||
int offset, underflow; | int n, offset, underflow; | |||
uint32_t i, j, adj_size; | uint32_t i, j, adj_size; | |||
libnet_pblock_t *p, *p_temp; | libnet_pblock_t *p, *p_temp; | |||
struct libnet_ipv4_hdr *ip_hdr; | struct libnet_ipv4_hdr *ip_hdr; | |||
struct libnet_tcp_hdr *tcp_hdr; | struct libnet_tcp_hdr *tcp_hdr; | |||
if (l == NULL) | if (l == NULL) | |||
{ | { | |||
return (-1); | return (-1); | |||
} | } | |||
skipping to change at line 248 | skipping to change at line 249 | |||
/* | /* | |||
* Find the existing protocol block if a ptag is specified, or create | * Find the existing protocol block if a ptag is specified, or create | |||
* a new one. | * a new one. | |||
*/ | */ | |||
p = libnet_pblock_probe(l, ptag, adj_size, LIBNET_PBLOCK_TCPO_H); | p = libnet_pblock_probe(l, ptag, adj_size, LIBNET_PBLOCK_TCPO_H); | |||
if (p == NULL) | if (p == NULL) | |||
{ | { | |||
return (-1); | return (-1); | |||
} | } | |||
libnet_pblock_append(l, p, options, options_s); | n = libnet_pblock_append(l, p, options, options_s); | |||
libnet_pblock_append(l, p, padding, adj_size - options_s); | if (n == -1) | |||
{ | ||||
goto bad; | ||||
} | ||||
n = libnet_pblock_append(l, p, padding, adj_size - options_s); | ||||
if (n == -1) | ||||
{ | ||||
goto bad; | ||||
} | ||||
if (ptag && p->next) | if (ptag && p->next) | |||
{ | { | |||
p_temp = p->next; | p_temp = p->next; | |||
while ((p_temp->next) && (p_temp->type != LIBNET_PBLOCK_TCP_H)) | while ((p_temp->next) && (p_temp->type != LIBNET_PBLOCK_TCP_H)) | |||
{ | { | |||
p_temp = p_temp->next; | p_temp = p_temp->next; | |||
} | } | |||
if (p_temp->type == LIBNET_PBLOCK_TCP_H) | if (p_temp->type == LIBNET_PBLOCK_TCP_H) | |||
{ | { | |||
skipping to change at line 299 | skipping to change at line 309 | |||
} | } | |||
else | else | |||
{ | { | |||
ip_hdr->ip_len -= htons(offset); | ip_hdr->ip_len -= htons(offset); | |||
} | } | |||
} | } | |||
} | } | |||
return (ptag ? ptag : libnet_pblock_update(l, p, adj_size, | return (ptag ? ptag : libnet_pblock_update(l, p, adj_size, | |||
LIBNET_PBLOCK_TCPO_H)); | LIBNET_PBLOCK_TCPO_H)); | |||
bad: | ||||
libnet_pblock_delete(l, p); | ||||
return (-1); | ||||
} | } | |||
/* EOF */ | /* EOF */ | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 17 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |