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,2157 @@
|
|
1
|
+
/*
|
2
|
+
* $Id: libnet-functions.h,v 1.42 2004/03/25 18:50:48 mike Exp $
|
3
|
+
*
|
4
|
+
* libnet-functions.h - function prototypes
|
5
|
+
*
|
6
|
+
* Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
|
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
|
+
#ifndef __LIBNET_FUNCTIONS_H
|
33
|
+
#define __LIBNET_FUNCTIONS_H
|
34
|
+
/**
|
35
|
+
* @file libnet-functions.h
|
36
|
+
* @brief libnet exported function prototypes
|
37
|
+
*/
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Creates the libnet environment. It initializes the library and returns a
|
41
|
+
* libnet context. If the injection_type is LIBNET_LINK or LIBNET_LINK_ADV, the
|
42
|
+
* function initializes the injection primitives for the link-layer interface
|
43
|
+
* enabling the application programmer to build packets starting at the
|
44
|
+
* data-link layer (which also provides more granular control over the IP
|
45
|
+
* layer). If libnet uses the link-layer and the device argument is non-NULL,
|
46
|
+
* the function attempts to use the specified network device for packet
|
47
|
+
* injection. This is either a canonical string that references the device
|
48
|
+
* (such as "eth0" for a 100MB Ethernet card on Linux or "fxp0" for a 100MB
|
49
|
+
* Ethernet card on OpenBSD) or the dots and decimals representation of the
|
50
|
+
* device's IP address (192.168.0.1). If device is NULL, libnet attempts to
|
51
|
+
* find a suitable device to use. If the injection_type is LIBNET_RAW4 or
|
52
|
+
* LIBNET_RAW4_ADV, the function initializes the injection primitives for the
|
53
|
+
* IPv4 raw socket interface. The final argument, err_buf, should be a buffer
|
54
|
+
* of size LIBNET_ERRBUF_SIZE and holds an error message if the function fails.
|
55
|
+
* This function requires root privileges to execute successfully. Upon
|
56
|
+
* success, the function returns a valid libnet context for use in later
|
57
|
+
* function calls; upon failure, the function returns NULL.
|
58
|
+
* @param injection_type packet injection type (LIBNET_LINK, LIBNET_LINK_ADV, LIBNET_RAW4, LIBNET_RAW4_ADV, LIBNET_RAW6, LIBNET_RAW6_ADV)
|
59
|
+
* @param device the interface to use (NULL and libnet will choose one)
|
60
|
+
* @param err_buf will contain an error message on failure
|
61
|
+
* @return libnet context ready for use or NULL on error.
|
62
|
+
*/
|
63
|
+
libnet_t *
|
64
|
+
libnet_init(int injection_type, char *device, char *err_buf);
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Shuts down the libnet session referenced by l. It closes the network
|
68
|
+
* interface and frees all internal memory structures associated with l.
|
69
|
+
* @param l pointer to a libnet context
|
70
|
+
*/
|
71
|
+
void
|
72
|
+
libnet_destroy(libnet_t *l);
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Clears the current packet referenced and frees all pblocks. Should be
|
76
|
+
* called when the programmer want to send a completely new packet of
|
77
|
+
* a different type using the same context.
|
78
|
+
* @param l pointer to a libnet context
|
79
|
+
*/
|
80
|
+
void
|
81
|
+
libnet_clear_packet(libnet_t *l);
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Fills in a libnet_stats structure with packet injection statistics
|
85
|
+
* (packets written, bytes written, packet sending errors).
|
86
|
+
* @param l pointer to a libnet context
|
87
|
+
* @param ls pointer to a libnet statistics structure
|
88
|
+
*/
|
89
|
+
void
|
90
|
+
libnet_stats(libnet_t *l, struct libnet_stats *ls);
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Returns the FILENO of the file descriptor used for packet injection.
|
94
|
+
* @param l pointer to a libnet context
|
95
|
+
* @return the file number of the file descriptor used for packet injection
|
96
|
+
*/
|
97
|
+
int
|
98
|
+
libnet_getfd(libnet_t *l);
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Returns the canonical name of the device used for packet injection.
|
102
|
+
* @param l pointer to a libnet context
|
103
|
+
* @return the canonical name of the device used for packet injection. Note
|
104
|
+
* it can be NULL without being an error.
|
105
|
+
*/
|
106
|
+
int8_t *
|
107
|
+
libnet_getdevice(libnet_t *l);
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Returns the pblock buffer contents for the specified ptag; a
|
111
|
+
* subsequent call to libnet_getpbuf_size() should be made to determine the
|
112
|
+
* size of the buffer.
|
113
|
+
* @param l pointer to a libnet context
|
114
|
+
* @param ptag the ptag reference number
|
115
|
+
* @return a pointer to the pblock buffer or NULL on error
|
116
|
+
*/
|
117
|
+
u_int8_t *
|
118
|
+
libnet_getpbuf(libnet_t *l, libnet_ptag_t ptag);
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Returns the pblock buffer size for the specified ptag; a
|
122
|
+
* previous call to libnet_getpbuf() should be made to pull the actual buffer
|
123
|
+
* contents.
|
124
|
+
* @param l pointer to a libnet context
|
125
|
+
* @param ptag the ptag reference number
|
126
|
+
* @return the size of the pblock buffer
|
127
|
+
*/
|
128
|
+
u_int32_t
|
129
|
+
libnet_getpbuf_size(libnet_t *l, libnet_ptag_t ptag);
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Returns the last error set inside of the referenced libnet context. This
|
133
|
+
* function should be called anytime a function fails or an error condition
|
134
|
+
* is detected inside of libnet.
|
135
|
+
* @param l pointer to a libnet context
|
136
|
+
* @return an error string or NULL if no error has occured
|
137
|
+
*/
|
138
|
+
char *
|
139
|
+
libnet_geterror(libnet_t *l);
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Returns the sum of the size of all of the pblocks inside of l (this should
|
143
|
+
* be the resuling packet size).
|
144
|
+
* @param l pointer to a libnet context
|
145
|
+
* @return the size of the packet in l
|
146
|
+
*/
|
147
|
+
u_int32_t
|
148
|
+
libnet_getpacket_size(libnet_t *l);
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Seeds the psuedo-random number generator.
|
152
|
+
* @param l pointer to a libnet context
|
153
|
+
* @return 1 on success, -1 on failure
|
154
|
+
*/
|
155
|
+
int
|
156
|
+
libnet_seed_prand(libnet_t *l);
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Generates an unsigned psuedo-random value within the range specified by
|
160
|
+
* mod.
|
161
|
+
* LIBNET_PR2 0 - 1
|
162
|
+
* LIBNET_PR8 0 - 255
|
163
|
+
* LIBNET_PR16 0 - 32767
|
164
|
+
* LIBNET_PRu16 0 - 65535
|
165
|
+
* LIBNET_PR32 0 - 2147483647
|
166
|
+
* LIBNET_PRu32 0 - 4294967295
|
167
|
+
*
|
168
|
+
* @param mod one the of LIBNET_PR* constants
|
169
|
+
* @return 1 on success, -1 on failure
|
170
|
+
*/
|
171
|
+
u_int32_t
|
172
|
+
libnet_get_prand(int mod);
|
173
|
+
|
174
|
+
/**
|
175
|
+
* If a given protocol header is built with the checksum field set to "0", by
|
176
|
+
* default libnet will calculate the header checksum prior to injection. If the
|
177
|
+
* header is set to any other value, by default libnet will not calculate the
|
178
|
+
* header checksum. To over-ride this behavior, use libnet_toggle_checksum().
|
179
|
+
* Switches auto-checksumming on or off for the specified ptag. If mode is set
|
180
|
+
* to LIBNET_ON, libnet will mark the specificed ptag to calculate a checksum
|
181
|
+
* for the ptag prior to injection. This assumes that the ptag refers to a
|
182
|
+
* protocol that has a checksum field. If mode is set to LIBNET_OFF, libnet
|
183
|
+
* will clear the checksum flag and no checksum will be computed prior to
|
184
|
+
* injection. This assumes that the programmer will assign a value (zero or
|
185
|
+
* otherwise) to the checksum field. Often times this is useful if a
|
186
|
+
* precomputed checksum or some other predefined value is going to be used.
|
187
|
+
* Note that when libnet is initialized with LIBNET_RAW4, the IPv4 header
|
188
|
+
* checksum will always be computed by the kernel prior to injection,
|
189
|
+
* regardless of what the programmer sets.
|
190
|
+
* @param l pointer to a libnet context
|
191
|
+
* @param ptag the ptag reference number
|
192
|
+
* @param mode LIBNET_ON or LIBNET_OFF
|
193
|
+
* @return 1 on success, -1 on failure
|
194
|
+
*/
|
195
|
+
int
|
196
|
+
libnet_toggle_checksum(libnet_t *l, libnet_ptag_t ptag, int mode);
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Takes a network byte ordered IPv4 address and returns a pointer to either a
|
200
|
+
* canonical DNS name (if it has one) or a string of dotted decimals. This may
|
201
|
+
* incur a DNS lookup if the hostname and mode is set to LIBNET_RESOLVE. If
|
202
|
+
* mode is set to LIBNET_DONT_RESOLVE, no DNS lookup will be performed and
|
203
|
+
* the function will return a pointer to a dotted decimal string. The function
|
204
|
+
* cannot fail -- if no canonical name exists, it will fall back on returning
|
205
|
+
* a dotted decimal string. This function is non-reentrant.
|
206
|
+
* @param in network byte ordered IPv4 address
|
207
|
+
* @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
|
208
|
+
* @return a pointer to presentation format string
|
209
|
+
*/
|
210
|
+
char *
|
211
|
+
libnet_addr2name4(u_int32_t in, u_int8_t use_name);
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Takes a dotted decimal string or a canonical DNS name and returns a
|
215
|
+
* network byte ordered IPv4 address. This may incur a DNS lookup if mode is
|
216
|
+
* set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If mode
|
217
|
+
* is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can
|
218
|
+
* fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and
|
219
|
+
* host_name refers to a canonical DNS name.
|
220
|
+
* @param l pointer to a libnet context
|
221
|
+
* @param host_name pointer to a string containing a presentation format host
|
222
|
+
* name
|
223
|
+
* @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
|
224
|
+
* @return network byte ordered IPv4 address or -1 (2^32 - 1) on error
|
225
|
+
*/
|
226
|
+
u_int32_t
|
227
|
+
libnet_name2addr4(libnet_t *l, char *host_name, u_int8_t use_name);
|
228
|
+
|
229
|
+
extern const struct libnet_in6_addr in6addr_error;
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Takes a dotted decimal string or a canonical DNS name and returns a
|
233
|
+
* network byte ordered IPv6 address. This may incur a DNS lookup if mode is
|
234
|
+
* set to LIBNET_RESOLVE and host_name refers to a canonical DNS name. If mode
|
235
|
+
* is set to LIBNET_DONT_RESOLVE no DNS lookup will occur. The function can
|
236
|
+
* fail if DNS lookup fails or if mode is set to LIBNET_DONT_RESOLVE and
|
237
|
+
* host_name refers to a canonical DNS name.
|
238
|
+
* @param l pointer to a libnet context
|
239
|
+
* @param host_name pointer to a string containing a presentation format host
|
240
|
+
* name
|
241
|
+
* @param use_name LIBNET_RESOLVE or LIBNET_DONT_RESOLVE
|
242
|
+
* @return network byte ordered IPv6 address structure
|
243
|
+
*/
|
244
|
+
struct libnet_in6_addr
|
245
|
+
libnet_name2addr6(libnet_t *l, char *host_name, u_int8_t use_name);
|
246
|
+
|
247
|
+
/**
|
248
|
+
* Should document this baby right here.
|
249
|
+
*/
|
250
|
+
void
|
251
|
+
libnet_addr2name6_r(struct libnet_in6_addr addr, u_int8_t use_name,
|
252
|
+
char *host_name, int host_name_len);
|
253
|
+
|
254
|
+
/**
|
255
|
+
* Creates a new port list. Port list chains are useful for TCP and UDP-based
|
256
|
+
* applications that need to send packets to a range of ports (contiguous or
|
257
|
+
* otherwise). The port list chain, which token_list points to, should contain
|
258
|
+
* a series of int8_tacters from the following list: "0123456789,-" of the
|
259
|
+
* general format "x - y, z", where "xyz" are port numbers between 0 and
|
260
|
+
* 65,535. plist points to the front of the port list chain list for use in
|
261
|
+
* further libnet_plist_chain() functions. Upon success, the function returns
|
262
|
+
* 1. Upon failure, the function returns -1 and libnet_geterror() can tell you
|
263
|
+
* why.
|
264
|
+
* @param l pointer to a libnet context
|
265
|
+
* @param plist if successful, will refer to the portlist, if not, NULL
|
266
|
+
* @param token_list string containing the port list primitive
|
267
|
+
* @return 1 on success, -1 on failure
|
268
|
+
*/
|
269
|
+
int
|
270
|
+
libnet_plist_chain_new(libnet_t *l, libnet_plist_t **plist, char *token_list);
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Returns the next port list chain pair from the port list chain plist. bport
|
274
|
+
* and eport contain the starting port number and ending port number,
|
275
|
+
* respectively. Upon success, the function returns 1 and fills in the port
|
276
|
+
* variables; however, if the list is empty, the function returns 0 and sets
|
277
|
+
* both port variables to 0. Upon failure, the function returns -1.
|
278
|
+
* @param plist previously created portlist
|
279
|
+
* @param bport will contain the beginning port number or 0
|
280
|
+
* @param eport will contain the ending port number or 0
|
281
|
+
* @return 1 on success, 0 if empty, -1 on failure
|
282
|
+
*/
|
283
|
+
int
|
284
|
+
libnet_plist_chain_next_pair(libnet_plist_t *plist, u_int16_t *bport,
|
285
|
+
u_int16_t *eport);
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Runs through the port list and prints the contents of the port list chain
|
289
|
+
* list to stdout.
|
290
|
+
* @param plist previously created portlist
|
291
|
+
* @return 1 on success, -1 on failure
|
292
|
+
*/
|
293
|
+
int
|
294
|
+
libnet_plist_chain_dump(libnet_plist_t *plist);
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Runs through the port list and prints the contents of the port list chain
|
298
|
+
* list to string. This function uses strdup and is not re-entrant. It also
|
299
|
+
* has a memory leak and should not really be used.
|
300
|
+
* @param plist previously created portlist
|
301
|
+
* @return a printable string containing the port list contents on success
|
302
|
+
* NULL on error
|
303
|
+
*/
|
304
|
+
char *
|
305
|
+
libnet_plist_chain_dump_string(libnet_plist_t *plist);
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Frees all memory associated with port list chain.
|
309
|
+
* @param plist previously created portlist
|
310
|
+
* @return 1 on success, -1 on failure
|
311
|
+
*/
|
312
|
+
int
|
313
|
+
libnet_plist_chain_free(libnet_plist_t *plist);
|
314
|
+
|
315
|
+
/**
|
316
|
+
* @section PBF Packet Builder Functions
|
317
|
+
*
|
318
|
+
* The core of libnet is the platform-independent packet-building
|
319
|
+
* functionality. These functions enable an application programmer to build
|
320
|
+
* protocol headers (and data) in a simple and consistent manner without having
|
321
|
+
* to worry (too much) about low-level network odds and ends. Each
|
322
|
+
* libnet_build() function builds a piece of a packet (generally a protocol
|
323
|
+
* header). While it is perfectly possible to build an entire,
|
324
|
+
* ready-to-transmit packet with a single call to a libnet_build() function,
|
325
|
+
* generally more than one builder-class function call is required to construct
|
326
|
+
* a full packet. A complete wire-ready packet generally consists of more than
|
327
|
+
* one piece.
|
328
|
+
* Every function that builds a protocol header takes a series of arguments
|
329
|
+
* roughly corresponding to the header values as they appear on the wire. This
|
330
|
+
* process is intuitive but often makes for functions with huge prototypes and
|
331
|
+
* large stack frames.
|
332
|
+
* One important thing to note is that you must call these functions in order,
|
333
|
+
* corresponding to how they should appear on the wire (from the highest
|
334
|
+
* protocol layer on down). This building process is intuitive; it approximates
|
335
|
+
* what happens in an operating system kernel. In other words, to build a
|
336
|
+
* Network Time Protocol (NTP) packet by using the link-layer interface, the
|
337
|
+
* application programmer would call the libnet_build() functions in the
|
338
|
+
* following order:
|
339
|
+
* 1. libnet_build_ntp()
|
340
|
+
* 2. libnet_build_udp()
|
341
|
+
* 3. libnet_build_ipv4()
|
342
|
+
* 4. libnet_build_ethernet()
|
343
|
+
* This ordering is essential for libnet 1.1.x to properly link together the
|
344
|
+
* packet internally (previous libnet versions did not have the requirement).
|
345
|
+
*
|
346
|
+
* @subsection TPI The Payload Interface
|
347
|
+
*
|
348
|
+
* The payload interface specifies an optional way to include data directly
|
349
|
+
* after the protocol header in question. You can use this function for a
|
350
|
+
* variety of purposes, including the following:
|
351
|
+
* - Including additional or arbitrary protocol header information that is not
|
352
|
+
* available from a libnet interface
|
353
|
+
* - Including a packet payload (data segment)
|
354
|
+
* - Building another protocol header that is not available from a libnet
|
355
|
+
* interface
|
356
|
+
* To employ the interface, the application programmer should construct the i
|
357
|
+
* payload data and pass a u_int8_t * to this data and its size to the desired
|
358
|
+
* libnet_build() function. Libnet handles the rest.
|
359
|
+
*
|
360
|
+
* It is important to note that some functions (notably the IPv6 builders) do
|
361
|
+
* use the payload interface to specify variable length but ostensibly
|
362
|
+
* non-optional data. See the individual libnet_build_ipv6*() functions for
|
363
|
+
* more information.
|
364
|
+
*
|
365
|
+
* @subsection PT Protocol Tags and Packet Builder Return Values
|
366
|
+
*
|
367
|
+
* Libnet uses the protocol tag (ptag) to identify individual pieces of a
|
368
|
+
* packet after being created. A new ptag results every time a libnet_build()
|
369
|
+
* function with an empty (0) ptag argument completes successfully. This new
|
370
|
+
* ptag now refers to the packet piece just created. The application
|
371
|
+
* programmer's responsibility is to save this value if he or she plans to
|
372
|
+
* modify this particular portion later on in the program. If the application
|
373
|
+
* programmer needs to modify some portion of that particular packet piece
|
374
|
+
* again, he or she calls the same libnet_build() function specifying the
|
375
|
+
* saved ptag argument. Libnet then searches for that packet piece and modifies
|
376
|
+
* it rather than creating a new one. Upon failure for any reason,
|
377
|
+
* libnet_build() functions return -1; libnet_geterror() tells you why.
|
378
|
+
*/
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Builds an IEEE 802.1q VLAN tagging header. Depending on the value of
|
382
|
+
* len_proto, the function wraps the 802.1q header inside either an IEEE 802.3
|
383
|
+
* header or an RFC 894 Ethernet II (DIX) header (both resulting in an 18-byte
|
384
|
+
* frame). If len is 1500 or less, most receiving protocol stacks parse the
|
385
|
+
* frame as an IEEE 802.3 encapsulated frame. If len is one of the Ethernet type
|
386
|
+
* values, most protocol stacks parse the frame as an RFC 894 Ethernet II
|
387
|
+
* encapsulated frame. Note the length value is calculated without the 802.1q
|
388
|
+
* header of 18 bytes.
|
389
|
+
* @param dst pointer to a six byte source ethernet address
|
390
|
+
* @param src pointer to a six byte destination ethernet address
|
391
|
+
* @param tpi tag protocol identifier
|
392
|
+
* @param priority priority
|
393
|
+
* @param cfi canonical format indicator
|
394
|
+
* @param vlan_id vlan identifier
|
395
|
+
* @param len_proto length (802.3) protocol (Ethernet II)
|
396
|
+
* @param payload optional payload or NULL
|
397
|
+
* @param payload_s payload length or 0
|
398
|
+
* @param l pointer to a libnet context
|
399
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
400
|
+
* @return protocol tag value on success, -1 on error
|
401
|
+
*/
|
402
|
+
libnet_ptag_t
|
403
|
+
libnet_build_802_1q(u_int8_t *dst, u_int8_t *src, u_int16_t tpi,
|
404
|
+
u_int8_t priority, u_int8_t cfi, u_int16_t vlan_id, u_int16_t len_proto,
|
405
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
406
|
+
|
407
|
+
/**
|
408
|
+
* Builds an IEEE 802.1x extended authentication protocol header.
|
409
|
+
* @param eap_ver the EAP version
|
410
|
+
* @param eap_type the EAP type
|
411
|
+
* @param length frame length
|
412
|
+
* @param payload optional payload or NULL
|
413
|
+
* @param payload_s payload length or 0
|
414
|
+
* @param l pointer to a libnet context
|
415
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
416
|
+
* @return protocol tag value on success, -1 on error
|
417
|
+
*/
|
418
|
+
libnet_ptag_t
|
419
|
+
libnet_build_802_1x(u_int8_t eap_ver, u_int8_t eap_type, u_int16_t length,
|
420
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
421
|
+
|
422
|
+
/**
|
423
|
+
* Builds an IEEE 802.2 LLC header.
|
424
|
+
* @param dsap destination service access point
|
425
|
+
* @param ssap source service access point
|
426
|
+
* @param control control field
|
427
|
+
* @param payload optional payload or NULL
|
428
|
+
* @param payload_s payload length or 0
|
429
|
+
* @param l pointer to a libnet context
|
430
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
431
|
+
* @return protocol tag value on success, -1 on error
|
432
|
+
*/
|
433
|
+
libnet_ptag_t
|
434
|
+
libnet_build_802_2(u_int8_t dsap, u_int8_t ssap, u_int8_t control,
|
435
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Builds an IEEE 802.2 LLC SNAP header.
|
439
|
+
* @param dsap destination service access point
|
440
|
+
* @param ssap source service access point
|
441
|
+
* @param control control field
|
442
|
+
* @param oui Organizationally Unique Identifier
|
443
|
+
* @param type upper layer protocol
|
444
|
+
* @param payload optional payload or NULL
|
445
|
+
* @param payload_s payload length or 0
|
446
|
+
* @param l pointer to a libnet context
|
447
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
448
|
+
* @return protocol tag value on success, -1 on error
|
449
|
+
*/
|
450
|
+
libnet_ptag_t
|
451
|
+
libnet_build_802_2snap(u_int8_t dsap, u_int8_t ssap, u_int8_t control,
|
452
|
+
u_int8_t *oui, u_int16_t type, u_int8_t *payload, u_int32_t payload_s,
|
453
|
+
libnet_t *l, libnet_ptag_t ptag);
|
454
|
+
|
455
|
+
/**
|
456
|
+
* Builds an IEEE 802.3 header. The 802.3 header is almost identical to the
|
457
|
+
* RFC 894 Ethernet II header, the exception being that the field immediately
|
458
|
+
* following the source address holds the frame's length (as opposed to the
|
459
|
+
* layer 3 protocol). You should only use this function when libnet is
|
460
|
+
* initialized with the LIBNET_LINK interface.
|
461
|
+
* @param dst destination ethernet address
|
462
|
+
* @param src source ethernet address
|
463
|
+
* @param len frame length sans header
|
464
|
+
* @param payload optional payload or NULL
|
465
|
+
* @param payload_s payload length or 0
|
466
|
+
* @param l pointer to a libnet context
|
467
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
468
|
+
* @return protocol tag value on success, -1 on error
|
469
|
+
*/
|
470
|
+
libnet_ptag_t
|
471
|
+
libnet_build_802_3(u_int8_t *dst, u_int8_t *src, u_int16_t len,
|
472
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
473
|
+
|
474
|
+
/**
|
475
|
+
* Builds an Ethernet header. The RFC 894 Ethernet II header is almost
|
476
|
+
* identical to the IEEE 802.3 header, with the exception that the field
|
477
|
+
* immediately following the source address holds the layer 3 protocol (as
|
478
|
+
* opposed to frame's length). You should only use this function when
|
479
|
+
* libnet is initialized with the LIBNET_LINK interface.
|
480
|
+
* @param dst destination ethernet address
|
481
|
+
* @param src source ethernet address
|
482
|
+
* @param type upper layer protocol type
|
483
|
+
* @param payload optional payload or NULL
|
484
|
+
* @param payload_s payload length or 0
|
485
|
+
* @param l pointer to a libnet context
|
486
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
487
|
+
* @return protocol tag value on success, -1 on error
|
488
|
+
*/
|
489
|
+
libnet_ptag_t
|
490
|
+
libnet_build_ethernet(u_int8_t *dst, u_int8_t *src, u_int16_t type,
|
491
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
492
|
+
|
493
|
+
/**
|
494
|
+
* Autobuilds an Ethernet header. The RFC 894 Ethernet II header is almost
|
495
|
+
* identical to the IEEE 802.3 header, with the exception that the field
|
496
|
+
* immediately following the source address holds the layer 3 protocol (as
|
497
|
+
* opposed to frame's length). You should only use this function when
|
498
|
+
* libnet is initialized with the LIBNET_LINK interface.
|
499
|
+
* @param dst destination ethernet address
|
500
|
+
* @param type upper layer protocol type
|
501
|
+
* @param l pointer to a libnet context
|
502
|
+
* @return protocol tag value on success, -1 on error
|
503
|
+
*/
|
504
|
+
libnet_ptag_t
|
505
|
+
libnet_autobuild_ethernet(u_int8_t *dst, u_int16_t type, libnet_t *l);
|
506
|
+
|
507
|
+
/**
|
508
|
+
* Builds a Fiber Distributed Data Interface (FDDI) header.
|
509
|
+
* @param fc class format and priority
|
510
|
+
* @oaram dst destination fddi address
|
511
|
+
* @oaram src source fddi address
|
512
|
+
* @param dsap destination service access point
|
513
|
+
* @param ssap source service access point
|
514
|
+
* @param cf cf
|
515
|
+
* @param oui 3 byte IEEE organizational code
|
516
|
+
* @param type upper layer protocol
|
517
|
+
* @param payload optional payload or NULL
|
518
|
+
* @param payload_s payload length or 0
|
519
|
+
* @param l pointer to a libnet context
|
520
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
521
|
+
* @return protocol tag value on success, -1 on error
|
522
|
+
*/
|
523
|
+
libnet_ptag_t
|
524
|
+
libnet_build_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t *src, u_int8_t dsap,
|
525
|
+
u_int8_t ssap, u_int8_t cf, u_int8_t *oui, u_int16_t type, u_int8_t *payload,
|
526
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
527
|
+
|
528
|
+
/**
|
529
|
+
* Autobuilds a Fiber Distributed Data Interface (FDDI) header.
|
530
|
+
* @param fc class format and priority
|
531
|
+
* @oaram dst destination fddi address
|
532
|
+
* @param dsap destination service access point
|
533
|
+
* @param ssap source service access point
|
534
|
+
* @param cf cf
|
535
|
+
* @param oui IEEE organizational code
|
536
|
+
* @param type upper layer protocol
|
537
|
+
* @param l pointer to a libnet context
|
538
|
+
* @return protocol tag value on success, -1 on error
|
539
|
+
*/
|
540
|
+
libnet_ptag_t
|
541
|
+
libnet_autobuild_fddi(u_int8_t fc, u_int8_t *dst, u_int8_t dsap, u_int8_t ssap,
|
542
|
+
u_int8_t cf, u_int8_t *oui, u_int16_t type, libnet_t *l);
|
543
|
+
|
544
|
+
/**
|
545
|
+
* Builds an Address Resolution Protocol (ARP) header. Depending on the op
|
546
|
+
* value, the function builds one of several different types of RFC 826 or
|
547
|
+
* RFC 903 RARP packets.
|
548
|
+
* @param hrd hardware address format
|
549
|
+
* @param pro protocol address format
|
550
|
+
* @param hln hardware address length
|
551
|
+
* @param pln protocol address length
|
552
|
+
* @param op ARP operation type
|
553
|
+
* @param sha sender's hardware address
|
554
|
+
* @param spa sender's protocol address
|
555
|
+
* @param tha target hardware address
|
556
|
+
* @param tpa targer protocol address
|
557
|
+
* @param payload optional payload or NULL
|
558
|
+
* @param payload_s payload length or 0
|
559
|
+
* @param l pointer to a libnet context
|
560
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
561
|
+
* @return protocol tag value on success, -1 on error
|
562
|
+
*/
|
563
|
+
libnet_ptag_t
|
564
|
+
libnet_build_arp(u_int16_t hrd, u_int16_t pro, u_int8_t hln, u_int8_t pln,
|
565
|
+
u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t *tha, u_int8_t *tpa,
|
566
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
567
|
+
|
568
|
+
/**
|
569
|
+
* Autouilds an Address Resolution Protocol (ARP) header. Depending on the op
|
570
|
+
* value, the function builds one of several different types of RFC 826 or
|
571
|
+
* RFC 903 RARP packets.
|
572
|
+
* @param op ARP operation type
|
573
|
+
* @param sha sender's hardware address
|
574
|
+
* @param spa sender's protocol address
|
575
|
+
* @param tha target hardware address
|
576
|
+
* @param tpa targer protocol address
|
577
|
+
* @param l pointer to a libnet context
|
578
|
+
* @return protocol tag value on success, -1 on error
|
579
|
+
*/
|
580
|
+
libnet_ptag_t
|
581
|
+
libnet_autobuild_arp(u_int16_t op, u_int8_t *sha, u_int8_t *spa, u_int8_t *tha,
|
582
|
+
u_int8_t *tpa, libnet_t *l);
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Builds an RFC 793 Transmission Control Protocol (TCP) header.
|
586
|
+
* @param sp source port
|
587
|
+
* @param dp destination port
|
588
|
+
* @param seq sequence number
|
589
|
+
* @param ack acknowledgement number
|
590
|
+
* @param control control flags
|
591
|
+
* @param win window size
|
592
|
+
* @param sum checksum (0 for libnet to autofill)
|
593
|
+
* @param urg urgent pointer
|
594
|
+
* @parama len total length of the TCP packet (for checksum calculation)
|
595
|
+
* @param payload_s payload length or 0
|
596
|
+
* @param l pointer to a libnet context
|
597
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
598
|
+
* @return protocol tag value on success, -1 on error
|
599
|
+
*/
|
600
|
+
libnet_ptag_t
|
601
|
+
libnet_build_tcp(u_int16_t sp, u_int16_t dp, u_int32_t seq, u_int32_t ack,
|
602
|
+
u_int8_t control, u_int16_t win, u_int16_t sum, u_int16_t urg, u_int16_t len,
|
603
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
604
|
+
|
605
|
+
/**
|
606
|
+
* Builds an RFC 793 Transmission Control Protocol (TCP) options header.
|
607
|
+
* The function expects options to be a valid TCP options string of size
|
608
|
+
* options_s, which is no larger than 40 bytes (the maximum size of an
|
609
|
+
* options string). The function checks to ensure that the packet consists of
|
610
|
+
* a TCP header preceded by an IPv4 header, and that the addition of the
|
611
|
+
* options string would not result in a packet larger than 65,535 bytes
|
612
|
+
* (IPMAXPACKET). The function counts up the number of 32-bit words in the
|
613
|
+
* options string and adjusts the TCP header length value as necessary.
|
614
|
+
* @param options byte string of TCP options
|
615
|
+
* @param options_s length of options string
|
616
|
+
* @param l pointer to a libnet context
|
617
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
618
|
+
* @return protocol tag value on success, -1 on error
|
619
|
+
*/
|
620
|
+
libnet_ptag_t
|
621
|
+
libnet_build_tcp_options(u_int8_t *options, u_int32_t options_s, libnet_t *l,
|
622
|
+
libnet_ptag_t ptag);
|
623
|
+
|
624
|
+
/**
|
625
|
+
* Builds an RFC 768 User Datagram Protocol (UDP) header.
|
626
|
+
* @param sp source port
|
627
|
+
* @param dp destination port
|
628
|
+
* @param len total length of the UDP packet
|
629
|
+
* @param sum checksum (0 for libnet to autofill)
|
630
|
+
* @param payload optional payload or NULL
|
631
|
+
* @param payload_s payload length or 0
|
632
|
+
* @param l pointer to a libnet context
|
633
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
634
|
+
* @return protocol tag value on success, -1 on error
|
635
|
+
*/
|
636
|
+
libnet_ptag_t
|
637
|
+
libnet_build_udp(u_int16_t sp, u_int16_t dp, u_int16_t len, u_int16_t sum,
|
638
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
639
|
+
|
640
|
+
/**
|
641
|
+
* Builds a Cisco Discovery Protocol (CDP) header. Cisco Systems designed CDP
|
642
|
+
* to aid in the network management of adjacent Cisco devices. The CDP protocol
|
643
|
+
* specifies data by using a type/length/value (TLV) setup. The first TLV can
|
644
|
+
* specified by using the functions type, length, and value arguments. To
|
645
|
+
* specify additional TLVs, the programmer could either use the payload
|
646
|
+
* interface or libnet_build_data() to construct them.
|
647
|
+
* @param version CDP version
|
648
|
+
* @param ttl time to live (time information should be cached by recipient)
|
649
|
+
* @param sum checksum (0 for libnet to autofill)
|
650
|
+
* @param type type of data contained in value
|
651
|
+
* @param len length of value arugment
|
652
|
+
* @param value the CDP information string
|
653
|
+
* @param payload optional payload or NULL
|
654
|
+
* @param payload_s payload length or 0
|
655
|
+
* @param l pointer to a libnet context
|
656
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
657
|
+
* @return protocol tag value on success, -1 on error
|
658
|
+
*/
|
659
|
+
libnet_ptag_t
|
660
|
+
libnet_build_cdp(u_int8_t version, u_int8_t ttl, u_int16_t sum, u_int16_t type,
|
661
|
+
u_int16_t len, u_int8_t *value, u_int8_t *payload, u_int32_t payload_s,
|
662
|
+
libnet_t *l, libnet_ptag_t ptag);
|
663
|
+
|
664
|
+
/**
|
665
|
+
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
|
666
|
+
* echo request/reply header
|
667
|
+
* @param type type of ICMP packet (should be ICMP_ECHOREPLY or ICMP_ECHO)
|
668
|
+
* @param code code of ICMP packet (should be 0)
|
669
|
+
* @param sum checksum (0 for libnet to autofill)
|
670
|
+
* @param id identification number
|
671
|
+
* @param seq packet sequence number
|
672
|
+
* @param payload optional payload or NULL
|
673
|
+
* @param payload_s payload length or 0
|
674
|
+
* @param l pointer to a libnet context
|
675
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
676
|
+
* @return protocol tag value on success, -1 on error
|
677
|
+
*/
|
678
|
+
libnet_ptag_t
|
679
|
+
libnet_build_icmpv4_echo(u_int8_t type, u_int8_t code, u_int16_t sum,
|
680
|
+
u_int16_t id, u_int16_t seq, u_int8_t *payload, u_int32_t payload_s,
|
681
|
+
libnet_t *l, libnet_ptag_t ptag);
|
682
|
+
|
683
|
+
/**
|
684
|
+
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
|
685
|
+
* IP netmask request/reply header.
|
686
|
+
* @param type type of ICMP packet (should be ICMP_MASKREQ or ICMP_MASKREPLY)
|
687
|
+
* @param code code of ICMP packet (should be 0)
|
688
|
+
* @param sum checksum (0 for libnet to autofill)
|
689
|
+
* @param id identification number
|
690
|
+
* @param seq packet sequence number
|
691
|
+
* @param mask subnet mask
|
692
|
+
* @param payload optional payload or NULL
|
693
|
+
* @param payload_s payload length or 0
|
694
|
+
* @param l pointer to a libnet context
|
695
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
696
|
+
* @return protocol tag value on success, -1 on error
|
697
|
+
*/
|
698
|
+
libnet_ptag_t
|
699
|
+
libnet_build_icmpv4_mask(u_int8_t type, u_int8_t code, u_int16_t sum,
|
700
|
+
u_int16_t id, u_int16_t seq, u_int32_t mask, u_int8_t *payload,
|
701
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
702
|
+
|
703
|
+
/**
|
704
|
+
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
|
705
|
+
* unreachable header. The IP header that caused the error message should be
|
706
|
+
* built by a previous call to libnet_build_ipv4().
|
707
|
+
* @param type type of ICMP packet (should be ICMP_UNREACH)
|
708
|
+
* @param code code of ICMP packet (should be one of the 16 unreachable codes)
|
709
|
+
* @param sum checksum (0 for libnet to autofill)
|
710
|
+
* @param payload optional payload or NULL
|
711
|
+
* @param payload_s payload length or 0
|
712
|
+
* @param l pointer to a libnet context
|
713
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
714
|
+
* @return protocol tag value on success, -1 on error
|
715
|
+
*/
|
716
|
+
libnet_ptag_t
|
717
|
+
libnet_build_icmpv4_unreach(u_int8_t type, u_int8_t code, u_int16_t sum,
|
718
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
719
|
+
|
720
|
+
/**
|
721
|
+
* Builds an IP version 4 RFC 792 Internet Message Control Protocol (ICMP)
|
722
|
+
* redirect header. The IP header that caused the error message should be
|
723
|
+
* built by a previous call to libnet_build_ipv4().
|
724
|
+
* @param type type of ICMP packet (should be ICMP_REDIRECT)
|
725
|
+
* @param code code of ICMP packet (should be one of the four redirect codes)
|
726
|
+
* @param sum checksum (0 for libnet to autofill)
|
727
|
+
* @param payload optional payload or NULL
|
728
|
+
* @param payload_s payload length or 0
|
729
|
+
* @param l pointer to a libnet context
|
730
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
731
|
+
* @return protocol tag value on success, -1 on error
|
732
|
+
*/
|
733
|
+
libnet_ptag_t
|
734
|
+
libnet_build_icmpv4_redirect(u_int8_t type, u_int8_t code, u_int16_t sum,
|
735
|
+
u_int32_t gateway, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
736
|
+
libnet_ptag_t ptag);
|
737
|
+
|
738
|
+
/**
|
739
|
+
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP) time
|
740
|
+
* exceeded header. The IP header that caused the error message should be
|
741
|
+
* built by a previous call to libnet_build_ipv4().
|
742
|
+
* @param type type of ICMP packet (should be ICMP_TIMXCEED)
|
743
|
+
* @param code code of ICMP packet (ICMP_TIMXCEED_INTRANS / ICMP_TIMXCEED_REASS)
|
744
|
+
* @param sum checksum (0 for libnet to autofill)
|
745
|
+
* @param payload optional payload or NULL
|
746
|
+
* @param payload optional payload or NULL
|
747
|
+
* @param payload_s payload length or 0
|
748
|
+
* @param l pointer to a libnet context
|
749
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
750
|
+
* @return protocol tag value on success, -1 on error
|
751
|
+
*/
|
752
|
+
libnet_ptag_t
|
753
|
+
libnet_build_icmpv4_timeexceed(u_int8_t type, u_int8_t code, u_int16_t sum,
|
754
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
755
|
+
|
756
|
+
/**
|
757
|
+
* Builds an IP version 4 RFC 792 Internet Control Message Protocol (ICMP)
|
758
|
+
* timestamp request/reply header.
|
759
|
+
* @param type type of ICMP packet (should be ICMP_TSTAMP or ICMP_TSTAMPREPLY)
|
760
|
+
* @param code code of ICMP packet (should be 0)
|
761
|
+
* @param sum checksum (0 for libnet to autofill)
|
762
|
+
* @param id identification number
|
763
|
+
* @param seq sequence number
|
764
|
+
* @param otime originate timestamp
|
765
|
+
* @param rtime receive timestamp
|
766
|
+
* @param ttime transmit timestamp
|
767
|
+
* @param payload optional payload or NULL
|
768
|
+
* @param payload_s payload length or 0
|
769
|
+
* @param l pointer to a libnet context
|
770
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
771
|
+
* @return protocol tag value on success, -1 on error
|
772
|
+
*/
|
773
|
+
libnet_ptag_t
|
774
|
+
libnet_build_icmpv4_timestamp(u_int8_t type, u_int8_t code, u_int16_t sum,
|
775
|
+
u_int16_t id, u_int16_t seq, n_time otime, n_time rtime, n_time ttime,
|
776
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
777
|
+
|
778
|
+
/**
|
779
|
+
* Builds an RFC 1112 Internet Group Memebership Protocol (IGMP) header.
|
780
|
+
* @param type packet type
|
781
|
+
* @param code packet code (should be 0)
|
782
|
+
* @param sum checksum (0 for libnet to autofill)
|
783
|
+
* @param ip IPv4 address
|
784
|
+
* @param payload optional payload or NULL
|
785
|
+
* @param payload_s payload length or 0
|
786
|
+
* @param l pointer to a libnet context
|
787
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
788
|
+
* @return protocol tag value on success, -1 on error
|
789
|
+
*/
|
790
|
+
libnet_ptag_t
|
791
|
+
libnet_build_igmp(u_int8_t type, u_int8_t code, u_int16_t sum, u_int32_t ip,
|
792
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
793
|
+
|
794
|
+
/**
|
795
|
+
* Builds a version 4 RFC 791 Internet Protocol (IP) header.
|
796
|
+
* @param len total length of the IP packet including all subsequent data
|
797
|
+
* @param tos type of service bits
|
798
|
+
* @param id IP identification number
|
799
|
+
* @param frag fragmentation bits and offset
|
800
|
+
* @param ttl time to live in the network
|
801
|
+
* @param prot upper layer protocol
|
802
|
+
* @param sum checksum (0 for libnet to autofill)
|
803
|
+
* @param src source IPv4 address (little endian)
|
804
|
+
* @param dst destination IPv4 address (little endian)
|
805
|
+
* @param payload optional payload or NULL
|
806
|
+
* @param payload_s payload length or 0
|
807
|
+
* @param l pointer to a libnet context
|
808
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
809
|
+
* @return protocol tag value on success, -1 on error
|
810
|
+
*/
|
811
|
+
libnet_ptag_t
|
812
|
+
libnet_build_ipv4(u_int16_t len, u_int8_t tos, u_int16_t id, u_int16_t frag,
|
813
|
+
u_int8_t ttl, u_int8_t prot, u_int16_t sum, u_int32_t src, u_int32_t dst,
|
814
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
815
|
+
|
816
|
+
/**
|
817
|
+
* Builds an version 4 Internet Protocol (IP) options header. The function
|
818
|
+
* expects options to be a valid IP options string of size options_s, no larger
|
819
|
+
* than 40 bytes (the maximum size of an options string). The function checks
|
820
|
+
* to make sure that the preceding header is an IPv4 header and that the
|
821
|
+
* options string would not result in a packet larger than 65,535 bytes
|
822
|
+
* (IPMAXPACKET). The function counts up the number of 32-bit words in the
|
823
|
+
* options string and adjusts the IP header length value as necessary.
|
824
|
+
* @param options byte string of IP options
|
825
|
+
* @param options_s length of options string
|
826
|
+
* @param l pointer to a libnet context
|
827
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
828
|
+
* @return protocol tag value on success, -1 on error
|
829
|
+
*/
|
830
|
+
libnet_ptag_t
|
831
|
+
libnet_build_ipv4_options(u_int8_t *options, u_int32_t options_s, libnet_t *l,
|
832
|
+
libnet_ptag_t ptag);
|
833
|
+
|
834
|
+
/**
|
835
|
+
* Autobuilds a version 4 Internet Protocol (IP) header. The function is useful * to build an IP header quickly when you do not need a granular level of
|
836
|
+
* control. The function takes the same len, prot, and dst arguments as
|
837
|
+
* libnet_build_ipv4(). The function does not accept a ptag argument, but it
|
838
|
+
* does return a ptag. In other words, you can use it to build a new IP header
|
839
|
+
* but not to modify an existing one.
|
840
|
+
* @param len total length of the IP packet including all subsequent data
|
841
|
+
* @param prot upper layer protocol
|
842
|
+
* @param dst destination IPv4 address (little endian)
|
843
|
+
* @param l pointer to a libnet context
|
844
|
+
* @return protocol tag value on success, -1 on error
|
845
|
+
*/
|
846
|
+
libnet_ptag_t
|
847
|
+
libnet_autobuild_ipv4(u_int16_t len, u_int8_t prot, u_int32_t dst, libnet_t *l);
|
848
|
+
|
849
|
+
/**
|
850
|
+
* Builds a version 6 RFC 2460 Internet Protocol (IP) header.
|
851
|
+
* @param tc traffic class
|
852
|
+
* @param fl flow label
|
853
|
+
* @param len total length of the IP packet
|
854
|
+
* @param nh next header
|
855
|
+
* @param hl hop limit
|
856
|
+
* @param src source IPv6 address
|
857
|
+
* @param dst destination IPv6 address
|
858
|
+
* @param payload optional payload or NULL
|
859
|
+
* @param payload_s payload length or 0
|
860
|
+
* @param l pointer to a libnet context
|
861
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
862
|
+
* @return protocol tag value on success, -1 on error
|
863
|
+
*/
|
864
|
+
libnet_ptag_t
|
865
|
+
libnet_build_ipv6(u_int8_t tc, u_int32_t fl, u_int16_t len, u_int8_t nh,
|
866
|
+
u_int8_t hl, struct libnet_in6_addr src, struct libnet_in6_addr dst,
|
867
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
868
|
+
|
869
|
+
/**
|
870
|
+
* Builds a version 6 RFC 2460 Internet Protocol (IP) fragmentation header.
|
871
|
+
* @param nh next header
|
872
|
+
* @param reserved unused value... OR IS IT!
|
873
|
+
* @param frag fragmentation bits (ala ipv4)
|
874
|
+
* @param id packet identification
|
875
|
+
* @param payload optional payload or NULL
|
876
|
+
* @param payload_s payload length or 0
|
877
|
+
* @param l pointer to a libnet context
|
878
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
879
|
+
* @return protocol tag value on success, -1 on error
|
880
|
+
*/
|
881
|
+
libnet_ptag_t
|
882
|
+
libnet_build_ipv6_frag(u_int8_t nh, u_int8_t reserved, u_int16_t frag,
|
883
|
+
u_int32_t id, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
884
|
+
libnet_ptag_t ptag);
|
885
|
+
|
886
|
+
/**
|
887
|
+
* Builds a version 6 RFC 2460 Internet Protocol (IP) routing header. This
|
888
|
+
* function is special in that it uses the payload interface to include the
|
889
|
+
* "type-specific data"; that is the routing information. Most often this will
|
890
|
+
* be a number of 128-bit IPv6 addresses. The application programmer will build
|
891
|
+
* a byte string of IPv6 address and pass them to the function using the
|
892
|
+
* payload interface.
|
893
|
+
* @param nh next header
|
894
|
+
* @param len length of the header in 8-byte octets not including the first 8 octets
|
895
|
+
* @rtype routing header type
|
896
|
+
* @param segments number of routing segments that follow
|
897
|
+
* @param payload optional payload of routing information
|
898
|
+
* @param payload_s payload length
|
899
|
+
* @param l pointer to a libnet context
|
900
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
901
|
+
* @return protocol tag value on success, -1 on error
|
902
|
+
*/
|
903
|
+
libnet_ptag_t
|
904
|
+
libnet_build_ipv6_routing(u_int8_t nh, u_int8_t len, u_int8_t rtype,
|
905
|
+
u_int8_t segments, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
906
|
+
libnet_ptag_t ptag);
|
907
|
+
|
908
|
+
/**
|
909
|
+
* Builds a version 6 RFC 2460 Internet Protocol (IP) destination options
|
910
|
+
* header. This function is special in that it uses the payload interface to
|
911
|
+
* include the options data. The application programmer will build an IPv6
|
912
|
+
* options byte string and pass it to the function using the payload interface.
|
913
|
+
* @param nh next header
|
914
|
+
* @param len length of the header in 8-byte octets not including the first 8 octets
|
915
|
+
* @param payload options payload
|
916
|
+
* @param payload_s payload length
|
917
|
+
* @param l pointer to a libnet context
|
918
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
919
|
+
* @return protocol tag value on success, -1 on error
|
920
|
+
*/
|
921
|
+
libnet_ptag_t
|
922
|
+
libnet_build_ipv6_destopts(u_int8_t nh, u_int8_t len, u_int8_t *payload,
|
923
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
924
|
+
|
925
|
+
/**
|
926
|
+
* Builds a version 6 RFC 2460 Internet Protocol (IP) hop by hop options
|
927
|
+
* header. This function is special in that it uses the payload interface to
|
928
|
+
* include the options data. The application programmer will build an IPv6
|
929
|
+
* hop by hop options byte string and pass it to the function using the payload
|
930
|
+
* interface.
|
931
|
+
* @param nh next header
|
932
|
+
* @param len length of the header in 8-byte octets not including the first 8 octets
|
933
|
+
* @param payload options payload
|
934
|
+
* @param payload_s payload length
|
935
|
+
* @param l pointer to a libnet context
|
936
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
937
|
+
* @return protocol tag value on success, -1 on error
|
938
|
+
*/
|
939
|
+
libnet_ptag_t
|
940
|
+
libnet_build_ipv6_hbhopts(u_int8_t nh, u_int8_t len, u_int8_t *payload,
|
941
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
942
|
+
|
943
|
+
/**
|
944
|
+
* This function is not yet implement and is a NONOP.
|
945
|
+
* @param len length
|
946
|
+
* @param nh next header
|
947
|
+
* @param dst destination IPv6 address
|
948
|
+
* @param payload optional payload or NULL
|
949
|
+
* @param payload_s payload length or 0
|
950
|
+
* @param l pointer to a libnet context
|
951
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
952
|
+
* @return protocol tag value on success, -1 on error
|
953
|
+
*/
|
954
|
+
libnet_ptag_t
|
955
|
+
libnet_autobuild_ipv6(u_int16_t len, u_int8_t nh, struct libnet_in6_addr dst,
|
956
|
+
libnet_t *l);
|
957
|
+
|
958
|
+
/**
|
959
|
+
* Builds a Cisco Inter-Switch Link (ISL) header.
|
960
|
+
* @param dhost destination address (should be 01:00:0c:00:00)
|
961
|
+
* @param type type of frame
|
962
|
+
* @param user user defined data
|
963
|
+
* @param shost source mac address
|
964
|
+
* @param len total length of the encapuslated packet less 18 bytes
|
965
|
+
* @param snap SNAP information (0xaaaa03 + vendor code)
|
966
|
+
* @param vid 15 bit VLAN ID, 1 bit BPDU or CDP indicator
|
967
|
+
* @param index port index
|
968
|
+
* @param reserved used for FDDI and token ring
|
969
|
+
* @param payload optional payload or NULL
|
970
|
+
* @param payload_s payload length or 0
|
971
|
+
* @param l pointer to a libnet context
|
972
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
973
|
+
* @return protocol tag value on success, -1 on error
|
974
|
+
*/
|
975
|
+
libnet_ptag_t
|
976
|
+
libnet_build_isl(u_int8_t *dhost, u_int8_t type, u_int8_t user, u_int8_t *shost,
|
977
|
+
u_int16_t len, u_int8_t *snap, u_int16_t vid, u_int16_t index,
|
978
|
+
u_int16_t reserved, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
979
|
+
libnet_ptag_t ptag);
|
980
|
+
|
981
|
+
/**
|
982
|
+
* Builds an Internet Protocol Security Encapsulating Security Payload header.
|
983
|
+
* @param spi security parameter index
|
984
|
+
* @param seq ESP sequence number
|
985
|
+
* @param iv initialization vector
|
986
|
+
* @param payload optional payload or NULL
|
987
|
+
* @param payload_s payload length or 0
|
988
|
+
* @param l pointer to a libnet context
|
989
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
990
|
+
* @return protocol tag value on success, -1 on error
|
991
|
+
*/
|
992
|
+
libnet_ptag_t
|
993
|
+
libnet_build_ipsec_esp_hdr(u_int32_t spi, u_int32_t seq, u_int32_t iv,
|
994
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
995
|
+
|
996
|
+
/**
|
997
|
+
* Builds an Internet Protocol Security Encapsulating Security Payload footer.
|
998
|
+
* @param len padding length
|
999
|
+
* @param nh next header
|
1000
|
+
* @param auth authentication data
|
1001
|
+
* @param payload optional payload or NULL
|
1002
|
+
* @param payload_s payload length or 0
|
1003
|
+
* @param l pointer to a libnet context
|
1004
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1005
|
+
* @return protocol tag value on success, -1 on error
|
1006
|
+
*/
|
1007
|
+
libnet_ptag_t
|
1008
|
+
libnet_build_ipsec_esp_ftr(u_int8_t len, u_int8_t nh, int8_t *auth,
|
1009
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1010
|
+
|
1011
|
+
/**
|
1012
|
+
* Builds an Internet Protocol Security Authentication header.
|
1013
|
+
* @param nh next header
|
1014
|
+
* @param len payload length
|
1015
|
+
* @param res reserved
|
1016
|
+
* @param spi security parameter index
|
1017
|
+
* @param seq sequence number
|
1018
|
+
* @param auth authentication data
|
1019
|
+
* @param payload optional payload or NULL
|
1020
|
+
* @param payload_s payload length or 0
|
1021
|
+
* @param l pointer to a libnet context
|
1022
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1023
|
+
* @return protocol tag value on success, -1 on error
|
1024
|
+
*/
|
1025
|
+
libnet_ptag_t
|
1026
|
+
libnet_build_ipsec_ah(u_int8_t nh, u_int8_t len, u_int16_t res,
|
1027
|
+
u_int32_t spi, u_int32_t seq, u_int32_t auth, u_int8_t *payload,
|
1028
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1029
|
+
|
1030
|
+
/**
|
1031
|
+
* Builds an RFC 1035 version 4 DNS header. Additional DNS payload information
|
1032
|
+
* should be specified using the payload interface.
|
1033
|
+
* @param id DNS packet id
|
1034
|
+
* @param flags control flags
|
1035
|
+
* @param num_q number of questions
|
1036
|
+
* @param num_anws_rr number of answer resource records
|
1037
|
+
* @param num_auth_rr number of authority resource records
|
1038
|
+
* @param num_addi_rr number of additional resource records
|
1039
|
+
* @param payload optional payload or NULL
|
1040
|
+
* @param payload_s payload length or 0
|
1041
|
+
* @param l pointer to a libnet context
|
1042
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1043
|
+
* @return protocol tag value on success, -1 on error
|
1044
|
+
*/
|
1045
|
+
libnet_ptag_t
|
1046
|
+
libnet_build_dnsv4(u_int16_t h_len, u_int16_t id, u_int16_t flags,
|
1047
|
+
u_int16_t num_q, u_int16_t num_anws_rr, u_int16_t num_auth_rr,
|
1048
|
+
u_int16_t num_addi_rr, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1049
|
+
libnet_ptag_t ptag);
|
1050
|
+
|
1051
|
+
/**
|
1052
|
+
* Builds a Routing Information Protocol header (RFCs 1058 and 2453).
|
1053
|
+
* @param cmd command
|
1054
|
+
* @param version protocol version
|
1055
|
+
* @param rd version one: 0, version two: routing domain
|
1056
|
+
* @param af address family
|
1057
|
+
* @param rt version one: 0, version two: route tag
|
1058
|
+
* @param addr IPv4 address
|
1059
|
+
* @param mask version one: 0, version two: subnet mask
|
1060
|
+
* @param next_hop version one: 0, version two: next hop address
|
1061
|
+
* @param metric routing metric
|
1062
|
+
* @param payload optional payload or NULL
|
1063
|
+
* @param payload_s payload length or 0
|
1064
|
+
* @param l pointer to a libnet context
|
1065
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1066
|
+
* @return protocol tag value on success, -1 on error
|
1067
|
+
*/
|
1068
|
+
libnet_ptag_t
|
1069
|
+
libnet_build_rip(u_int8_t cmd, u_int8_t version, u_int16_t rd, u_int16_t af,
|
1070
|
+
u_int16_t rt, u_int32_t addr, u_int32_t mask, u_int32_t next_hop,
|
1071
|
+
u_int32_t metric, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1072
|
+
libnet_ptag_t ptag);
|
1073
|
+
|
1074
|
+
/**
|
1075
|
+
* Builds an Remote Procedure Call (Version 2) Call message header as
|
1076
|
+
* specified in RFC 1831. This builder provides the option for
|
1077
|
+
* specifying the record marking which is required when used with
|
1078
|
+
* streaming protocols (TCP).
|
1079
|
+
* @param rm record marking indicating the position in a stream, 0 otherwise
|
1080
|
+
* @param xid transaction identifier used to link calls and replies
|
1081
|
+
* @param prog_num remote program specification typically between 0 - 1fffffff
|
1082
|
+
* @param prog_vers remote program version specification
|
1083
|
+
* @param procedure procedure to be performed by remote program
|
1084
|
+
* @param cflavor authentication credential type
|
1085
|
+
* @param clength credential length (should be 0)
|
1086
|
+
* @param cdata opaque credential data (currently unused)
|
1087
|
+
* @param vflavor authentication verifier type
|
1088
|
+
* @param vlength verifier length (should be 0)
|
1089
|
+
* @param vdata opaque verifier data (currently unused)
|
1090
|
+
* @param payload optional payload or NULL
|
1091
|
+
* @param payload_s payload length or 0
|
1092
|
+
* @param l pointer to a libnet context
|
1093
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1094
|
+
* @return protocol tag value on success, -1 on error
|
1095
|
+
*/
|
1096
|
+
libnet_ptag_t
|
1097
|
+
libnet_build_rpc_call(u_int32_t rm, u_int32_t xid, u_int32_t prog_num,
|
1098
|
+
u_int32_t prog_vers, u_int32_t procedure, u_int32_t cflavor, u_int32_t clength,
|
1099
|
+
u_int8_t *cdata, u_int32_t vflavor, u_int32_t vlength, u_int8_t *vdata,
|
1100
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1101
|
+
|
1102
|
+
/**
|
1103
|
+
* Builds an IEEE 802.1d Spanning Tree Protocol (STP) configuration header.
|
1104
|
+
* STP frames are usually encapsulated inside of an 802.2 + 802.3 frame
|
1105
|
+
* combination.
|
1106
|
+
* @param id protocol id
|
1107
|
+
* @param version protocol version
|
1108
|
+
* @param bpdu_type bridge protocol data unit type
|
1109
|
+
* @param flags flags
|
1110
|
+
* @param root_id root id
|
1111
|
+
* @param root_pc root path cost
|
1112
|
+
* @param bridge_id bridge id
|
1113
|
+
* @param port_id port id
|
1114
|
+
* @param message_age message age
|
1115
|
+
* @param max_age max age
|
1116
|
+
* @param hello_time hello time
|
1117
|
+
* @param f_delay forward delay
|
1118
|
+
* @param payload optional payload or NULL
|
1119
|
+
* @param payload_s payload length or 0
|
1120
|
+
* @param l pointer to a libnet context
|
1121
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1122
|
+
* @return protocol tag value on success, -1 on error
|
1123
|
+
*/
|
1124
|
+
libnet_ptag_t
|
1125
|
+
libnet_build_stp_conf(u_int16_t id, u_int8_t version, u_int8_t bpdu_type,
|
1126
|
+
u_int8_t flags, u_int8_t *root_id, u_int32_t root_pc, u_int8_t *bridge_id,
|
1127
|
+
u_int16_t port_id, u_int16_t message_age, u_int16_t max_age,
|
1128
|
+
u_int16_t hello_time, u_int16_t f_delay, u_int8_t *payload,
|
1129
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1130
|
+
|
1131
|
+
/**
|
1132
|
+
* Builds an IEEE 802.1d Spanning Tree Protocol (STP) topology change
|
1133
|
+
* notification header. STP frames are usually encapsulated inside of an
|
1134
|
+
* 802.2 + 802.3 frame combination.
|
1135
|
+
* @param id protocol id
|
1136
|
+
* @param version protocol version
|
1137
|
+
* @param bpdu_type bridge protocol data unit type
|
1138
|
+
* @param payload optional payload or NULL
|
1139
|
+
* @param payload_s payload length or 0
|
1140
|
+
* @param l pointer to a libnet context
|
1141
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1142
|
+
* @return protocol tag value on success, -1 on error
|
1143
|
+
*/
|
1144
|
+
libnet_ptag_t
|
1145
|
+
libnet_build_stp_tcn(u_int16_t id, u_int8_t version, u_int8_t bpdu_type,
|
1146
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1147
|
+
|
1148
|
+
/**
|
1149
|
+
* Builds a token ring header.
|
1150
|
+
* @param ac access control
|
1151
|
+
* @param fc frame control
|
1152
|
+
* @param dst destination address
|
1153
|
+
* @param src source address
|
1154
|
+
* @param dsap destination service access point
|
1155
|
+
* @param ssap source service access point
|
1156
|
+
* @param cf control field
|
1157
|
+
* @param oui Organizationally Unique Identifier
|
1158
|
+
* @param type upper layer protocol type
|
1159
|
+
* @param payload optional payload or NULL
|
1160
|
+
* @param payload_s payload length or 0
|
1161
|
+
* @param l pointer to a libnet context
|
1162
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1163
|
+
* @return protocol tag value on success, -1 on error
|
1164
|
+
*/
|
1165
|
+
libnet_ptag_t
|
1166
|
+
libnet_build_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst, u_int8_t *src,
|
1167
|
+
u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *oui, u_int16_t type,
|
1168
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1169
|
+
|
1170
|
+
/**
|
1171
|
+
* Auto-builds a token ring header.
|
1172
|
+
* @param ac access control
|
1173
|
+
* @param fc frame control
|
1174
|
+
* @param dst destination address
|
1175
|
+
* @param dsap destination service access point
|
1176
|
+
* @param ssap source service access point
|
1177
|
+
* @param cf control field
|
1178
|
+
* @param oui Organizationally Unique Identifier
|
1179
|
+
* @param type upper layer protocol type
|
1180
|
+
* @param l pointer to a libnet context
|
1181
|
+
* @return protocol tag value on success, -1 on error
|
1182
|
+
*/
|
1183
|
+
libnet_ptag_t
|
1184
|
+
libnet_autobuild_token_ring(u_int8_t ac, u_int8_t fc, u_int8_t *dst,
|
1185
|
+
u_int8_t dsap, u_int8_t ssap, u_int8_t cf, u_int8_t *oui, u_int16_t type,
|
1186
|
+
libnet_t *l);
|
1187
|
+
|
1188
|
+
/**
|
1189
|
+
* Builds an RFC 2338 Virtual Router Redundacy Protool (VRRP) header. Use the
|
1190
|
+
* payload interface to specify address and autthentication information. To
|
1191
|
+
* build a "legal" packet, the destination IPv4 address should be the multicast * address 224.0.0.18, the IP TTL should be set to 255, and the IP protocol
|
1192
|
+
* should be set to 112.
|
1193
|
+
* @param version VRRP version (should be 2)
|
1194
|
+
* @param type VRRP packet type (should be 1 -- ADVERTISEMENT)
|
1195
|
+
* @param vrouter_id virtual router identification
|
1196
|
+
* @param priority priority (higher numbers indicate higher priority)
|
1197
|
+
* @param ip_count number of IPv4 addresses contained in this advertisement
|
1198
|
+
* @param auth_type type of authentication (0, 1, 2 -- see RFC)
|
1199
|
+
* @param advert_int interval between advertisements
|
1200
|
+
* @param sum checksum (0 for libnet to autofill)
|
1201
|
+
* @param payload optional payload or NULL
|
1202
|
+
* @param payload_s payload length or 0
|
1203
|
+
* @param l pointer to a libnet context
|
1204
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1205
|
+
* @return protocol tag value on success, -1 on error
|
1206
|
+
*/
|
1207
|
+
libnet_ptag_t
|
1208
|
+
libnet_build_vrrp(u_int8_t version, u_int8_t type, u_int8_t vrouter_id,
|
1209
|
+
u_int8_t priority, u_int8_t ip_count, u_int8_t auth_type, u_int8_t advert_int,
|
1210
|
+
u_int16_t sum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1211
|
+
libnet_ptag_t ptag);
|
1212
|
+
|
1213
|
+
/**
|
1214
|
+
* Builds an RFC 3032 Multi-Protocol Label Switching (MPLS) header.
|
1215
|
+
* @param label 20-bit label value
|
1216
|
+
* @param experimental 3-bit reserved field
|
1217
|
+
* @param bos 1-bit bottom of stack identifier
|
1218
|
+
* @param ttl time to live
|
1219
|
+
* @param payload optional payload or NULL
|
1220
|
+
* @param payload_s payload length or 0
|
1221
|
+
* @param l pointer to a libnet context
|
1222
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1223
|
+
* @return protocol tag value on success, -1 on error
|
1224
|
+
*/
|
1225
|
+
libnet_ptag_t
|
1226
|
+
libnet_build_mpls(u_int32_t label, u_int8_t experimental, u_int8_t bos,
|
1227
|
+
u_int8_t ttl, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1228
|
+
libnet_ptag_t ptag);
|
1229
|
+
|
1230
|
+
/**
|
1231
|
+
* Builds an RFC 958 Network Time Protocol (NTP) header.
|
1232
|
+
* @param leap_indicator the leap indicator
|
1233
|
+
* @param version NTP protocol version
|
1234
|
+
* @param mode NTP mode
|
1235
|
+
* @param stratum stratum
|
1236
|
+
* @param poll polling interval
|
1237
|
+
* @param precision precision
|
1238
|
+
* @param delay_interval delay interval
|
1239
|
+
* @param delay_frac delay fraction
|
1240
|
+
* @param dispersion_int dispersion interval
|
1241
|
+
* @param dispersion_frac dispersion fraction
|
1242
|
+
* @param reference_id reference id
|
1243
|
+
* @param ref_ts_int reference timestamp integer
|
1244
|
+
* @param ref_ts_frac reference timestamp fraction
|
1245
|
+
* @param orig_ts_int original timestamp integer
|
1246
|
+
* @param orig_ts_frac original timestamp fraction
|
1247
|
+
* @param rec_ts_int receiver timestamp integer
|
1248
|
+
* @param rec_ts_frac reciever timestamp fraction
|
1249
|
+
* @param xmt_ts_int transmit timestamp integer
|
1250
|
+
* @param xmt_ts_frac transmit timestamp integer
|
1251
|
+
* @param payload optional payload or NULL
|
1252
|
+
* @param payload_s payload length or 0
|
1253
|
+
* @param l pointer to a libnet context
|
1254
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1255
|
+
* @return protocol tag value on success, -1 on error
|
1256
|
+
*/
|
1257
|
+
libnet_ptag_t
|
1258
|
+
libnet_build_ntp(u_int8_t leap_indicator, u_int8_t version, u_int8_t mode,
|
1259
|
+
u_int8_t stratum, u_int8_t poll, u_int8_t precision, u_int16_t delay_int,
|
1260
|
+
u_int16_t delay_frac, u_int16_t dispersion_int, u_int16_t dispersion_frac,
|
1261
|
+
u_int32_t reference_id, u_int32_t ref_ts_int, u_int32_t ref_ts_frac,
|
1262
|
+
u_int32_t orig_ts_int, u_int32_t orig_ts_frac, u_int32_t rec_ts_int,
|
1263
|
+
u_int32_t rec_ts_frac, u_int32_t xmt_ts_int, u_int32_t xmt_ts_frac,
|
1264
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1265
|
+
|
1266
|
+
/**
|
1267
|
+
* @param payload optional payload or NULL
|
1268
|
+
* @param payload_s payload length or 0
|
1269
|
+
* @param l pointer to a libnet context
|
1270
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1271
|
+
* @return protocol tag value on success, -1 on error
|
1272
|
+
*/
|
1273
|
+
libnet_ptag_t
|
1274
|
+
libnet_build_ospfv2(u_int16_t len, u_int8_t type, u_int32_t rtr_id,
|
1275
|
+
u_int32_t area_id, u_int16_t sum, u_int16_t autype, u_int8_t *payload,
|
1276
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1277
|
+
|
1278
|
+
/**
|
1279
|
+
* @param payload optional payload or NULL
|
1280
|
+
* @param payload_s payload length or 0
|
1281
|
+
* @param l pointer to a libnet context
|
1282
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1283
|
+
* @return protocol tag value on success, -1 on error
|
1284
|
+
*/
|
1285
|
+
libnet_ptag_t
|
1286
|
+
libnet_build_ospfv2_hello(u_int32_t netmask, u_int16_t interval, u_int8_t opts,
|
1287
|
+
u_int8_t priority, u_int dead_int, u_int32_t des_rtr, u_int32_t bkup_rtr,
|
1288
|
+
u_int32_t neighbor, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1289
|
+
libnet_ptag_t ptag);
|
1290
|
+
|
1291
|
+
/**
|
1292
|
+
* @param payload optional payload or NULL
|
1293
|
+
* @param payload_s payload length or 0
|
1294
|
+
* @param l pointer to a libnet context
|
1295
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1296
|
+
* @return protocol tag value on success, -1 on error
|
1297
|
+
*/
|
1298
|
+
libnet_ptag_t
|
1299
|
+
libnet_build_ospfv2_dbd(u_int16_t dgram_len, u_int8_t opts, u_int8_t type,
|
1300
|
+
u_int seqnum, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1301
|
+
libnet_ptag_t ptag);
|
1302
|
+
|
1303
|
+
/**
|
1304
|
+
* @param payload optional payload or NULL
|
1305
|
+
* @param payload_s payload length or 0
|
1306
|
+
* @param l pointer to a libnet context
|
1307
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1308
|
+
* @return protocol tag value on success, -1 on error
|
1309
|
+
*/
|
1310
|
+
libnet_ptag_t
|
1311
|
+
libnet_build_ospfv2_lsr(u_int type, u_int lsid, u_int32_t advrtr,
|
1312
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1313
|
+
|
1314
|
+
/**
|
1315
|
+
* @param payload optional payload or NULL
|
1316
|
+
* @param payload_s payload length or 0
|
1317
|
+
* @param l pointer to a libnet context
|
1318
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1319
|
+
* @return protocol tag value on success, -1 on error
|
1320
|
+
*/
|
1321
|
+
libnet_ptag_t
|
1322
|
+
libnet_build_ospfv2_lsu(u_int num, u_int8_t *payload, u_int32_t payload_s,
|
1323
|
+
libnet_t *l, libnet_ptag_t ptag);
|
1324
|
+
|
1325
|
+
/**
|
1326
|
+
* @param payload optional payload or NULL
|
1327
|
+
* @param payload_s payload length or 0
|
1328
|
+
* @param l pointer to a libnet context
|
1329
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1330
|
+
* @return protocol tag value on success, -1 on error
|
1331
|
+
*/
|
1332
|
+
libnet_ptag_t
|
1333
|
+
libnet_build_ospfv2_lsa(u_int16_t age, u_int8_t opts, u_int8_t type,
|
1334
|
+
u_int lsid, u_int32_t advrtr, u_int seqnum, u_int16_t sum, u_int16_t len,
|
1335
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1336
|
+
|
1337
|
+
/**
|
1338
|
+
* @param payload optional payload or NULL
|
1339
|
+
* @param payload_s payload length or 0
|
1340
|
+
* @param l pointer to a libnet context
|
1341
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1342
|
+
* @return protocol tag value on success, -1 on error
|
1343
|
+
*/
|
1344
|
+
libnet_ptag_t
|
1345
|
+
libnet_build_ospfv2_lsa_rtr(u_int16_t flags, u_int16_t num, u_int id,
|
1346
|
+
u_int data, u_int8_t type, u_int8_t tos, u_int16_t metric, u_int8_t *payload,
|
1347
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1348
|
+
|
1349
|
+
/**
|
1350
|
+
* @param payload optional payload or NULL
|
1351
|
+
* @param payload_s payload length or 0
|
1352
|
+
* @param l pointer to a libnet context
|
1353
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1354
|
+
* @return protocol tag value on success, -1 on error
|
1355
|
+
*/
|
1356
|
+
libnet_ptag_t
|
1357
|
+
libnet_build_ospfv2_lsa_net(u_int32_t nmask, u_int rtrid, u_int8_t *payload,
|
1358
|
+
u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1359
|
+
|
1360
|
+
/**
|
1361
|
+
* @param payload optional payload or NULL
|
1362
|
+
* @param payload_s payload length or 0
|
1363
|
+
* @param l pointer to a libnet context
|
1364
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1365
|
+
* @return protocol tag value on success, -1 on error
|
1366
|
+
*/
|
1367
|
+
libnet_ptag_t
|
1368
|
+
libnet_build_ospfv2_lsa_sum(u_int32_t nmask, u_int metric, u_int tos,
|
1369
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1370
|
+
|
1371
|
+
/**
|
1372
|
+
* @param payload optional payload or NULL
|
1373
|
+
* @param payload_s payload length or 0
|
1374
|
+
* @param l pointer to a libnet context
|
1375
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1376
|
+
* @return protocol tag value on success, -1 on error
|
1377
|
+
*/
|
1378
|
+
libnet_ptag_t
|
1379
|
+
libnet_build_ospfv2_lsa_as(u_int32_t nmask, u_int metric, u_int32_t fwdaddr,
|
1380
|
+
u_int tag, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1381
|
+
libnet_ptag_t ptag);
|
1382
|
+
|
1383
|
+
/**
|
1384
|
+
* Builds a generic libnet protocol header. This is useful for including an
|
1385
|
+
* optional payload to a packet that might need to change repeatedly inside
|
1386
|
+
* of a loop.
|
1387
|
+
* @param payload optional payload or NULL
|
1388
|
+
* @param payload_s payload length or 0
|
1389
|
+
* @param l pointer to a libnet context
|
1390
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1391
|
+
* @return protocol tag value on success, -1 on error
|
1392
|
+
*/
|
1393
|
+
libnet_ptag_t
|
1394
|
+
libnet_build_data(u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1395
|
+
libnet_ptag_t ptag);
|
1396
|
+
|
1397
|
+
/**
|
1398
|
+
* @param payload optional payload or NULL
|
1399
|
+
* @param payload_s payload length or 0
|
1400
|
+
* @param l pointer to a libnet context
|
1401
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1402
|
+
* @return protocol tag value on success, -1 on error
|
1403
|
+
*/
|
1404
|
+
libnet_ptag_t
|
1405
|
+
libnet_build_dhcpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen,
|
1406
|
+
u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags,
|
1407
|
+
u_int32_t cip, u_int32_t yip, u_int32_t sip, u_int32_t gip, u_int8_t *chaddr,
|
1408
|
+
u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s,
|
1409
|
+
libnet_t *l, libnet_ptag_t ptag);
|
1410
|
+
|
1411
|
+
/**
|
1412
|
+
* @param payload optional payload or NULL
|
1413
|
+
* @param payload_s payload length or 0
|
1414
|
+
* @param l pointer to a libnet context
|
1415
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1416
|
+
* @return protocol tag value on success, -1 on error
|
1417
|
+
*/
|
1418
|
+
libnet_ptag_t
|
1419
|
+
libnet_build_bootpv4(u_int8_t opcode, u_int8_t htype, u_int8_t hlen,
|
1420
|
+
u_int8_t hopcount, u_int32_t xid, u_int16_t secs, u_int16_t flags,
|
1421
|
+
u_int32_t cip, u_int32_t yip, u_int32_t sip, u_int32_t gip, u_int8_t *chaddr,
|
1422
|
+
u_int8_t *sname, u_int8_t *file, u_int8_t *payload, u_int32_t payload_s,
|
1423
|
+
libnet_t *l, libnet_ptag_t ptag);
|
1424
|
+
|
1425
|
+
/**
|
1426
|
+
* @param payload optional payload or NULL
|
1427
|
+
* @param payload_s payload length or 0
|
1428
|
+
* @param l pointer to a libnet context
|
1429
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1430
|
+
* @return protocol tag value on success, -1 on error
|
1431
|
+
*/
|
1432
|
+
inline u_int32_t
|
1433
|
+
libnet_getgre_length(u_int16_t fv);
|
1434
|
+
|
1435
|
+
/**
|
1436
|
+
* Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate any
|
1437
|
+
* protocol. Hence, the IP part of the packet is usually referred as "delivery
|
1438
|
+
* header". It is then followed by the GRE header and finally the encapsulated
|
1439
|
+
* packet (IP or whatever).
|
1440
|
+
* As GRE is very modular, the first GRE header describes the structure of the
|
1441
|
+
* header, using bits and flag to specify which fields will be present in the
|
1442
|
+
* header.
|
1443
|
+
* @param fv the 16 0 to 7: which fields are included in the header (checksum, seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version.
|
1444
|
+
* @param payload optional payload or NULL
|
1445
|
+
* @param type which protocol is encapsulated (PPP, IP, ...)
|
1446
|
+
* @param sum checksum (0 for libnet to autofill).
|
1447
|
+
* @param offset byte offset from the start of the routing field to the first byte of the SRE
|
1448
|
+
* @param key inserted by the encapsulator to authenticate the source
|
1449
|
+
* @param seq sequence number used by the receiver to sort the packets
|
1450
|
+
* @param len size of the GRE packet
|
1451
|
+
* @param payload_s payload length or 0
|
1452
|
+
* @param l pointer to a libnet context
|
1453
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1454
|
+
* @return protocol tag value on success, -1 on error
|
1455
|
+
*/
|
1456
|
+
libnet_ptag_t
|
1457
|
+
libnet_build_gre(u_int16_t fv, u_int16_t type, u_int16_t sum,
|
1458
|
+
u_int16_t offset, u_int32_t key, u_int32_t seq, u_int16_t len,
|
1459
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1460
|
+
|
1461
|
+
/**
|
1462
|
+
* Generic Routing Encapsulation (GRE - RFC 1701) is used to encapsulate any
|
1463
|
+
* protocol. Hence, the IP part of the packet is usually referred as "delivery
|
1464
|
+
* header". It is then followed by the GRE header and finally the encapsulated
|
1465
|
+
* packet (IP or whatever).
|
1466
|
+
* As GRE is very modular, the first GRE header describes the structure of the
|
1467
|
+
* header, using bits and flag to specify which fields will be present in the
|
1468
|
+
* header.
|
1469
|
+
* @param fv the 16 0 to 7: which fields are included in the header (checksum, seq. number, key, ...), bits 8 to 12: flag, bits 13 to 15: version.
|
1470
|
+
* @param payload optional payload or NULL
|
1471
|
+
* @param type which protocol is encapsulated (PPP, IP, ...)
|
1472
|
+
* @param sum checksum (0 for libnet to autofill).
|
1473
|
+
* @param offset byte offset from the start of the routing field to the first byte of the SRE
|
1474
|
+
* @param key inserted by the encapsulator to authenticate the source
|
1475
|
+
* @param seq sequence number used by the receiver to sort the packets
|
1476
|
+
* @param len size of the GRE packet
|
1477
|
+
* @param payload_s payload length or 0
|
1478
|
+
* @param l pointer to a libnet context
|
1479
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1480
|
+
* @return protocol tag value on success, -1 on error
|
1481
|
+
*/
|
1482
|
+
libnet_ptag_t
|
1483
|
+
libnet_build_egre(u_int16_t fv, u_int16_t type, u_int16_t sum,
|
1484
|
+
u_int16_t offset, u_int32_t key, u_int32_t seq, u_int16_t len,
|
1485
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1486
|
+
|
1487
|
+
/**
|
1488
|
+
* @param payload optional payload or NULL
|
1489
|
+
* @param payload_s payload length or 0
|
1490
|
+
* @param l pointer to a libnet context
|
1491
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1492
|
+
* @return protocol tag value on success, -1 on error
|
1493
|
+
*/
|
1494
|
+
libnet_ptag_t
|
1495
|
+
libnet_build_gre_sre(u_int16_t af, u_int8_t offset, u_int8_t length,
|
1496
|
+
u_int8_t *routing, u_int8_t *payload, u_int32_t payload_s, libnet_t *l,
|
1497
|
+
libnet_ptag_t ptag);
|
1498
|
+
|
1499
|
+
/**
|
1500
|
+
* @param payload optional payload or NULL
|
1501
|
+
* @param payload_s payload length or 0
|
1502
|
+
* @param l pointer to a libnet context
|
1503
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1504
|
+
* @return protocol tag value on success, -1 on error
|
1505
|
+
*/
|
1506
|
+
libnet_ptag_t
|
1507
|
+
libnet_build_gre_last_sre(libnet_t *l, libnet_ptag_t ptag);
|
1508
|
+
|
1509
|
+
/**
|
1510
|
+
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) header. The primary
|
1511
|
+
* function of a BGP speaking system is to exchange network reachability
|
1512
|
+
* information with other BGP systems. This network reachability information
|
1513
|
+
* includes information on the list of Autonomous Systems (ASs) that
|
1514
|
+
* reachability information traverses. This information is sufficient to
|
1515
|
+
* construct a graph of AS connectivity from which routing loops may be pruned
|
1516
|
+
* and some policy decisions at the AS level may be enforced.
|
1517
|
+
* This function builds the base BGP header which is used as a preamble before
|
1518
|
+
* any other BGP header. For example, a BGP KEEPALIVE message may be built with
|
1519
|
+
* only this function, while an error notification requires a subsequent call
|
1520
|
+
* to libnet_build_bgp4_notification.
|
1521
|
+
* @param marker a value the receiver can predict (if the message type is not BGP OPEN, or no authentication is used, these 16 bytes are normally set as all ones)
|
1522
|
+
* @param len total length of the BGP message, including the header
|
1523
|
+
* @param type type code of the message (OPEN, UPDATE, NOTIFICATION or KEEPALIVE)
|
1524
|
+
* @param payload optional payload or NULL
|
1525
|
+
* @param payload_s payload length or 0
|
1526
|
+
* @param l pointer to a libnet context
|
1527
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1528
|
+
* @return protocol tag value on success, -1 on error
|
1529
|
+
*/
|
1530
|
+
libnet_ptag_t
|
1531
|
+
libnet_build_bgp4_header(u_int8_t marker[LIBNET_BGP4_MARKER_SIZE],
|
1532
|
+
u_int16_t len, u_int8_t type, u_int8_t *payload, u_int32_t payload_s,
|
1533
|
+
libnet_t *l, libnet_ptag_t ptag);
|
1534
|
+
|
1535
|
+
/**
|
1536
|
+
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) OPEN header. This is
|
1537
|
+
* the first message sent by each side of a BGP connection. The optional
|
1538
|
+
* parameters options should be constructed using the payload interface (see
|
1539
|
+
* RFC 1771 for the options structures).
|
1540
|
+
* @param version protocol version (should be set to 4)
|
1541
|
+
* @param src_as Autonomous System of the sender
|
1542
|
+
* @param hold_time used to compute the maximum allowed time between the receipt of KEEPALIVE, and/or UPDATE messages by the sender
|
1543
|
+
* @param bgp_id BGP identifier of the sender
|
1544
|
+
* @param opt_len total length of the optional parameters field in bytes
|
1545
|
+
* @param payload optional payload or NULL
|
1546
|
+
* @param payload_s payload length or 0
|
1547
|
+
* @param l pointer to a libnet context
|
1548
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1549
|
+
* @return protocol tag value on success, -1 on error
|
1550
|
+
*/
|
1551
|
+
libnet_ptag_t
|
1552
|
+
libnet_build_bgp4_open(u_int8_t version, u_int16_t src_as, u_int16_t hold_time,
|
1553
|
+
u_int32_t bgp_id, u_int8_t opt_len, u_int8_t *payload, u_int32_t payload_s,
|
1554
|
+
libnet_t *l, libnet_ptag_t ptag);
|
1555
|
+
|
1556
|
+
/**
|
1557
|
+
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) update header. Update
|
1558
|
+
* messages are used to transfer routing information between BGP peers.
|
1559
|
+
* @param unfeasible_rt_len indicates the length of the (next) "withdrawn routes" field in bytes
|
1560
|
+
* @param withdrawn_rt list of IP addresses prefixes for the routes that are being withdrawn; each IP address prefix is built as a 2-tuple <length (1 byte), prefix (variable)>
|
1561
|
+
* @param total_path_attr_len indicates the length of the (next) "path attributes" field in bytes
|
1562
|
+
* @param path_attributes each attribute is a 3-tuple <type (2 bytes), length, value>
|
1563
|
+
* @param info_len indicates the length of the (next) "network layer reachability information" field in bytes (needed for internal memory size calculation)
|
1564
|
+
* @param reachability_info 2-tuples <length (1 byte), prefix (variable)>.
|
1565
|
+
* @param payload optional payload or NULL
|
1566
|
+
* @param payload_s payload length or 0
|
1567
|
+
* @param l pointer to a libnet context
|
1568
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1569
|
+
* @return protocol tag value on success, -1 on error
|
1570
|
+
*/
|
1571
|
+
libnet_ptag_t
|
1572
|
+
libnet_build_bgp4_update(u_int16_t unfeasible_rt_len, u_int8_t *withdrawn_rt,
|
1573
|
+
u_int16_t total_path_attr_len, u_int8_t *path_attributes, u_int16_t info_len,
|
1574
|
+
u_int8_t *reachability_info, u_int8_t *payload, u_int32_t payload_s,
|
1575
|
+
libnet_t *l, libnet_ptag_t ptag);
|
1576
|
+
|
1577
|
+
/**
|
1578
|
+
* Builds an RFC 1771 Border Gateway Protocol 4 (BGP-4) notification header.
|
1579
|
+
* A NOTIFICATION message is sent when an error condition is detected. Specific
|
1580
|
+
* error information may be passed through the payload interface.
|
1581
|
+
* @param err_code type of notification
|
1582
|
+
* @param err_subcode more specific information about the reported error.
|
1583
|
+
* @param payload optional payload or NULL
|
1584
|
+
* @param payload_s payload length or 0
|
1585
|
+
* @param l pointer to a libnet context
|
1586
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1587
|
+
* @return protocol tag value on success, -1 on error
|
1588
|
+
*/
|
1589
|
+
libnet_ptag_t
|
1590
|
+
libnet_build_bgp4_notification(u_int8_t err_code, u_int8_t err_subcode,
|
1591
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1592
|
+
|
1593
|
+
/**
|
1594
|
+
* Builds a Sebek header. The Sebek protocol was designed by the Honeynet
|
1595
|
+
* Project as a transport mechanism for post-intrusion forensic data. More
|
1596
|
+
* information may be found here: http://www.honeynet.org/papers/sebek.pdf.
|
1597
|
+
* @param magic identify packets that should be hidden
|
1598
|
+
* @param version protocol version, currently 1
|
1599
|
+
* @param type type of record (read data is type 0, write data is type 1)
|
1600
|
+
* @param counter PDU counter used to identify when packet are lost
|
1601
|
+
* @param time_sec seconds since EPOCH according to the honeypot
|
1602
|
+
* @param time_usec residual microseconds
|
1603
|
+
* @param pid PID
|
1604
|
+
* @param uid UID
|
1605
|
+
* @param fd FD
|
1606
|
+
* @param cmd[SEBEK_CMD_LENGTH] 12 first characters of the command
|
1607
|
+
* @param length length in bytes of the PDU's body
|
1608
|
+
* @param payload optional payload or NULL
|
1609
|
+
* @param payload_s payload length or 0
|
1610
|
+
* @param l pointer to a libnet context
|
1611
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1612
|
+
* @return protocol tag value on success, -1 on error
|
1613
|
+
*/
|
1614
|
+
libnet_ptag_t
|
1615
|
+
libnet_build_sebek(u_int32_t magic, u_int16_t version, u_int16_t type,
|
1616
|
+
u_int32_t counter, u_int32_t time_sec, u_int32_t time_usec, u_int32_t pid,
|
1617
|
+
u_int32_t uid, u_int32_t fd, u_int8_t cmd[SEBEK_CMD_LENGTH], u_int32_t length,
|
1618
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1619
|
+
|
1620
|
+
/**
|
1621
|
+
* Builds a link layer header for an initialized l. The function
|
1622
|
+
* determines the proper link layer header format from how l was initialized.
|
1623
|
+
* The function current supports Ethernet and Token Ring link layers.
|
1624
|
+
* @param dst the destination MAC address
|
1625
|
+
* @param src the source MAC address
|
1626
|
+
* @param oui Organizationally Unique Identifier (unused for Ethernet)
|
1627
|
+
* @param type the upper layer protocol type
|
1628
|
+
* @param payload optional payload or NULL
|
1629
|
+
* @param payload_s payload length or 0
|
1630
|
+
* @param l pointer to a libnet context
|
1631
|
+
* @param ptag protocol tag to modify an existing header, 0 to build a new one
|
1632
|
+
* @return protocol tag value on success, -1 on error
|
1633
|
+
*/
|
1634
|
+
libnet_ptag_t
|
1635
|
+
libnet_build_link(u_int8_t *dst, u_int8_t *src, u_int8_t *oui, u_int16_t type,
|
1636
|
+
u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag);
|
1637
|
+
|
1638
|
+
/**
|
1639
|
+
* Automatically builds a link layer header for an initialized l. The function
|
1640
|
+
* determines the proper link layer header format from how l was initialized.
|
1641
|
+
* The function current supports Ethernet and Token Ring link layers.
|
1642
|
+
* @param dst the destination MAC address
|
1643
|
+
* @param oui Organizationally Unique Identifier (unused for Ethernet)
|
1644
|
+
* @param type the upper layer protocol type
|
1645
|
+
* @param l pointer to a libnet context
|
1646
|
+
* @return protocol tag value on success, -1 on error
|
1647
|
+
*/
|
1648
|
+
libnet_ptag_t
|
1649
|
+
libnet_autobuild_link(u_int8_t *dst, u_int8_t *oui, u_int16_t type,
|
1650
|
+
libnet_t *l);
|
1651
|
+
|
1652
|
+
/**
|
1653
|
+
* Writes a prebuilt packet to the network. The function assumes that l was
|
1654
|
+
* previously initialized (via a call to libnet_init()) and that a
|
1655
|
+
* previously constructed packet has been built inside this context (via one or
|
1656
|
+
* more calls to the libnet_build* family of functions) and is ready to go.
|
1657
|
+
* Depending on how libnet was initialized, the function will write the packet
|
1658
|
+
* to the wire either via the raw or link layer interface. The function will
|
1659
|
+
* also bump up the internal libnet stat counters which are retrievable via
|
1660
|
+
* libnet_stats().
|
1661
|
+
* @param l pointer to a libnet context
|
1662
|
+
* @return the number of bytes written, -1 on error
|
1663
|
+
*/
|
1664
|
+
int
|
1665
|
+
libnet_write(libnet_t *l);
|
1666
|
+
|
1667
|
+
/**
|
1668
|
+
* Returns the IP address for the device libnet was initialized with. If
|
1669
|
+
* libnet was initialized without a device (in raw socket mode) the function
|
1670
|
+
* will attempt to find one. If the function fails and returns -1 a call to
|
1671
|
+
* libnet_geterrror() will tell you why.
|
1672
|
+
* @param l pointer to a libnet context
|
1673
|
+
* @return a big endian IP address suitable for use in a libnet_build function or -1
|
1674
|
+
*/
|
1675
|
+
|
1676
|
+
u_int32_t
|
1677
|
+
libnet_get_ipaddr4(libnet_t *l);
|
1678
|
+
|
1679
|
+
/**
|
1680
|
+
* This function is not yet implemented under IPv6.
|
1681
|
+
* @param l pointer to a libnet context
|
1682
|
+
* @return well, nothing yet
|
1683
|
+
*/
|
1684
|
+
struct libnet_in6_addr
|
1685
|
+
libnet_get_ipaddr6(libnet_t *l);
|
1686
|
+
|
1687
|
+
/**
|
1688
|
+
* Returns the MAC address for the device libnet was initialized with. If
|
1689
|
+
* libnet was initialized without a device the function will attempt to find
|
1690
|
+
* one. If the function fails and returns NULL a call to libnet_geterror() will
|
1691
|
+
* tell you why.
|
1692
|
+
* @param l pointer to a libnet context
|
1693
|
+
* @return a pointer to the MAC address or NULL
|
1694
|
+
*/
|
1695
|
+
struct libnet_ether_addr *
|
1696
|
+
libnet_get_hwaddr(libnet_t *l);
|
1697
|
+
|
1698
|
+
/**
|
1699
|
+
* Takes a colon separated hexidecimal address (from the command line) and
|
1700
|
+
* returns a bytestring suitable for use in a libnet_build function. Note this
|
1701
|
+
* function performs an implicit malloc and the return value should be freed
|
1702
|
+
* after its use.
|
1703
|
+
* @param s the string to be parsed
|
1704
|
+
* @param len the resulting size of the returned byte string
|
1705
|
+
* @return a byte string or NULL on failure
|
1706
|
+
*/
|
1707
|
+
u_int8_t *
|
1708
|
+
libnet_hex_aton(int8_t *s, int *len);
|
1709
|
+
|
1710
|
+
/**
|
1711
|
+
* [Advanced Interface]
|
1712
|
+
* Yanks a prebuilt, wire-ready packet from the given libnet context. If
|
1713
|
+
* libnet was configured to do so (which it is by default) the packet will have
|
1714
|
+
* all checksums written in. This function is part of the advanced interface
|
1715
|
+
* and is only available when libnet is initialized in advanced mode. It is
|
1716
|
+
* important to note that the function performs an implicit malloc() and a
|
1717
|
+
* corresponding call to libnet_adv_free_packet() should be made to free the
|
1718
|
+
* memory packet occupies. If the function fails libnet_geterror() can tell you
|
1719
|
+
* why.
|
1720
|
+
* @param l pointer to a libnet context
|
1721
|
+
* @param packet will contain the wire-ready packet
|
1722
|
+
* @param packet_s will contain the packet size
|
1723
|
+
* @return 1 on success, -1 on failure
|
1724
|
+
*/
|
1725
|
+
int
|
1726
|
+
libnet_adv_cull_packet(libnet_t *l, u_int8_t **packet, u_int32_t *packet_s);
|
1727
|
+
|
1728
|
+
/**
|
1729
|
+
* [Advanced Interface]
|
1730
|
+
* Pulls the header from the specified ptag from the given libnet context. This
|
1731
|
+
* function is part of the advanced interface and is only available when libnet
|
1732
|
+
* is initialized in advanced mode. If the function fails libnet_geterror() can
|
1733
|
+
* tell you why.
|
1734
|
+
* @param l pointer to a libnet context
|
1735
|
+
* @param ptag the ptag referencing the header to pull
|
1736
|
+
* @param header will contain the header
|
1737
|
+
* @param header_s will contain the header size
|
1738
|
+
* @return 1 on success, -1 on failure
|
1739
|
+
*/
|
1740
|
+
int
|
1741
|
+
libnet_adv_cull_header(libnet_t *l, libnet_ptag_t ptag, u_int8_t **header,
|
1742
|
+
u_int32_t *header_s);
|
1743
|
+
|
1744
|
+
/**
|
1745
|
+
* [Advanced Interface]
|
1746
|
+
* Writes a packet the network at the link layer. This function is useful to
|
1747
|
+
* write a packet that has been constructed by hand by the application
|
1748
|
+
* programmer or, more commonly, to write a packet that has been returned by
|
1749
|
+
* a call to libnet_adv_cull_packet(). This function is part of the advanced
|
1750
|
+
* interface and is only available when libnet is initialized in advanced mode.
|
1751
|
+
* If the function fails libnet_geterror() can tell you why.
|
1752
|
+
* @param l pointer to a libnet context
|
1753
|
+
* @param packet a pointer to the packet to inject
|
1754
|
+
* @param packet_s the size of the packet
|
1755
|
+
* @return the number of bytes written, or -1 on failure
|
1756
|
+
*/
|
1757
|
+
int
|
1758
|
+
libnet_adv_write_link(libnet_t *l, u_int8_t *packet, u_int32_t packet_s);
|
1759
|
+
|
1760
|
+
/**
|
1761
|
+
* [Advanced Interface]
|
1762
|
+
* Frees the memory allocated when libnet_adv_cull_packet() is called.
|
1763
|
+
* @param l pointer to a libnet context
|
1764
|
+
* @param packet a pointer to the packet to free
|
1765
|
+
*/
|
1766
|
+
void
|
1767
|
+
libnet_adv_free_packet(libnet_t *l, u_int8_t *packet);
|
1768
|
+
|
1769
|
+
/**
|
1770
|
+
* [Context Queue]
|
1771
|
+
* Adds a new context to the libnet context queue. If no queue exists, this
|
1772
|
+
* function will create the queue and add the specified libnet context as the
|
1773
|
+
* first entry on the list. The functions checks to ensure niether l nor label
|
1774
|
+
* are NULL, and that label doesn't refer to an existing context already in the
|
1775
|
+
* queue. Additionally, l should refer to a libnet context previously
|
1776
|
+
* initialized with a call to libnet_init(). If the context queue in write
|
1777
|
+
* locked, this function will fail.
|
1778
|
+
* @param l pointer to a libnet context
|
1779
|
+
* @param label a canonical name given to recognize the new context, no longer than LIBNET_LABEL_SIZE
|
1780
|
+
* @return 1 on success, -1 on failure
|
1781
|
+
*/
|
1782
|
+
int
|
1783
|
+
libnet_cq_add(libnet_t *l, char *label);
|
1784
|
+
|
1785
|
+
/**
|
1786
|
+
* [Context Queue]
|
1787
|
+
* Removes a specified context from the libnet context queue by specifying the
|
1788
|
+
* libnet context pointer. Note the function will remove the specified context
|
1789
|
+
* from the context queue and cleanup internal memory from the queue, it is up
|
1790
|
+
* to the application programmer to free the returned libnet context with a
|
1791
|
+
* call to libnet_destroy(). Also, as it is not necessary to keep the libnet
|
1792
|
+
* context pointer when initially adding it to the context queue, most
|
1793
|
+
* application programmers will prefer to refer to entries on the context
|
1794
|
+
* queue by canonical name and would use libnet_cq_remove_by_label(). If the
|
1795
|
+
* context queue is write locked, this function will fail.
|
1796
|
+
* @param l pointer to a libnet context
|
1797
|
+
* @return the pointer to the removed libnet context, NULL on failure
|
1798
|
+
*/
|
1799
|
+
libnet_t *
|
1800
|
+
libnet_cq_remove(libnet_t *l);
|
1801
|
+
|
1802
|
+
/**
|
1803
|
+
* [Context Queue]
|
1804
|
+
* Removes a specified context from the libnet context queue by specifying the
|
1805
|
+
* canonical name. Note the function will remove the specified context from
|
1806
|
+
* the context queue and cleanup internal memory from the queue, it is up to
|
1807
|
+
* the application programmer to free the returned libnet context with a call
|
1808
|
+
* to libnet_destroy(). If the context queue is write locked, this function
|
1809
|
+
* will fail.
|
1810
|
+
* @param label canonical name of the context to remove
|
1811
|
+
* @return the pointer to the removed libnet context, NULL on failure
|
1812
|
+
*/
|
1813
|
+
libnet_t *
|
1814
|
+
libnet_cq_remove_by_label(char *label);
|
1815
|
+
|
1816
|
+
/**
|
1817
|
+
* [Context Queue]
|
1818
|
+
* Returns the canonical label associated with the context.
|
1819
|
+
* @param l pointer to a libnet context
|
1820
|
+
* @return pointer to the libnet context's label
|
1821
|
+
*/
|
1822
|
+
int8_t *
|
1823
|
+
libnet_cq_getlabel(libnet_t *l);
|
1824
|
+
|
1825
|
+
/**
|
1826
|
+
* [Context Queue]
|
1827
|
+
* Locates a libnet context from the queue, indexed by a canonical label.
|
1828
|
+
* @param label canonical label of the libnet context to retrieve
|
1829
|
+
* @return the expected libnet context, NULL on failure
|
1830
|
+
*/
|
1831
|
+
libnet_t *
|
1832
|
+
libnet_cq_find_by_label(char *label);
|
1833
|
+
|
1834
|
+
/**
|
1835
|
+
* [Context Queue]
|
1836
|
+
* Destroys the entire context queue, calling libnet_destroy() on each
|
1837
|
+
* member context.
|
1838
|
+
*/
|
1839
|
+
void
|
1840
|
+
libnet_cq_destroy();
|
1841
|
+
|
1842
|
+
/**
|
1843
|
+
* [Context Queue]
|
1844
|
+
* Intiailizes the interator interface and set a write lock on the entire
|
1845
|
+
* queue. This function is intended to be called just prior to interating
|
1846
|
+
* through the entire list of contexts (with the probable intent of inject a
|
1847
|
+
* series of packets in rapid succession). This function is often used as
|
1848
|
+
* per the following:
|
1849
|
+
*
|
1850
|
+
* for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
|
1851
|
+
* {
|
1852
|
+
* ...
|
1853
|
+
* }
|
1854
|
+
*
|
1855
|
+
* Much of the time, the application programmer will use the iterator as it is
|
1856
|
+
* written above; as such, libnet provides a macro to do exactly that,
|
1857
|
+
* for_each_context_in_cq(l). Warning: do not call the iterator more than once
|
1858
|
+
* in a single loop.
|
1859
|
+
* @return the head of the context queue
|
1860
|
+
*/
|
1861
|
+
libnet_t *
|
1862
|
+
libnet_cq_head();
|
1863
|
+
|
1864
|
+
/**
|
1865
|
+
* [Context Queue]
|
1866
|
+
* Check whether the iterator is at the last context in the queue.
|
1867
|
+
* @return 1 if at the end of the context queue, 0 otherwise
|
1868
|
+
*/
|
1869
|
+
int
|
1870
|
+
libnet_cq_last();
|
1871
|
+
|
1872
|
+
/**
|
1873
|
+
* [Context Queue]
|
1874
|
+
* Get next context from the context queue.
|
1875
|
+
* @reutrn the next context from the context queue
|
1876
|
+
*/
|
1877
|
+
libnet_t *
|
1878
|
+
libnet_cq_next();
|
1879
|
+
|
1880
|
+
/**
|
1881
|
+
* [Context Queue]
|
1882
|
+
* Function returns the number of libnet contexts that are in the queue.
|
1883
|
+
* @return the number of libnet contexts currently in the queue
|
1884
|
+
*/
|
1885
|
+
u_int32_t
|
1886
|
+
libnet_cq_size();
|
1887
|
+
|
1888
|
+
/**
|
1889
|
+
* [Diagnostic]
|
1890
|
+
* Prints the contents of the given context.
|
1891
|
+
* @param l pointer to a libnet context
|
1892
|
+
*/
|
1893
|
+
void
|
1894
|
+
libnet_diag_dump_context(libnet_t *l);
|
1895
|
+
|
1896
|
+
/**
|
1897
|
+
* [Diagnostic]
|
1898
|
+
* Prints the contents of every pblock.
|
1899
|
+
* @param l pointer to a libnet context
|
1900
|
+
*/
|
1901
|
+
void
|
1902
|
+
libnet_diag_dump_pblock(libnet_t *l);
|
1903
|
+
|
1904
|
+
/**
|
1905
|
+
* [Diagnostic]
|
1906
|
+
* Returns the canonical name of the pblock type.
|
1907
|
+
* @param type pblock type
|
1908
|
+
* @return a string representing the pblock type type or "unknown" for an unknown value
|
1909
|
+
*/
|
1910
|
+
char *
|
1911
|
+
libnet_diag_dump_pblock_type(u_int8_t type);
|
1912
|
+
|
1913
|
+
/**
|
1914
|
+
* [Diagnostic]
|
1915
|
+
* Function prints the contents of the supplied buffer to the supplied
|
1916
|
+
* stream pointer. Will swap endianness based disposition of mode variable.
|
1917
|
+
* Useful to be used in conjunction with the advanced interface and a culled
|
1918
|
+
* packet.
|
1919
|
+
* @param packet the packet to print
|
1920
|
+
* @param len length of the packet in bytes
|
1921
|
+
* @param swap 1 to swap byte order, 0 to not
|
1922
|
+
* @param stream a stream pointer to print to
|
1923
|
+
*/
|
1924
|
+
void
|
1925
|
+
libnet_diag_dump_hex(u_int8_t *packet, u_int32_t len, int swap, FILE *stream);
|
1926
|
+
|
1927
|
+
/*
|
1928
|
+
* [Internal]
|
1929
|
+
*/
|
1930
|
+
int
|
1931
|
+
libnet_open_socket(libnet_t *l);
|
1932
|
+
|
1933
|
+
/*
|
1934
|
+
* [Internal]
|
1935
|
+
*/
|
1936
|
+
int
|
1937
|
+
libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u_int32_t size);
|
1938
|
+
|
1939
|
+
/*
|
1940
|
+
* [Internal]
|
1941
|
+
*/
|
1942
|
+
int
|
1943
|
+
libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u_int32_t size);
|
1944
|
+
|
1945
|
+
/*
|
1946
|
+
* [Internal]
|
1947
|
+
*/
|
1948
|
+
int
|
1949
|
+
libnet_write_link(libnet_t *l, u_int8_t *packet, u_int32_t size);
|
1950
|
+
|
1951
|
+
#if ((__WIN32__) && !(__CYGWIN__))
|
1952
|
+
/*
|
1953
|
+
* [Internal]
|
1954
|
+
*/
|
1955
|
+
SOCKET
|
1956
|
+
libnet_open_raw4(libnet_t *l);
|
1957
|
+
#else
|
1958
|
+
/*
|
1959
|
+
* [Internal]
|
1960
|
+
*/
|
1961
|
+
int
|
1962
|
+
libnet_open_raw4(libnet_t *l);
|
1963
|
+
#endif
|
1964
|
+
|
1965
|
+
/*
|
1966
|
+
* [Internal]
|
1967
|
+
*/
|
1968
|
+
int
|
1969
|
+
libnet_close_raw4(libnet_t *l);
|
1970
|
+
|
1971
|
+
/*
|
1972
|
+
* [Internal]
|
1973
|
+
*/
|
1974
|
+
int
|
1975
|
+
libnet_open_raw6(libnet_t *l);
|
1976
|
+
|
1977
|
+
/*
|
1978
|
+
* [Internal]
|
1979
|
+
*/
|
1980
|
+
int
|
1981
|
+
libnet_close_raw6(libnet_t *l);
|
1982
|
+
|
1983
|
+
/*
|
1984
|
+
* [Internal]
|
1985
|
+
*/
|
1986
|
+
int
|
1987
|
+
libnet_select_device(libnet_t *l);
|
1988
|
+
|
1989
|
+
/*
|
1990
|
+
* [Internal]
|
1991
|
+
*/
|
1992
|
+
int
|
1993
|
+
libnet_open_link(libnet_t *l);
|
1994
|
+
|
1995
|
+
/*
|
1996
|
+
* [Internal]
|
1997
|
+
*/
|
1998
|
+
int
|
1999
|
+
libnet_close_link(libnet_t *l);
|
2000
|
+
|
2001
|
+
/*
|
2002
|
+
* [Internal]
|
2003
|
+
*/
|
2004
|
+
int
|
2005
|
+
libnet_do_checksum(libnet_t *l, u_int8_t *packet, int protocol, int len);
|
2006
|
+
|
2007
|
+
/*
|
2008
|
+
* [Internal]
|
2009
|
+
*/
|
2010
|
+
u_int32_t
|
2011
|
+
libnet_compute_crc(u_int8_t *buf, u_int32_t len);
|
2012
|
+
|
2013
|
+
/*
|
2014
|
+
* [Internal]
|
2015
|
+
*/
|
2016
|
+
u_int16_t
|
2017
|
+
libnet_ip_check(u_int16_t *addr, int len);
|
2018
|
+
|
2019
|
+
/*
|
2020
|
+
* [Internal]
|
2021
|
+
*/
|
2022
|
+
int
|
2023
|
+
libnet_in_cksum(u_int16_t *addr, int len);
|
2024
|
+
|
2025
|
+
/*
|
2026
|
+
* [Internal]
|
2027
|
+
* If ptag is 0, function will create a pblock for the protocol unit type,
|
2028
|
+
* append it to the list and return a pointer to it. If ptag is not 0,
|
2029
|
+
* function will search the pblock list for the specified protocol block
|
2030
|
+
* and return a pointer to it.
|
2031
|
+
*/
|
2032
|
+
libnet_pblock_t *
|
2033
|
+
libnet_pblock_probe(libnet_t *l, libnet_ptag_t ptag, u_int32_t n,
|
2034
|
+
u_int8_t type);
|
2035
|
+
|
2036
|
+
/*
|
2037
|
+
* [Internal]
|
2038
|
+
* Function creates the pblock list if l->protocol_blocks == NULL or appends
|
2039
|
+
* an entry to the doubly linked list.
|
2040
|
+
*/
|
2041
|
+
libnet_pblock_t *
|
2042
|
+
libnet_pblock_new(libnet_t *l, u_int32_t size);
|
2043
|
+
|
2044
|
+
/*
|
2045
|
+
* [Internal]
|
2046
|
+
* Function swaps two pblocks in memory.
|
2047
|
+
*/
|
2048
|
+
int
|
2049
|
+
libnet_pblock_swap(libnet_t *l, libnet_ptag_t ptag1, libnet_ptag_t ptag2);
|
2050
|
+
|
2051
|
+
/*
|
2052
|
+
* [Internal]
|
2053
|
+
* Function inserts a pblock into the doubly linked list.
|
2054
|
+
*/
|
2055
|
+
int
|
2056
|
+
libnet_pblock_insert_before(libnet_t *l, libnet_ptag_t ptag1,
|
2057
|
+
libnet_ptag_t ptag2);
|
2058
|
+
|
2059
|
+
/*
|
2060
|
+
* [Internal]
|
2061
|
+
* Function removes a pblock from context
|
2062
|
+
*/
|
2063
|
+
void
|
2064
|
+
libnet_pblock_delete(libnet_t *l, libnet_pblock_t *p);
|
2065
|
+
|
2066
|
+
/*
|
2067
|
+
* [Internal]
|
2068
|
+
* Function updates the pblock meta-inforation. Internally it updates the
|
2069
|
+
* ptag with a monotonically increasing variable kept in l. This way each
|
2070
|
+
* pblock has a succesively increasing ptag identifier.
|
2071
|
+
*/
|
2072
|
+
libnet_ptag_t
|
2073
|
+
libnet_pblock_update(libnet_t *l, libnet_pblock_t *p, u_int32_t h,
|
2074
|
+
u_int8_t type);
|
2075
|
+
|
2076
|
+
|
2077
|
+
/*
|
2078
|
+
* [Internal]
|
2079
|
+
* Checksums are a real pain in the <beep>!!!
|
2080
|
+
* Function updates referer used to compute the checksum. All
|
2081
|
+
* pblock need to know where is their referer (ie IP header).
|
2082
|
+
* So, this function is called each time a new IP header is inserted.
|
2083
|
+
* It updates the ip_pos field (referer) of each subsequent pblock.
|
2084
|
+
*/
|
2085
|
+
void
|
2086
|
+
libnet_pblock_record_ip_offset(libnet_t *l, u_int32_t offset);
|
2087
|
+
|
2088
|
+
/*
|
2089
|
+
* [Internal]
|
2090
|
+
* Function locates a given block by it's ptag.
|
2091
|
+
*/
|
2092
|
+
libnet_pblock_t *
|
2093
|
+
libnet_pblock_find(libnet_t *l, libnet_ptag_t ptag);
|
2094
|
+
|
2095
|
+
/*
|
2096
|
+
* [Internal]
|
2097
|
+
* Function copies protocol block data over.
|
2098
|
+
*/
|
2099
|
+
int
|
2100
|
+
libnet_pblock_append(libnet_t *l, libnet_pblock_t *p, u_int8_t *buf,
|
2101
|
+
u_int32_t len);
|
2102
|
+
|
2103
|
+
/*
|
2104
|
+
* [Internal]
|
2105
|
+
* Function sets pblock flags.
|
2106
|
+
*/
|
2107
|
+
void
|
2108
|
+
libnet_pblock_setflags(libnet_pblock_t *p, u_int8_t flags);
|
2109
|
+
|
2110
|
+
/*
|
2111
|
+
* [Internal]
|
2112
|
+
* Function returns the protocol number for the protocol block type. If
|
2113
|
+
* the type is unknown, the function defaults to returning IPPROTO_IP.
|
2114
|
+
*/
|
2115
|
+
int
|
2116
|
+
libnet_pblock_p2p(u_int8_t type);
|
2117
|
+
|
2118
|
+
/*
|
2119
|
+
* [Internal]
|
2120
|
+
* Function assembles the packet for subsequent writing. Function makes two
|
2121
|
+
* passes through the pblock list:
|
2122
|
+
*/
|
2123
|
+
int
|
2124
|
+
libnet_pblock_coalesce(libnet_t *l, u_int8_t **packet, u_int32_t *size);
|
2125
|
+
|
2126
|
+
#if !(__WIN32__)
|
2127
|
+
/*
|
2128
|
+
* [Internal]
|
2129
|
+
* By testing if we can retrieve the FLAGS of an iface
|
2130
|
+
* we can know if it exists or not and if it is up.
|
2131
|
+
*/
|
2132
|
+
int
|
2133
|
+
libnet_check_iface(libnet_t *l);
|
2134
|
+
#endif
|
2135
|
+
|
2136
|
+
#if defined(__WIN32__)
|
2137
|
+
/*
|
2138
|
+
* [Internal]
|
2139
|
+
*/
|
2140
|
+
BYTE *
|
2141
|
+
libnet_win32_get_remote_mac(libnet_t *l, DWORD IP);
|
2142
|
+
|
2143
|
+
/*
|
2144
|
+
* [Internal]
|
2145
|
+
*/
|
2146
|
+
int
|
2147
|
+
libnet_close_link_interface(libnet_t *l);
|
2148
|
+
|
2149
|
+
/*
|
2150
|
+
* [Internal]
|
2151
|
+
*/
|
2152
|
+
BYTE *
|
2153
|
+
libnet_win32_read_arp_table(DWORD IP);
|
2154
|
+
#endif
|
2155
|
+
#endif /* __LIBNET_FUNCTIONS_H */
|
2156
|
+
|
2157
|
+
/* EOF */
|