--- embedaddon/libnet/src/libnet_init.c 2013/07/22 11:54:42 1.1.1.2 +++ embedaddon/libnet/src/libnet_init.c 2023/09/27 11:11:38 1.1.1.3 @@ -1,5 +1,5 @@ /* - * $Id: libnet_init.c,v 1.1.1.2 2013/07/22 11:54:42 misho Exp $ + * $Id: libnet_init.c,v 1.1.1.3 2023/09/27 11:11:38 misho Exp $ * * libnet * libnet_init.c - Initilization routines. @@ -30,14 +30,7 @@ * */ -#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" libnet_t * libnet_init(int injection_type, const char *device, char *err_buf) @@ -50,7 +43,7 @@ libnet_init(int injection_type, const char *device, ch if ((WSAStartup(0x0202, &wsaData)) != 0) { snprintf(err_buf, LIBNET_ERRBUF_SIZE, - "%s(): unable to initialize winsock 2\n", __func__); + "%s(): unable to initialize winsock 2", __func__); goto bad; } #endif @@ -58,7 +51,7 @@ libnet_init(int injection_type, const char *device, ch l = (libnet_t *)malloc(sizeof (libnet_t)); if (l == NULL) { - snprintf(err_buf, LIBNET_ERRBUF_SIZE, "%s(): malloc(): %s\n", __func__, + snprintf(err_buf, LIBNET_ERRBUF_SIZE, "%s(): malloc(): %s", __func__, strerror(errno)); goto bad; } @@ -108,7 +101,7 @@ libnet_init(int injection_type, const char *device, ch break; default: snprintf(err_buf, LIBNET_ERRBUF_SIZE, - "%s(): unsupported injection type\n", __func__); + "%s(): unsupported injection type", __func__); goto bad; break; } @@ -128,7 +121,8 @@ libnet_destroy(libnet_t *l) { if (l) { - close(l->fd); + if (l->fd != -1) + close(l->fd); free(l->device); libnet_clear_packet(l); free(l); @@ -175,7 +169,7 @@ libnet_getfd(libnet_t *l) return (-1); } - return (l->fd); + return (int)(l->fd); } const char * @@ -257,4 +251,9 @@ libnet_getpacket_size(libnet_t *l) return (n); } -/* EOF */ +/** + * Local Variables: + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + */