--- embedaddon/libnet/src/libnet_build_ip.c 2013/07/22 11:54:42 1.1.1.2 +++ embedaddon/libnet/src/libnet_build_ip.c 2023/09/27 11:11:38 1.1.1.3 @@ -1,5 +1,5 @@ /* - * $Id: libnet_build_ip.c,v 1.1.1.2 2013/07/22 11:54:42 misho Exp $ + * $Id: libnet_build_ip.c,v 1.1.1.3 2023/09/27 11:11:38 misho Exp $ * * libnet * libnet_build_ip.c - IP packet assembler @@ -30,16 +30,8 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif -#if (!(_WIN32) || (__CYGWIN__)) -#include "../include/libnet.h" -#else -#include "../include/win32/libnet.h" -#endif +#include "common.h" - /* TODO len - should be calculated if -1 */ libnet_ptag_t libnet_build_ipv4(uint16_t ip_len, uint8_t tos, uint16_t id, uint16_t frag, @@ -134,14 +126,14 @@ const uint8_t *payload, uint32_t payload_s, libnet_t * else { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): IPv4 data pblock not found\n", __func__); + "%s(): IPv4 data pblock not found", __func__); } } if (payload_s && !payload) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): payload inconsistency\n", __func__); + "%s(): payload inconsistency", __func__); goto bad; } @@ -343,7 +335,7 @@ libnet_ptag_t ptag) if (options_s > LIBNET_MAXOPTION_SIZE) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): options list is too large %d\n", __func__, options_s); + "%s(): options list is too large %d", __func__, options_s); return (-1); } @@ -433,7 +425,7 @@ const uint8_t *payload, uint32_t payload_s, libnet_t * if (LIBNET_IPV6_H + payload_s > IP_MAXPACKET) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): IP packet too large\n", __func__); + "%s(): IP packet too large", __func__); return (-1); } @@ -450,7 +442,7 @@ const uint8_t *payload, uint32_t payload_s, libnet_t * memset(&ip_hdr, 0, sizeof(ip_hdr)); ip_hdr.ip_flags[0] = (0x06 << 4) | ((tc & 0xF0) >> 4); ip_hdr.ip_flags[1] = ((tc & 0x0F) << 4) | ((fl & 0xF0000) >> 16); - ip_hdr.ip_flags[2] = fl & 0x0FF00 >> 8; + ip_hdr.ip_flags[2] = (fl & 0x0FF00) >> 8; ip_hdr.ip_flags[3] = fl & 0x000FF; ip_hdr.ip_len = htons(len); ip_hdr.ip_nh = nh; @@ -499,7 +491,7 @@ libnet_ptag_t ptag) if (LIBNET_IPV6_FRAG_H + payload_s > IP_MAXPACKET) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): IP packet too large\n", __func__); + "%s(): IP packet too large", __func__); return (-1); } @@ -568,7 +560,7 @@ libnet_ptag_t ptag) if (LIBNET_IPV6_ROUTING_H + payload_s > IP_MAXPACKET) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): IP packet too large\n", __func__); + "%s(): IP packet too large", __func__); return (-1); } @@ -636,7 +628,7 @@ uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) if (LIBNET_IPV6_DESTOPTS_H + payload_s > IP_MAXPACKET) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): IP packet too large\n", __func__); + "%s(): IP packet too large", __func__); return (-1); } @@ -702,7 +694,7 @@ uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag) if (LIBNET_IPV6_HBHOPTS_H + payload_s > IP_MAXPACKET) { snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, - "%s(): IP packet too large\n", __func__); + "%s(): IP packet too large", __func__); return (-1); } @@ -761,3 +753,9 @@ libnet_autobuild_ipv6(uint16_t len, uint8_t nh, struct return libnet_build_ipv6(0, 0, len, nh, 64, src, dst, NULL, 0, l, ptag); } +/** + * Local Variables: + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + */