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 | |
|
|
int |
int |
libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet, u_int32_t *packet_s) | libnet_adv_cull_packet(libnet_t *l, uint8_t **packet, uint32_t *packet_s) |
{ |
{ |
*packet = NULL; |
*packet = NULL; |
*packet_s = 0; |
*packet_s = 0; |
Line 48 libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet,
|
Line 41 libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet,
|
if (l->injection_type != LIBNET_LINK_ADV) |
if (l->injection_type != LIBNET_LINK_ADV) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"%s(): advanced link mode not enabled\n", __func__); | "%s(): advanced link mode not enabled", __func__); |
return (-1); |
return (-1); |
} |
} |
|
|
Line 57 libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet,
|
Line 50 libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet,
|
} |
} |
|
|
int |
int |
libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, u_int8_t **header, | libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, uint8_t **header, |
u_int32_t *header_s) | uint32_t *header_s) |
{ |
{ |
libnet_pblock_t *p; |
libnet_pblock_t *p; |
|
|
Line 68 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag
|
Line 61 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag
|
if (l->injection_type != LIBNET_LINK_ADV) |
if (l->injection_type != LIBNET_LINK_ADV) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"%s(): advanced link mode not enabled\n", __func__); | "%s(): advanced link mode not enabled", __func__); |
return (-1); |
return (-1); |
} |
} |
|
|
Line 76 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag
|
Line 69 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag
|
if (p == NULL) |
if (p == NULL) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"%s(): ptag not found, you sure it exists?\n", __func__); | "%s(): ptag not found, you sure it exists?", __func__); |
return (-1); |
return (-1); |
} |
} |
*header = p->buf; |
*header = p->buf; |
Line 86 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag
|
Line 79 libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag
|
} |
} |
|
|
int |
int |
libnet_adv_write_link(libnet_t *l, u_int8_t *packet, u_int32_t packet_s) | libnet_adv_write_link(libnet_t *l, const uint8_t *packet, uint32_t packet_s) |
{ |
{ |
int c; |
int c; |
|
|
if (l->injection_type != LIBNET_LINK_ADV) |
if (l->injection_type != LIBNET_LINK_ADV) |
{ |
{ |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
"%s(): advanced link mode not enabled\n", __func__); | "%s(): advanced link mode not enabled", __func__); |
return (-1); |
return (-1); |
} |
} |
c = libnet_write_link(l, packet, packet_s); |
c = libnet_write_link(l, packet, packet_s); |
Line 119 libnet_adv_write_link(libnet_t *l, u_int8_t *packet, u
|
Line 112 libnet_adv_write_link(libnet_t *l, u_int8_t *packet, u
|
return (c); |
return (c); |
} |
} |
|
|
|
int |
|
libnet_adv_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t packet_s) |
|
{ |
|
int c; |
|
|
|
if (l->injection_type != LIBNET_RAW4_ADV) |
|
{ |
|
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, |
|
"%s(): advanced raw4 mode not enabled", __func__); |
|
return (-1); |
|
} |
|
c = libnet_write_raw_ipv4(l, packet, packet_s); |
|
|
|
/* do statistics */ |
|
if (c == packet_s) |
|
{ |
|
l->stats.packets_sent++; |
|
l->stats.bytes_written += c; |
|
} |
|
else |
|
{ |
|
l->stats.packet_errors++; |
|
/* |
|
* XXX - we probably should have a way to retrieve the number of |
|
* bytes actually written (since we might have written something). |
|
*/ |
|
if (c > 0) |
|
{ |
|
l->stats.bytes_written += c; |
|
} |
|
} |
|
return (c); |
|
} |
|
|
void |
void |
libnet_adv_free_packet(libnet_t *l, u_int8_t *packet) | libnet_adv_free_packet(libnet_t *l, uint8_t *packet) |
{ |
{ |
/* |
/* |
* Restore original pointer address so free won't complain about a |
* Restore original pointer address so free won't complain about a |
Line 133 libnet_adv_free_packet(libnet_t *l, u_int8_t *packet)
|
Line 160 libnet_adv_free_packet(libnet_t *l, u_int8_t *packet)
|
free(packet); |
free(packet); |
} |
} |
|
|
/* EOF */ | /** |
| * Local Variables: |
| * indent-tabs-mode: nil |
| * c-file-style: "stroustrup" |
| * End: |
| */ |