libnet4r 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +15 -0
- data/LICENSE +28 -0
- data/README +187 -0
- data/Rakefile +110 -0
- data/ext/extconf.rb +60 -0
- data/ext/libnet.c +705 -0
- data/ext/libnet_arp.c +152 -0
- data/ext/libnet_ethernet.c +115 -0
- data/ext/libnet_ipv4.c +140 -0
- data/ext/libnet_ipv6.c +138 -0
- data/ext/libnet_udp.c +112 -0
- data/ext/libnet_vlan.c +131 -0
- data/lib/libnet4r/header.rb +609 -0
- data/lib/libnet4r/helpers.rb +19 -0
- data/lib/libnet4r/libnet.rb +39 -0
- data/libnet/CVS/Entries +24 -0
- data/libnet/CVS/Repository +1 -0
- data/libnet/CVS/Root +1 -0
- data/libnet/Makefile.am +15 -0
- data/libnet/Makefile.am.common +10 -0
- data/libnet/Makefile.in +443 -0
- data/libnet/README +21 -0
- data/libnet/VERSION +1 -0
- data/libnet/acconfig.h +36 -0
- data/libnet/acinclude.m4 +463 -0
- data/libnet/aclocal.m4 +1337 -0
- data/libnet/autom4te.cache/CVS/Entries +1 -0
- data/libnet/autom4te.cache/CVS/Repository +1 -0
- data/libnet/autom4te.cache/CVS/Root +1 -0
- data/libnet/autom4te.cache/output.0 +6225 -0
- data/libnet/autom4te.cache/requests +111 -0
- data/libnet/autom4te.cache/traces.0 +272 -0
- data/libnet/config.guess +1314 -0
- data/libnet/config.sub +1410 -0
- data/libnet/configure +6225 -0
- data/libnet/configure.in +235 -0
- data/libnet/doc/BUGS +19 -0
- data/libnet/doc/CHANGELOG +527 -0
- data/libnet/doc/CONTRIB +53 -0
- data/libnet/doc/COPYING +31 -0
- data/libnet/doc/CVS/Entries +12 -0
- data/libnet/doc/CVS/Repository +1 -0
- data/libnet/doc/CVS/Root +1 -0
- data/libnet/doc/DESIGN_NOTES +134 -0
- data/libnet/doc/MIGRATION +172 -0
- data/libnet/doc/PACKET_BUILDING +161 -0
- data/libnet/doc/PORTED +45 -0
- data/libnet/doc/RAWSOCKET_NON_SEQUITUR +41 -0
- data/libnet/doc/TODO +96 -0
- data/libnet/doc/html/acconfig_8h-source.html +49 -0
- data/libnet/doc/html/annotated.html +17 -0
- data/libnet/doc/html/bpf_8h-source.html +277 -0
- data/libnet/doc/html/config_8h-source.html +125 -0
- data/libnet/doc/html/doxygen.css +169 -0
- data/libnet/doc/html/doxygen.png +0 -0
- data/libnet/doc/html/files.html +29 -0
- data/libnet/doc/html/functions.html +26 -0
- data/libnet/doc/html/functions_vars.html +26 -0
- data/libnet/doc/html/getopt_8h-source.html +97 -0
- data/libnet/doc/html/globals.html +219 -0
- data/libnet/doc/html/globals_defs.html +104 -0
- data/libnet/doc/html/globals_func.html +136 -0
- data/libnet/doc/html/gnuc_8h-source.html +56 -0
- data/libnet/doc/html/graph_legend.dot +22 -0
- data/libnet/doc/html/graph_legend.html +75 -0
- data/libnet/doc/html/ifaddrlist_8h-source.html +65 -0
- data/libnet/doc/html/in__systm_8h-source.html +90 -0
- data/libnet/doc/html/index.html +17 -0
- data/libnet/doc/html/libnet-asn1_8h-source.html +268 -0
- data/libnet/doc/html/libnet-functions_8h-source.html +742 -0
- data/libnet/doc/html/libnet-functions_8h.html +8844 -0
- data/libnet/doc/html/libnet-headers_8h-source.html +1655 -0
- data/libnet/doc/html/libnet-headers_8h.html +3053 -0
- data/libnet/doc/html/libnet-macros_8h-source.html +161 -0
- data/libnet/doc/html/libnet-macros_8h.html +358 -0
- data/libnet/doc/html/libnet-structures_8h-source.html +233 -0
- data/libnet/doc/html/libnet-types_8h-source.html +58 -0
- data/libnet/doc/html/libnet_8h-source.html +119 -0
- data/libnet/doc/html/libnet_8h.html +24 -0
- data/libnet/doc/html/structlibnet__802__1q__hdr.html +145 -0
- data/libnet/doc/html/structlibnet__802__1x__hdr.html +97 -0
- data/libnet/doc/libnet.doxygen.conf +1102 -0
- data/libnet/doc/man/CVS/Entries +1 -0
- data/libnet/doc/man/CVS/Repository +1 -0
- data/libnet/doc/man/CVS/Root +1 -0
- data/libnet/doc/man/man3/libnet-functions.h.3 +3136 -0
- data/libnet/doc/man/man3/libnet-headers.h.3 +1872 -0
- data/libnet/doc/man/man3/libnet-macros.h.3 +172 -0
- data/libnet/doc/man/man3/libnet.h.3 +17 -0
- data/libnet/doc/man/man3/libnet_802_1q_hdr.3 +53 -0
- data/libnet/doc/man/man3/libnet_802_1x_hdr.3 +41 -0
- data/libnet/include/CVS/Entries +10 -0
- data/libnet/include/CVS/Repository +1 -0
- data/libnet/include/CVS/Root +1 -0
- data/libnet/include/Makefile.am +7 -0
- data/libnet/include/Makefile.in +395 -0
- data/libnet/include/bpf.h +264 -0
- data/libnet/include/config.h.in +118 -0
- data/libnet/include/gnuc.h +43 -0
- data/libnet/include/ifaddrlist.h +52 -0
- data/libnet/include/libnet/CVS/Entries +9 -0
- data/libnet/include/libnet/CVS/Repository +1 -0
- data/libnet/include/libnet/CVS/Root +1 -0
- data/libnet/include/libnet/Makefile.am +12 -0
- data/libnet/include/libnet/Makefile.in +294 -0
- data/libnet/include/libnet/libnet-asn1.h +255 -0
- data/libnet/include/libnet/libnet-functions.h +2157 -0
- data/libnet/include/libnet/libnet-headers.h +1662 -0
- data/libnet/include/libnet/libnet-macros.h +186 -0
- data/libnet/include/libnet/libnet-structures.h +222 -0
- data/libnet/include/libnet/libnet-types.h +45 -0
- data/libnet/include/libnet.h.in +132 -0
- data/libnet/include/stamp-h.in +1 -0
- data/libnet/include/win32/CVS/Entries +5 -0
- data/libnet/include/win32/CVS/Repository +1 -0
- data/libnet/include/win32/CVS/Root +1 -0
- data/libnet/include/win32/config.h +112 -0
- data/libnet/include/win32/getopt.h +84 -0
- data/libnet/include/win32/in_systm.h +77 -0
- data/libnet/include/win32/libnet.h +106 -0
- data/libnet/install-sh +250 -0
- data/libnet/libnet-config.in +62 -0
- data/libnet/libnet.doxygen.conf +1102 -0
- data/libnet/man/CVS/Entries +1 -0
- data/libnet/man/CVS/Repository +1 -0
- data/libnet/man/CVS/Root +1 -0
- data/libnet/missing +283 -0
- data/libnet/mkinstalldirs +40 -0
- data/libnet/sample/CVS/Entries +47 -0
- data/libnet/sample/CVS/Repository +1 -0
- data/libnet/sample/CVS/Root +1 -0
- data/libnet/sample/Makefile.am +63 -0
- data/libnet/sample/Makefile.in +729 -0
- data/libnet/sample/arp-new.c +144 -0
- data/libnet/sample/arp.c +151 -0
- data/libnet/sample/bgp4_hdr.c +225 -0
- data/libnet/sample/bgp4_notification.c +242 -0
- data/libnet/sample/bgp4_open.c +266 -0
- data/libnet/sample/bgp4_update.c +337 -0
- data/libnet/sample/cdp.c +187 -0
- data/libnet/sample/dhcp_discover.c +257 -0
- data/libnet/sample/dns.c +260 -0
- data/libnet/sample/dot1x.c +113 -0
- data/libnet/sample/fddi_tcp1.c +213 -0
- data/libnet/sample/fddi_tcp2.c +209 -0
- data/libnet/sample/get_addr.c +112 -0
- data/libnet/sample/gre.c +410 -0
- data/libnet/sample/icmp6_echoreq.c +184 -0
- data/libnet/sample/icmp_echo_cq.c +201 -0
- data/libnet/sample/icmp_redirect.c +200 -0
- data/libnet/sample/icmp_timeexceed.c +190 -0
- data/libnet/sample/icmp_timestamp.c +157 -0
- data/libnet/sample/icmp_unreach.c +204 -0
- data/libnet/sample/ieee.c +177 -0
- data/libnet/sample/ip_link.c +201 -0
- data/libnet/sample/ip_raw.c +180 -0
- data/libnet/sample/isl.c +167 -0
- data/libnet/sample/libnet_test.h +60 -0
- data/libnet/sample/mpls.c +251 -0
- data/libnet/sample/ntp.c +193 -0
- data/libnet/sample/ospf_hello.c +179 -0
- data/libnet/sample/ospf_lsa.c +190 -0
- data/libnet/sample/ping_of_death.c +171 -0
- data/libnet/sample/rpc_tcp.c +214 -0
- data/libnet/sample/rpc_udp.c +213 -0
- data/libnet/sample/sebek.c +299 -0
- data/libnet/sample/smurf.c +194 -0
- data/libnet/sample/stp.c +227 -0
- data/libnet/sample/synflood.c +200 -0
- data/libnet/sample/synflood6.c +209 -0
- data/libnet/sample/synflood6_frag.c +234 -0
- data/libnet/sample/tcp1.c +227 -0
- data/libnet/sample/tcp2.c +192 -0
- data/libnet/sample/tftp.c +207 -0
- data/libnet/sample/tring_tcp1.c +214 -0
- data/libnet/sample/tring_tcp2.c +210 -0
- data/libnet/sample/udp1.c +223 -0
- data/libnet/sample/udp2.c +232 -0
- data/libnet/sample/win32/CVS/Entries +9 -0
- data/libnet/sample/win32/CVS/Repository +1 -0
- data/libnet/sample/win32/CVS/Root +1 -0
- data/libnet/sample/win32/arp/CVS/Entries +2 -0
- data/libnet/sample/win32/arp/CVS/Repository +1 -0
- data/libnet/sample/win32/arp/CVS/Root +1 -0
- data/libnet/sample/win32/arp/arp.vcproj +136 -0
- data/libnet/sample/win32/cdp/CVS/Entries +2 -0
- data/libnet/sample/win32/cdp/CVS/Repository +1 -0
- data/libnet/sample/win32/cdp/CVS/Root +1 -0
- data/libnet/sample/win32/cdp/cdp.vcproj +136 -0
- data/libnet/sample/win32/dhcp_discover/CVS/Entries +2 -0
- data/libnet/sample/win32/dhcp_discover/CVS/Repository +1 -0
- data/libnet/sample/win32/dhcp_discover/CVS/Root +1 -0
- data/libnet/sample/win32/dhcp_discover/dhcp_discover.vcproj +139 -0
- data/libnet/sample/win32/dns/CVS/Entries +2 -0
- data/libnet/sample/win32/dns/CVS/Repository +1 -0
- data/libnet/sample/win32/dns/CVS/Root +1 -0
- data/libnet/sample/win32/dns/dns.vcproj +139 -0
- data/libnet/sample/win32/get_addr/CVS/Entries +2 -0
- data/libnet/sample/win32/get_addr/CVS/Repository +1 -0
- data/libnet/sample/win32/get_addr/CVS/Root +1 -0
- data/libnet/sample/win32/get_addr/get_addr.vcproj +139 -0
- data/libnet/sample/win32/getopt.c +121 -0
- data/libnet/sample/win32/icmp_echo_cq/CVS/Entries +2 -0
- data/libnet/sample/win32/icmp_echo_cq/CVS/Repository +1 -0
- data/libnet/sample/win32/icmp_echo_cq/CVS/Root +1 -0
- data/libnet/sample/win32/icmp_echo_cq/icmp_echo_cq.vcproj +139 -0
- data/libnet/sample/win32/tcp1/CVS/Entries +2 -0
- data/libnet/sample/win32/tcp1/CVS/Repository +1 -0
- data/libnet/sample/win32/tcp1/CVS/Root +1 -0
- data/libnet/sample/win32/tcp1/tcp1.vcproj +142 -0
- data/libnet/sample/win32/udp1/CVS/Entries +3 -0
- data/libnet/sample/win32/udp1/CVS/Repository +1 -0
- data/libnet/sample/win32/udp1/CVS/Root +1 -0
- data/libnet/sample/win32/udp1/dns.vcproj +125 -0
- data/libnet/sample/win32/udp1/udp1.vcproj +139 -0
- data/libnet/src/CVS/Entries +60 -0
- data/libnet/src/CVS/Repository +1 -0
- data/libnet/src/CVS/Root +1 -0
- data/libnet/src/Makefile.am +71 -0
- data/libnet/src/Makefile.in +428 -0
- data/libnet/src/libnet_advanced.c +136 -0
- data/libnet/src/libnet_asn1.c +436 -0
- data/libnet/src/libnet_build_802.1q.c +115 -0
- data/libnet/src/libnet_build_802.1x.c +103 -0
- data/libnet/src/libnet_build_802.2.c +167 -0
- data/libnet/src/libnet_build_802.3.c +101 -0
- data/libnet/src/libnet_build_arp.c +169 -0
- data/libnet/src/libnet_build_bgp.c +350 -0
- data/libnet/src/libnet_build_cdp.c +191 -0
- data/libnet/src/libnet_build_data.c +90 -0
- data/libnet/src/libnet_build_dhcp.c +156 -0
- data/libnet/src/libnet_build_dns.c +129 -0
- data/libnet/src/libnet_build_ethernet.c +173 -0
- data/libnet/src/libnet_build_fddi.c +191 -0
- data/libnet/src/libnet_build_gre.c +427 -0
- data/libnet/src/libnet_build_icmp.c +437 -0
- data/libnet/src/libnet_build_igmp.c +112 -0
- data/libnet/src/libnet_build_ip.c +892 -0
- data/libnet/src/libnet_build_ipsec.c +232 -0
- data/libnet/src/libnet_build_isl.c +113 -0
- data/libnet/src/libnet_build_link.c +90 -0
- data/libnet/src/libnet_build_mpls.c +112 -0
- data/libnet/src/libnet_build_ntp.c +121 -0
- data/libnet/src/libnet_build_ospf.c +699 -0
- data/libnet/src/libnet_build_rip.c +108 -0
- data/libnet/src/libnet_build_rpc.c +138 -0
- data/libnet/src/libnet_build_sebek.c +108 -0
- data/libnet/src/libnet_build_snmp.c +52 -0
- data/libnet/src/libnet_build_stp.c +222 -0
- data/libnet/src/libnet_build_tcp.c +365 -0
- data/libnet/src/libnet_build_token_ring.c +193 -0
- data/libnet/src/libnet_build_udp.c +111 -0
- data/libnet/src/libnet_build_vrrp.c +117 -0
- data/libnet/src/libnet_checksum.c +376 -0
- data/libnet/src/libnet_cq.c +395 -0
- data/libnet/src/libnet_crc.c +113 -0
- data/libnet/src/libnet_dll.c +47 -0
- data/libnet/src/libnet_error.c +55 -0
- data/libnet/src/libnet_if_addr.c +415 -0
- data/libnet/src/libnet_init.c +234 -0
- data/libnet/src/libnet_internal.c +310 -0
- data/libnet/src/libnet_link_bpf.c +348 -0
- data/libnet/src/libnet_link_dlpi.c +785 -0
- data/libnet/src/libnet_link_linux.c +310 -0
- data/libnet/src/libnet_link_nit.c +125 -0
- data/libnet/src/libnet_link_none.c +66 -0
- data/libnet/src/libnet_link_pf.c +179 -0
- data/libnet/src/libnet_link_snit.c +149 -0
- data/libnet/src/libnet_link_snoop.c +166 -0
- data/libnet/src/libnet_link_win32.c +346 -0
- data/libnet/src/libnet_pblock.c +511 -0
- data/libnet/src/libnet_port_list.c +295 -0
- data/libnet/src/libnet_prand.c +106 -0
- data/libnet/src/libnet_raw.c +257 -0
- data/libnet/src/libnet_resolve.c +414 -0
- data/libnet/src/libnet_version.c +54 -0
- data/libnet/src/libnet_write.c +502 -0
- data/libnet/version.h.in +6 -0
- data/libnet/win32/CVS/Entries +15 -0
- data/libnet/win32/CVS/Repository +1 -0
- data/libnet/win32/CVS/Root +1 -0
- data/libnet/win32/Libnet-1.1.1-2002.sln +77 -0
- data/libnet/win32/Libnet-1.1.1-2003.ncb +0 -0
- data/libnet/win32/Libnet-1.1.1-2003.sln +84 -0
- data/libnet/win32/Libnet-1.1.1-2003.suo +0 -0
- data/libnet/win32/Libnet-1.1.1.vcproj +311 -0
- data/libnet/win32/Libnet-latest.ncb +0 -0
- data/libnet/win32/Libnet-latest.opt +0 -0
- data/libnet/win32/Libnet-latest.sln +77 -0
- data/libnet/win32/Libnet-latest.suo +0 -0
- data/libnet/win32/Libnet-latest.vcproj +311 -0
- data/libnet/win32/Libnet.dsp +337 -0
- data/libnet/win32/Libnet.dsw +32 -0
- data/libnet/win32/README.txt +57 -0
- data/libnet/win32/libnet_dll.def +164 -0
- data/test/tc_arp.rb +169 -0
- data/test/tc_class.rb +219 -0
- data/test/tc_ethernet.rb +97 -0
- data/test/tc_header.rb +163 -0
- data/test/tc_init.rb +25 -0
- data/test/tc_ipv4.rb +219 -0
- data/test/tc_ipv6.rb +235 -0
- data/test/tc_udp.rb +229 -0
- data/test/tc_vlan.rb +118 -0
- data/test/ts_all.rb +15 -0
- metadata +401 -0
@@ -0,0 +1,395 @@
|
|
1
|
+
/*
|
2
|
+
* $Id: libnet_cq.c,v 1.11 2004/01/28 19:45:00 mike Exp $
|
3
|
+
*
|
4
|
+
* libnet
|
5
|
+
* libnet_cq.c - context queue management routines
|
6
|
+
*
|
7
|
+
* Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
|
8
|
+
* Copyright (c) 2002 Fr�d�ric Raynal <pappy@security-labs.org>
|
9
|
+
* All rights reserved.
|
10
|
+
*
|
11
|
+
* Redistribution and use in source and binary forms, with or without
|
12
|
+
* modification, are permitted provided that the following conditions
|
13
|
+
* are met:
|
14
|
+
* 1. Redistributions of source code must retain the above copyright
|
15
|
+
* notice, this list of conditions and the following disclaimer.
|
16
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
17
|
+
* notice, this list of conditions and the following disclaimer in the
|
18
|
+
* documentation and/or other materials provided with the distribution.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
21
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
24
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
26
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
27
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
28
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
29
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
30
|
+
* SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#if (HAVE_CONFIG_H)
|
35
|
+
#include "../include/config.h"
|
36
|
+
#endif
|
37
|
+
#if (!(_WIN32) || (__CYGWIN__))
|
38
|
+
#include "../include/libnet.h"
|
39
|
+
#else
|
40
|
+
#include "../include/win32/libnet.h"
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/* private function prototypes */
|
44
|
+
static libnet_cq_t *libnet_cq_find_internal(libnet_t *);
|
45
|
+
static int libnet_cq_dup_check(libnet_t *, char *);
|
46
|
+
static libnet_cq_t *libnet_cq_find_by_label_internal(char *label);
|
47
|
+
|
48
|
+
/* global context queue */
|
49
|
+
static libnet_cq_t *l_cq = NULL;
|
50
|
+
static libnet_cqd_t l_cqd = {0, CQ_LOCK_UNLOCKED, NULL};
|
51
|
+
|
52
|
+
|
53
|
+
static inline int set_cq_lock(u_int x)
|
54
|
+
{
|
55
|
+
if (check_cq_lock(x))
|
56
|
+
{
|
57
|
+
return (0);
|
58
|
+
}
|
59
|
+
|
60
|
+
l_cqd.cq_lock |= x;
|
61
|
+
return (1);
|
62
|
+
}
|
63
|
+
|
64
|
+
static inline int clear_cq_lock(u_int x)
|
65
|
+
{
|
66
|
+
if (!check_cq_lock(x))
|
67
|
+
{
|
68
|
+
return (0);
|
69
|
+
}
|
70
|
+
|
71
|
+
l_cqd.cq_lock &= ~x;
|
72
|
+
return (1);
|
73
|
+
}
|
74
|
+
|
75
|
+
int
|
76
|
+
libnet_cq_add(libnet_t *l, char *label)
|
77
|
+
{
|
78
|
+
libnet_cq_t *new;
|
79
|
+
|
80
|
+
if (l == NULL)
|
81
|
+
{
|
82
|
+
return (-1);
|
83
|
+
}
|
84
|
+
|
85
|
+
/* check for write lock on the context queue */
|
86
|
+
if (cq_is_wlocked())
|
87
|
+
{
|
88
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
89
|
+
"%s(): can't add, context queue is write locked\n", __func__);
|
90
|
+
return (-1);
|
91
|
+
}
|
92
|
+
|
93
|
+
/* ensure there is a label */
|
94
|
+
if (label == NULL)
|
95
|
+
{
|
96
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): empty label\n",
|
97
|
+
__func__);
|
98
|
+
return (-1);
|
99
|
+
}
|
100
|
+
|
101
|
+
/* check to see if we're the first node on the list */
|
102
|
+
if (l_cq == NULL)
|
103
|
+
{
|
104
|
+
l_cq = (libnet_cq_t *)malloc(sizeof (libnet_cq_t));
|
105
|
+
if (l_cq == NULL)
|
106
|
+
{
|
107
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
108
|
+
"%s(): can't malloc initial context queue: %s\n",
|
109
|
+
__func__, strerror(errno));
|
110
|
+
return (-1);
|
111
|
+
}
|
112
|
+
|
113
|
+
l_cq->context = l;
|
114
|
+
|
115
|
+
/* label the context with the user specified string */
|
116
|
+
strncpy(l->label, label, LIBNET_LABEL_SIZE);
|
117
|
+
l->label[LIBNET_LABEL_SIZE] = '\0';
|
118
|
+
|
119
|
+
l_cq->next = NULL;
|
120
|
+
l_cq->prev = NULL;
|
121
|
+
|
122
|
+
/* track the number of nodes in the context queue */
|
123
|
+
l_cqd.node = 1;
|
124
|
+
|
125
|
+
return (1);
|
126
|
+
}
|
127
|
+
|
128
|
+
/* check to see if the cq we're about to add is already in the list */
|
129
|
+
if (libnet_cq_dup_check(l, label))
|
130
|
+
{
|
131
|
+
/* error message set in libnet_cq_dup_check() */
|
132
|
+
return (-1);
|
133
|
+
}
|
134
|
+
|
135
|
+
new = (libnet_cq_t *)malloc(sizeof (libnet_cq_t));
|
136
|
+
if (l_cq == NULL)
|
137
|
+
{
|
138
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
139
|
+
"%s(): can't malloc new context queue: %s\n",
|
140
|
+
__func__, strerror(errno));
|
141
|
+
return (-1);
|
142
|
+
}
|
143
|
+
|
144
|
+
new->context = l;
|
145
|
+
|
146
|
+
/* label the context with the user specified string */
|
147
|
+
strncpy(l->label, label, LIBNET_LABEL_SIZE);
|
148
|
+
l->label[LIBNET_LABEL_SIZE] = '\0';
|
149
|
+
|
150
|
+
new->next = l_cq;
|
151
|
+
new->prev = NULL;
|
152
|
+
|
153
|
+
l_cq->prev = new;
|
154
|
+
l_cq = new;
|
155
|
+
|
156
|
+
/* track the number of nodes in the context queue */
|
157
|
+
l_cqd.node++;
|
158
|
+
|
159
|
+
return (1);
|
160
|
+
}
|
161
|
+
|
162
|
+
libnet_t *
|
163
|
+
libnet_cq_remove(libnet_t *l)
|
164
|
+
{
|
165
|
+
libnet_cq_t *p;
|
166
|
+
libnet_t *ret;
|
167
|
+
|
168
|
+
if (l_cq == NULL)
|
169
|
+
{
|
170
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
171
|
+
"%s(): can't remove from empty context queue\n", __func__);
|
172
|
+
return (NULL);
|
173
|
+
}
|
174
|
+
|
175
|
+
if (l == NULL)
|
176
|
+
{
|
177
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
178
|
+
"%s(): can't remove empty libnet context\n", __func__);
|
179
|
+
return(NULL);
|
180
|
+
}
|
181
|
+
|
182
|
+
/* check for write lock on the cq */
|
183
|
+
if (cq_is_wlocked())
|
184
|
+
{
|
185
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
186
|
+
"%s(): can't remove, context queue is write locked\n",
|
187
|
+
__func__);
|
188
|
+
return (NULL);
|
189
|
+
}
|
190
|
+
|
191
|
+
if ((p = libnet_cq_find_internal(l)) == NULL)
|
192
|
+
{
|
193
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
194
|
+
"%s(): context not present in context queue\n", __func__);
|
195
|
+
return (NULL);
|
196
|
+
}
|
197
|
+
|
198
|
+
if (p->prev)
|
199
|
+
{
|
200
|
+
p->prev->next = p->next;
|
201
|
+
}
|
202
|
+
else
|
203
|
+
{
|
204
|
+
l_cq = p->next;
|
205
|
+
}
|
206
|
+
if (p->next)
|
207
|
+
{
|
208
|
+
p->next->prev = p->prev;
|
209
|
+
}
|
210
|
+
|
211
|
+
ret = p->context;
|
212
|
+
free(p);
|
213
|
+
|
214
|
+
/* track the number of nodes in the cq */
|
215
|
+
l_cqd.node--;
|
216
|
+
|
217
|
+
return (ret);
|
218
|
+
}
|
219
|
+
|
220
|
+
libnet_t *
|
221
|
+
libnet_cq_remove_by_label(char *label)
|
222
|
+
{
|
223
|
+
libnet_cq_t *p;
|
224
|
+
libnet_t *ret;
|
225
|
+
|
226
|
+
if ((p = libnet_cq_find_by_label_internal(label)) == NULL)
|
227
|
+
{
|
228
|
+
/* no context to write an error message */
|
229
|
+
return (NULL);
|
230
|
+
}
|
231
|
+
|
232
|
+
if (cq_is_wlocked())
|
233
|
+
{
|
234
|
+
/* now we have a context, but the user can't see it */
|
235
|
+
return (NULL);
|
236
|
+
}
|
237
|
+
|
238
|
+
if (p->prev)
|
239
|
+
{
|
240
|
+
p->prev->next = p->next;
|
241
|
+
}
|
242
|
+
else
|
243
|
+
{
|
244
|
+
l_cq = p->next;
|
245
|
+
}
|
246
|
+
if (p->next)
|
247
|
+
{
|
248
|
+
p->next->prev = p->prev;
|
249
|
+
}
|
250
|
+
|
251
|
+
ret = p->context;
|
252
|
+
free(p);
|
253
|
+
|
254
|
+
/* track the number of nodes in the cq */
|
255
|
+
l_cqd.node--;
|
256
|
+
|
257
|
+
return (ret);
|
258
|
+
}
|
259
|
+
|
260
|
+
libnet_cq_t *
|
261
|
+
libnet_cq_find_internal(libnet_t *l)
|
262
|
+
{
|
263
|
+
libnet_cq_t *p;
|
264
|
+
|
265
|
+
for (p = l_cq; p; p = p->next)
|
266
|
+
{
|
267
|
+
if (p->context == l)
|
268
|
+
{
|
269
|
+
return (p);
|
270
|
+
}
|
271
|
+
}
|
272
|
+
return (NULL);
|
273
|
+
}
|
274
|
+
|
275
|
+
int
|
276
|
+
libnet_cq_dup_check(libnet_t *l, char *label)
|
277
|
+
{
|
278
|
+
libnet_cq_t *p;
|
279
|
+
|
280
|
+
for (p = l_cq; p; p = p->next)
|
281
|
+
{
|
282
|
+
if (p->context == l)
|
283
|
+
{
|
284
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
285
|
+
"%s(): context already in context queue\n", __func__);
|
286
|
+
return (1);
|
287
|
+
}
|
288
|
+
if (strncmp(p->context->label, label, LIBNET_LABEL_SIZE) == 0)
|
289
|
+
{
|
290
|
+
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
|
291
|
+
"%s(): duplicate label %s\n", __func__, label);
|
292
|
+
return (1);
|
293
|
+
}
|
294
|
+
}
|
295
|
+
/* no duplicate */
|
296
|
+
return (0);
|
297
|
+
}
|
298
|
+
|
299
|
+
libnet_cq_t *
|
300
|
+
libnet_cq_find_by_label_internal(char *label)
|
301
|
+
{
|
302
|
+
libnet_cq_t *p;
|
303
|
+
|
304
|
+
if (label == NULL)
|
305
|
+
{
|
306
|
+
return (NULL);
|
307
|
+
}
|
308
|
+
|
309
|
+
for (p = l_cq; p; p = p->next)
|
310
|
+
{
|
311
|
+
if (!strncmp(p->context->label, label, LIBNET_LABEL_SIZE))
|
312
|
+
{
|
313
|
+
return (p);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
return (NULL);
|
317
|
+
}
|
318
|
+
|
319
|
+
libnet_t *
|
320
|
+
libnet_cq_find_by_label(char *label)
|
321
|
+
{
|
322
|
+
libnet_cq_t *p;
|
323
|
+
|
324
|
+
p = libnet_cq_find_by_label_internal(label);
|
325
|
+
return (p ? p->context : NULL);
|
326
|
+
}
|
327
|
+
|
328
|
+
int8_t *
|
329
|
+
libnet_cq_getlabel(libnet_t *l)
|
330
|
+
{
|
331
|
+
return (l->label);
|
332
|
+
}
|
333
|
+
|
334
|
+
void
|
335
|
+
libnet_cq_destroy()
|
336
|
+
{
|
337
|
+
libnet_cq_t *p = l_cq;
|
338
|
+
libnet_cq_t *tmp;
|
339
|
+
|
340
|
+
while (p)
|
341
|
+
{
|
342
|
+
tmp = p;
|
343
|
+
p = p->next;
|
344
|
+
libnet_destroy(tmp->context);
|
345
|
+
free(tmp);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
libnet_t *
|
350
|
+
libnet_cq_head()
|
351
|
+
{
|
352
|
+
if (l_cq == NULL)
|
353
|
+
{
|
354
|
+
return (NULL);
|
355
|
+
}
|
356
|
+
|
357
|
+
if (!set_cq_lock(CQ_LOCK_WRITE))
|
358
|
+
{
|
359
|
+
return (NULL);
|
360
|
+
}
|
361
|
+
|
362
|
+
l_cqd.current = l_cq;
|
363
|
+
return (l_cqd.current->context);
|
364
|
+
}
|
365
|
+
|
366
|
+
int
|
367
|
+
libnet_cq_last()
|
368
|
+
{
|
369
|
+
if (l_cqd.current)
|
370
|
+
{
|
371
|
+
return (1);
|
372
|
+
}
|
373
|
+
else
|
374
|
+
{
|
375
|
+
return (0);
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
libnet_t *
|
380
|
+
libnet_cq_next()
|
381
|
+
{
|
382
|
+
if (l_cqd.current == NULL)
|
383
|
+
{
|
384
|
+
return (NULL);
|
385
|
+
}
|
386
|
+
|
387
|
+
l_cqd.current = l_cqd.current->next;
|
388
|
+
return (l_cqd.current ? l_cqd.current->context : NULL);
|
389
|
+
}
|
390
|
+
|
391
|
+
u_int32_t
|
392
|
+
libnet_cq_size()
|
393
|
+
{
|
394
|
+
return (l_cqd.node);
|
395
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/*
|
2
|
+
* $Id: libnet_crc.c,v 1.5 2004/01/03 20:31:02 mike Exp $
|
3
|
+
*
|
4
|
+
* libnet
|
5
|
+
* libnet_crc.c - CRC routine
|
6
|
+
*
|
7
|
+
* Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
|
8
|
+
* All rights reserved.
|
9
|
+
*
|
10
|
+
* Redistribution and use in source and binary forms, with or without
|
11
|
+
* modification, are permitted provided that the following conditions
|
12
|
+
* are met:
|
13
|
+
* 1. Redistributions of source code must retain the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer.
|
15
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
* notice, this list of conditions and the following disclaimer in the
|
17
|
+
* documentation and/or other materials provided with the distribution.
|
18
|
+
*
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
20
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
23
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
25
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
26
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
27
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
28
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
29
|
+
* SUCH DAMAGE.
|
30
|
+
*
|
31
|
+
*/
|
32
|
+
|
33
|
+
#if (HAVE_CONFIG_H)
|
34
|
+
#include "../include/config.h"
|
35
|
+
#endif
|
36
|
+
#if (!(_WIN32) || (__CYGWIN__))
|
37
|
+
#include "../include/libnet.h"
|
38
|
+
#else
|
39
|
+
#include "../include/win32/libnet.h"
|
40
|
+
#endif
|
41
|
+
|
42
|
+
|
43
|
+
/* CRC routines based off of sample code in appendix of RFC 2083 */
|
44
|
+
static u_int crc_table[256] =
|
45
|
+
{
|
46
|
+
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
|
47
|
+
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
48
|
+
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
|
49
|
+
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
50
|
+
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
51
|
+
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
52
|
+
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
|
53
|
+
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
54
|
+
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
|
55
|
+
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
56
|
+
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
|
57
|
+
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
58
|
+
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
|
59
|
+
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
60
|
+
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
61
|
+
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
62
|
+
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
|
63
|
+
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
64
|
+
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
|
65
|
+
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
66
|
+
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
|
67
|
+
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
68
|
+
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
|
69
|
+
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
70
|
+
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
71
|
+
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
72
|
+
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
|
73
|
+
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
74
|
+
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
|
75
|
+
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
76
|
+
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
|
77
|
+
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
78
|
+
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
|
79
|
+
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
80
|
+
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
81
|
+
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
82
|
+
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
|
83
|
+
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
84
|
+
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
|
85
|
+
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
86
|
+
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
|
87
|
+
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
88
|
+
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
89
|
+
};
|
90
|
+
|
91
|
+
|
92
|
+
/*
|
93
|
+
* Compute the CRC of the contents of a buffer
|
94
|
+
*
|
95
|
+
* CRC generator G(x) is the sum of x^n for
|
96
|
+
* n = 32, 26, 23, 22, 16, 12, 11, 10, 8, 7, 5, 4, 2, 1, 0
|
97
|
+
*/
|
98
|
+
u_int32_t
|
99
|
+
libnet_compute_crc(u_int8_t *buf, u_int32_t len)
|
100
|
+
{
|
101
|
+
u_int32_t val;
|
102
|
+
|
103
|
+
val = ~0;
|
104
|
+
while (len--)
|
105
|
+
{
|
106
|
+
val = crc_table[(val ^ *buf) & 0xff] ^ (val >> 0x08);
|
107
|
+
buf++;
|
108
|
+
}
|
109
|
+
return (~val);
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
/* EOF */
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* libnet
|
4
|
+
* libnet_dll.c - low-level win32 dll routines
|
5
|
+
*
|
6
|
+
* Copyright (c) 2002 Roberto Larcher <roberto.larcher@libero.it>
|
7
|
+
* All rights reserved.
|
8
|
+
*
|
9
|
+
* Redistribution and use in source and binary forms, with or without
|
10
|
+
* modification, are permitted provided that the following conditions
|
11
|
+
* are met:
|
12
|
+
* 1. Redistributions of source code must retain the above copyright
|
13
|
+
* notice, this list of conditions and the following disclaimer.
|
14
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
15
|
+
* notice, this list of conditions and the following disclaimer in the
|
16
|
+
* documentation and/or other materials provided with the distribution.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
19
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
22
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
24
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
25
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
27
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
28
|
+
* SUCH DAMAGE.
|
29
|
+
*
|
30
|
+
*/
|
31
|
+
|
32
|
+
#include "../include/win32/libnet.h"
|
33
|
+
#include "packet32.h"
|
34
|
+
|
35
|
+
BOOL WINAPI DllMain(HINSTANCE hinst, ULONG fdwReason, LPVOID lpReserved)
|
36
|
+
{
|
37
|
+
switch (fdwReason)
|
38
|
+
{
|
39
|
+
case DLL_PROCESS_ATTACH:
|
40
|
+
break;
|
41
|
+
case DLL_PROCESS_DETACH:
|
42
|
+
break;
|
43
|
+
}
|
44
|
+
return (TRUE);
|
45
|
+
}
|
46
|
+
|
47
|
+
/* EOF */
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/*
|
2
|
+
* $Id: libnet_error.c,v 1.6 2004/01/03 20:31:02 mike Exp $
|
3
|
+
*
|
4
|
+
* libnet
|
5
|
+
* libnet_error.c - error handling code
|
6
|
+
*
|
7
|
+
* Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
|
8
|
+
* All rights reserved.
|
9
|
+
*
|
10
|
+
* Redistribution and use in source and binary forms, with or without
|
11
|
+
* modification, are permitted provided that the following conditions
|
12
|
+
* are met:
|
13
|
+
* 1. Redistributions of source code must retain the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer.
|
15
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
* notice, this list of conditions and the following disclaimer in the
|
17
|
+
* documentation and/or other materials provided with the distribution.
|
18
|
+
*
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
20
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
23
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
25
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
26
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
27
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
28
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
29
|
+
* SUCH DAMAGE.
|
30
|
+
*
|
31
|
+
*/
|
32
|
+
|
33
|
+
#if (HAVE_CONFIG_H)
|
34
|
+
#include "../include/config.h"
|
35
|
+
#endif
|
36
|
+
#if (!(_WIN32) || (__CYGWIN__))
|
37
|
+
#include "../include/libnet.h"
|
38
|
+
#else
|
39
|
+
#include "../include/win32/libnet.h"
|
40
|
+
#endif
|
41
|
+
|
42
|
+
|
43
|
+
char *
|
44
|
+
libnet_geterror(libnet_t *l)
|
45
|
+
{
|
46
|
+
if (l == NULL)
|
47
|
+
{
|
48
|
+
return (NULL);
|
49
|
+
}
|
50
|
+
|
51
|
+
return (l->err_buf);
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
/* EOF */
|