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.
Files changed (306) hide show
  1. data/CHANGELOG +15 -0
  2. data/LICENSE +28 -0
  3. data/README +187 -0
  4. data/Rakefile +110 -0
  5. data/ext/extconf.rb +60 -0
  6. data/ext/libnet.c +705 -0
  7. data/ext/libnet_arp.c +152 -0
  8. data/ext/libnet_ethernet.c +115 -0
  9. data/ext/libnet_ipv4.c +140 -0
  10. data/ext/libnet_ipv6.c +138 -0
  11. data/ext/libnet_udp.c +112 -0
  12. data/ext/libnet_vlan.c +131 -0
  13. data/lib/libnet4r/header.rb +609 -0
  14. data/lib/libnet4r/helpers.rb +19 -0
  15. data/lib/libnet4r/libnet.rb +39 -0
  16. data/libnet/CVS/Entries +24 -0
  17. data/libnet/CVS/Repository +1 -0
  18. data/libnet/CVS/Root +1 -0
  19. data/libnet/Makefile.am +15 -0
  20. data/libnet/Makefile.am.common +10 -0
  21. data/libnet/Makefile.in +443 -0
  22. data/libnet/README +21 -0
  23. data/libnet/VERSION +1 -0
  24. data/libnet/acconfig.h +36 -0
  25. data/libnet/acinclude.m4 +463 -0
  26. data/libnet/aclocal.m4 +1337 -0
  27. data/libnet/autom4te.cache/CVS/Entries +1 -0
  28. data/libnet/autom4te.cache/CVS/Repository +1 -0
  29. data/libnet/autom4te.cache/CVS/Root +1 -0
  30. data/libnet/autom4te.cache/output.0 +6225 -0
  31. data/libnet/autom4te.cache/requests +111 -0
  32. data/libnet/autom4te.cache/traces.0 +272 -0
  33. data/libnet/config.guess +1314 -0
  34. data/libnet/config.sub +1410 -0
  35. data/libnet/configure +6225 -0
  36. data/libnet/configure.in +235 -0
  37. data/libnet/doc/BUGS +19 -0
  38. data/libnet/doc/CHANGELOG +527 -0
  39. data/libnet/doc/CONTRIB +53 -0
  40. data/libnet/doc/COPYING +31 -0
  41. data/libnet/doc/CVS/Entries +12 -0
  42. data/libnet/doc/CVS/Repository +1 -0
  43. data/libnet/doc/CVS/Root +1 -0
  44. data/libnet/doc/DESIGN_NOTES +134 -0
  45. data/libnet/doc/MIGRATION +172 -0
  46. data/libnet/doc/PACKET_BUILDING +161 -0
  47. data/libnet/doc/PORTED +45 -0
  48. data/libnet/doc/RAWSOCKET_NON_SEQUITUR +41 -0
  49. data/libnet/doc/TODO +96 -0
  50. data/libnet/doc/html/acconfig_8h-source.html +49 -0
  51. data/libnet/doc/html/annotated.html +17 -0
  52. data/libnet/doc/html/bpf_8h-source.html +277 -0
  53. data/libnet/doc/html/config_8h-source.html +125 -0
  54. data/libnet/doc/html/doxygen.css +169 -0
  55. data/libnet/doc/html/doxygen.png +0 -0
  56. data/libnet/doc/html/files.html +29 -0
  57. data/libnet/doc/html/functions.html +26 -0
  58. data/libnet/doc/html/functions_vars.html +26 -0
  59. data/libnet/doc/html/getopt_8h-source.html +97 -0
  60. data/libnet/doc/html/globals.html +219 -0
  61. data/libnet/doc/html/globals_defs.html +104 -0
  62. data/libnet/doc/html/globals_func.html +136 -0
  63. data/libnet/doc/html/gnuc_8h-source.html +56 -0
  64. data/libnet/doc/html/graph_legend.dot +22 -0
  65. data/libnet/doc/html/graph_legend.html +75 -0
  66. data/libnet/doc/html/ifaddrlist_8h-source.html +65 -0
  67. data/libnet/doc/html/in__systm_8h-source.html +90 -0
  68. data/libnet/doc/html/index.html +17 -0
  69. data/libnet/doc/html/libnet-asn1_8h-source.html +268 -0
  70. data/libnet/doc/html/libnet-functions_8h-source.html +742 -0
  71. data/libnet/doc/html/libnet-functions_8h.html +8844 -0
  72. data/libnet/doc/html/libnet-headers_8h-source.html +1655 -0
  73. data/libnet/doc/html/libnet-headers_8h.html +3053 -0
  74. data/libnet/doc/html/libnet-macros_8h-source.html +161 -0
  75. data/libnet/doc/html/libnet-macros_8h.html +358 -0
  76. data/libnet/doc/html/libnet-structures_8h-source.html +233 -0
  77. data/libnet/doc/html/libnet-types_8h-source.html +58 -0
  78. data/libnet/doc/html/libnet_8h-source.html +119 -0
  79. data/libnet/doc/html/libnet_8h.html +24 -0
  80. data/libnet/doc/html/structlibnet__802__1q__hdr.html +145 -0
  81. data/libnet/doc/html/structlibnet__802__1x__hdr.html +97 -0
  82. data/libnet/doc/libnet.doxygen.conf +1102 -0
  83. data/libnet/doc/man/CVS/Entries +1 -0
  84. data/libnet/doc/man/CVS/Repository +1 -0
  85. data/libnet/doc/man/CVS/Root +1 -0
  86. data/libnet/doc/man/man3/libnet-functions.h.3 +3136 -0
  87. data/libnet/doc/man/man3/libnet-headers.h.3 +1872 -0
  88. data/libnet/doc/man/man3/libnet-macros.h.3 +172 -0
  89. data/libnet/doc/man/man3/libnet.h.3 +17 -0
  90. data/libnet/doc/man/man3/libnet_802_1q_hdr.3 +53 -0
  91. data/libnet/doc/man/man3/libnet_802_1x_hdr.3 +41 -0
  92. data/libnet/include/CVS/Entries +10 -0
  93. data/libnet/include/CVS/Repository +1 -0
  94. data/libnet/include/CVS/Root +1 -0
  95. data/libnet/include/Makefile.am +7 -0
  96. data/libnet/include/Makefile.in +395 -0
  97. data/libnet/include/bpf.h +264 -0
  98. data/libnet/include/config.h.in +118 -0
  99. data/libnet/include/gnuc.h +43 -0
  100. data/libnet/include/ifaddrlist.h +52 -0
  101. data/libnet/include/libnet/CVS/Entries +9 -0
  102. data/libnet/include/libnet/CVS/Repository +1 -0
  103. data/libnet/include/libnet/CVS/Root +1 -0
  104. data/libnet/include/libnet/Makefile.am +12 -0
  105. data/libnet/include/libnet/Makefile.in +294 -0
  106. data/libnet/include/libnet/libnet-asn1.h +255 -0
  107. data/libnet/include/libnet/libnet-functions.h +2157 -0
  108. data/libnet/include/libnet/libnet-headers.h +1662 -0
  109. data/libnet/include/libnet/libnet-macros.h +186 -0
  110. data/libnet/include/libnet/libnet-structures.h +222 -0
  111. data/libnet/include/libnet/libnet-types.h +45 -0
  112. data/libnet/include/libnet.h.in +132 -0
  113. data/libnet/include/stamp-h.in +1 -0
  114. data/libnet/include/win32/CVS/Entries +5 -0
  115. data/libnet/include/win32/CVS/Repository +1 -0
  116. data/libnet/include/win32/CVS/Root +1 -0
  117. data/libnet/include/win32/config.h +112 -0
  118. data/libnet/include/win32/getopt.h +84 -0
  119. data/libnet/include/win32/in_systm.h +77 -0
  120. data/libnet/include/win32/libnet.h +106 -0
  121. data/libnet/install-sh +250 -0
  122. data/libnet/libnet-config.in +62 -0
  123. data/libnet/libnet.doxygen.conf +1102 -0
  124. data/libnet/man/CVS/Entries +1 -0
  125. data/libnet/man/CVS/Repository +1 -0
  126. data/libnet/man/CVS/Root +1 -0
  127. data/libnet/missing +283 -0
  128. data/libnet/mkinstalldirs +40 -0
  129. data/libnet/sample/CVS/Entries +47 -0
  130. data/libnet/sample/CVS/Repository +1 -0
  131. data/libnet/sample/CVS/Root +1 -0
  132. data/libnet/sample/Makefile.am +63 -0
  133. data/libnet/sample/Makefile.in +729 -0
  134. data/libnet/sample/arp-new.c +144 -0
  135. data/libnet/sample/arp.c +151 -0
  136. data/libnet/sample/bgp4_hdr.c +225 -0
  137. data/libnet/sample/bgp4_notification.c +242 -0
  138. data/libnet/sample/bgp4_open.c +266 -0
  139. data/libnet/sample/bgp4_update.c +337 -0
  140. data/libnet/sample/cdp.c +187 -0
  141. data/libnet/sample/dhcp_discover.c +257 -0
  142. data/libnet/sample/dns.c +260 -0
  143. data/libnet/sample/dot1x.c +113 -0
  144. data/libnet/sample/fddi_tcp1.c +213 -0
  145. data/libnet/sample/fddi_tcp2.c +209 -0
  146. data/libnet/sample/get_addr.c +112 -0
  147. data/libnet/sample/gre.c +410 -0
  148. data/libnet/sample/icmp6_echoreq.c +184 -0
  149. data/libnet/sample/icmp_echo_cq.c +201 -0
  150. data/libnet/sample/icmp_redirect.c +200 -0
  151. data/libnet/sample/icmp_timeexceed.c +190 -0
  152. data/libnet/sample/icmp_timestamp.c +157 -0
  153. data/libnet/sample/icmp_unreach.c +204 -0
  154. data/libnet/sample/ieee.c +177 -0
  155. data/libnet/sample/ip_link.c +201 -0
  156. data/libnet/sample/ip_raw.c +180 -0
  157. data/libnet/sample/isl.c +167 -0
  158. data/libnet/sample/libnet_test.h +60 -0
  159. data/libnet/sample/mpls.c +251 -0
  160. data/libnet/sample/ntp.c +193 -0
  161. data/libnet/sample/ospf_hello.c +179 -0
  162. data/libnet/sample/ospf_lsa.c +190 -0
  163. data/libnet/sample/ping_of_death.c +171 -0
  164. data/libnet/sample/rpc_tcp.c +214 -0
  165. data/libnet/sample/rpc_udp.c +213 -0
  166. data/libnet/sample/sebek.c +299 -0
  167. data/libnet/sample/smurf.c +194 -0
  168. data/libnet/sample/stp.c +227 -0
  169. data/libnet/sample/synflood.c +200 -0
  170. data/libnet/sample/synflood6.c +209 -0
  171. data/libnet/sample/synflood6_frag.c +234 -0
  172. data/libnet/sample/tcp1.c +227 -0
  173. data/libnet/sample/tcp2.c +192 -0
  174. data/libnet/sample/tftp.c +207 -0
  175. data/libnet/sample/tring_tcp1.c +214 -0
  176. data/libnet/sample/tring_tcp2.c +210 -0
  177. data/libnet/sample/udp1.c +223 -0
  178. data/libnet/sample/udp2.c +232 -0
  179. data/libnet/sample/win32/CVS/Entries +9 -0
  180. data/libnet/sample/win32/CVS/Repository +1 -0
  181. data/libnet/sample/win32/CVS/Root +1 -0
  182. data/libnet/sample/win32/arp/CVS/Entries +2 -0
  183. data/libnet/sample/win32/arp/CVS/Repository +1 -0
  184. data/libnet/sample/win32/arp/CVS/Root +1 -0
  185. data/libnet/sample/win32/arp/arp.vcproj +136 -0
  186. data/libnet/sample/win32/cdp/CVS/Entries +2 -0
  187. data/libnet/sample/win32/cdp/CVS/Repository +1 -0
  188. data/libnet/sample/win32/cdp/CVS/Root +1 -0
  189. data/libnet/sample/win32/cdp/cdp.vcproj +136 -0
  190. data/libnet/sample/win32/dhcp_discover/CVS/Entries +2 -0
  191. data/libnet/sample/win32/dhcp_discover/CVS/Repository +1 -0
  192. data/libnet/sample/win32/dhcp_discover/CVS/Root +1 -0
  193. data/libnet/sample/win32/dhcp_discover/dhcp_discover.vcproj +139 -0
  194. data/libnet/sample/win32/dns/CVS/Entries +2 -0
  195. data/libnet/sample/win32/dns/CVS/Repository +1 -0
  196. data/libnet/sample/win32/dns/CVS/Root +1 -0
  197. data/libnet/sample/win32/dns/dns.vcproj +139 -0
  198. data/libnet/sample/win32/get_addr/CVS/Entries +2 -0
  199. data/libnet/sample/win32/get_addr/CVS/Repository +1 -0
  200. data/libnet/sample/win32/get_addr/CVS/Root +1 -0
  201. data/libnet/sample/win32/get_addr/get_addr.vcproj +139 -0
  202. data/libnet/sample/win32/getopt.c +121 -0
  203. data/libnet/sample/win32/icmp_echo_cq/CVS/Entries +2 -0
  204. data/libnet/sample/win32/icmp_echo_cq/CVS/Repository +1 -0
  205. data/libnet/sample/win32/icmp_echo_cq/CVS/Root +1 -0
  206. data/libnet/sample/win32/icmp_echo_cq/icmp_echo_cq.vcproj +139 -0
  207. data/libnet/sample/win32/tcp1/CVS/Entries +2 -0
  208. data/libnet/sample/win32/tcp1/CVS/Repository +1 -0
  209. data/libnet/sample/win32/tcp1/CVS/Root +1 -0
  210. data/libnet/sample/win32/tcp1/tcp1.vcproj +142 -0
  211. data/libnet/sample/win32/udp1/CVS/Entries +3 -0
  212. data/libnet/sample/win32/udp1/CVS/Repository +1 -0
  213. data/libnet/sample/win32/udp1/CVS/Root +1 -0
  214. data/libnet/sample/win32/udp1/dns.vcproj +125 -0
  215. data/libnet/sample/win32/udp1/udp1.vcproj +139 -0
  216. data/libnet/src/CVS/Entries +60 -0
  217. data/libnet/src/CVS/Repository +1 -0
  218. data/libnet/src/CVS/Root +1 -0
  219. data/libnet/src/Makefile.am +71 -0
  220. data/libnet/src/Makefile.in +428 -0
  221. data/libnet/src/libnet_advanced.c +136 -0
  222. data/libnet/src/libnet_asn1.c +436 -0
  223. data/libnet/src/libnet_build_802.1q.c +115 -0
  224. data/libnet/src/libnet_build_802.1x.c +103 -0
  225. data/libnet/src/libnet_build_802.2.c +167 -0
  226. data/libnet/src/libnet_build_802.3.c +101 -0
  227. data/libnet/src/libnet_build_arp.c +169 -0
  228. data/libnet/src/libnet_build_bgp.c +350 -0
  229. data/libnet/src/libnet_build_cdp.c +191 -0
  230. data/libnet/src/libnet_build_data.c +90 -0
  231. data/libnet/src/libnet_build_dhcp.c +156 -0
  232. data/libnet/src/libnet_build_dns.c +129 -0
  233. data/libnet/src/libnet_build_ethernet.c +173 -0
  234. data/libnet/src/libnet_build_fddi.c +191 -0
  235. data/libnet/src/libnet_build_gre.c +427 -0
  236. data/libnet/src/libnet_build_icmp.c +437 -0
  237. data/libnet/src/libnet_build_igmp.c +112 -0
  238. data/libnet/src/libnet_build_ip.c +892 -0
  239. data/libnet/src/libnet_build_ipsec.c +232 -0
  240. data/libnet/src/libnet_build_isl.c +113 -0
  241. data/libnet/src/libnet_build_link.c +90 -0
  242. data/libnet/src/libnet_build_mpls.c +112 -0
  243. data/libnet/src/libnet_build_ntp.c +121 -0
  244. data/libnet/src/libnet_build_ospf.c +699 -0
  245. data/libnet/src/libnet_build_rip.c +108 -0
  246. data/libnet/src/libnet_build_rpc.c +138 -0
  247. data/libnet/src/libnet_build_sebek.c +108 -0
  248. data/libnet/src/libnet_build_snmp.c +52 -0
  249. data/libnet/src/libnet_build_stp.c +222 -0
  250. data/libnet/src/libnet_build_tcp.c +365 -0
  251. data/libnet/src/libnet_build_token_ring.c +193 -0
  252. data/libnet/src/libnet_build_udp.c +111 -0
  253. data/libnet/src/libnet_build_vrrp.c +117 -0
  254. data/libnet/src/libnet_checksum.c +376 -0
  255. data/libnet/src/libnet_cq.c +395 -0
  256. data/libnet/src/libnet_crc.c +113 -0
  257. data/libnet/src/libnet_dll.c +47 -0
  258. data/libnet/src/libnet_error.c +55 -0
  259. data/libnet/src/libnet_if_addr.c +415 -0
  260. data/libnet/src/libnet_init.c +234 -0
  261. data/libnet/src/libnet_internal.c +310 -0
  262. data/libnet/src/libnet_link_bpf.c +348 -0
  263. data/libnet/src/libnet_link_dlpi.c +785 -0
  264. data/libnet/src/libnet_link_linux.c +310 -0
  265. data/libnet/src/libnet_link_nit.c +125 -0
  266. data/libnet/src/libnet_link_none.c +66 -0
  267. data/libnet/src/libnet_link_pf.c +179 -0
  268. data/libnet/src/libnet_link_snit.c +149 -0
  269. data/libnet/src/libnet_link_snoop.c +166 -0
  270. data/libnet/src/libnet_link_win32.c +346 -0
  271. data/libnet/src/libnet_pblock.c +511 -0
  272. data/libnet/src/libnet_port_list.c +295 -0
  273. data/libnet/src/libnet_prand.c +106 -0
  274. data/libnet/src/libnet_raw.c +257 -0
  275. data/libnet/src/libnet_resolve.c +414 -0
  276. data/libnet/src/libnet_version.c +54 -0
  277. data/libnet/src/libnet_write.c +502 -0
  278. data/libnet/version.h.in +6 -0
  279. data/libnet/win32/CVS/Entries +15 -0
  280. data/libnet/win32/CVS/Repository +1 -0
  281. data/libnet/win32/CVS/Root +1 -0
  282. data/libnet/win32/Libnet-1.1.1-2002.sln +77 -0
  283. data/libnet/win32/Libnet-1.1.1-2003.ncb +0 -0
  284. data/libnet/win32/Libnet-1.1.1-2003.sln +84 -0
  285. data/libnet/win32/Libnet-1.1.1-2003.suo +0 -0
  286. data/libnet/win32/Libnet-1.1.1.vcproj +311 -0
  287. data/libnet/win32/Libnet-latest.ncb +0 -0
  288. data/libnet/win32/Libnet-latest.opt +0 -0
  289. data/libnet/win32/Libnet-latest.sln +77 -0
  290. data/libnet/win32/Libnet-latest.suo +0 -0
  291. data/libnet/win32/Libnet-latest.vcproj +311 -0
  292. data/libnet/win32/Libnet.dsp +337 -0
  293. data/libnet/win32/Libnet.dsw +32 -0
  294. data/libnet/win32/README.txt +57 -0
  295. data/libnet/win32/libnet_dll.def +164 -0
  296. data/test/tc_arp.rb +169 -0
  297. data/test/tc_class.rb +219 -0
  298. data/test/tc_ethernet.rb +97 -0
  299. data/test/tc_header.rb +163 -0
  300. data/test/tc_init.rb +25 -0
  301. data/test/tc_ipv4.rb +219 -0
  302. data/test/tc_ipv6.rb +235 -0
  303. data/test/tc_udp.rb +229 -0
  304. data/test/tc_vlan.rb +118 -0
  305. data/test/ts_all.rb +15 -0
  306. metadata +401 -0
@@ -0,0 +1,1662 @@
1
+ /*
2
+ * $Id: libnet-headers.h,v 1.14 2004/03/11 18:50:20 mike Exp $
3
+ *
4
+ * libnet-headers.h - Network routine library headers header file
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_HEADERS_H
33
+ #define __LIBNET_HEADERS_H
34
+ /**
35
+ * @file libnet-headers.h
36
+ * @brief libnet header information
37
+ */
38
+
39
+ /**
40
+ * Libnet defines header sizes for every builder function exported.
41
+ */
42
+ #define LIBNET_802_1Q_H 0x12 /**< 802.1Q header: 18 bytes */
43
+ #define LIBNET_802_1X_H 0x04 /**< 802.1X header: 4 bytes */
44
+ #define LIBNET_802_2_H 0x03 /**< 802.2 LLC header: 3 bytes */
45
+ #define LIBNET_802_2SNAP_H 0x08 /**< 802.2 LLC/SNAP header:8 bytes */
46
+ #define LIBNET_802_3_H 0x0e /**< 802.3 header: 14 bytes */
47
+ #define LIBNET_ARP_H 0x08 /**< ARP header w/o addrs: 8 bytes */
48
+ #define LIBNET_ARP_ETH_IP_H 0x1c /**< ARP w/ ETH and IP: 28 bytes */
49
+ #define LIBNET_BGP4_HEADER_H 0x13 /**< BGP header: 19 bytes */
50
+ #define LIBNET_BGP4_OPEN_H 0x0a /**< BGP open header: 10 bytes */
51
+ #define LIBNET_BGP4_UPDATE_H 0x04 /**< BGP open header: 4 bytes */
52
+ #define LIBNET_BGP4_NOTIFICATION_H 0x02 /**< BGP notif. header: 2 bytes */
53
+ #define LIBNET_CDP_H 0x08 /**< CDP header base: 8 bytes */
54
+ #define LIBNET_DHCPV4_H 0xf0 /**< DHCP v4 header: 240 bytes */
55
+ #define LIBNET_UDP_DNSV4_H 0x0c /**< UDP DNS v4 header: 12 bytes */
56
+ #define LIBNET_TCP_DNSV4_H 0x0e /**< TCP DNS v4 header: 14 bytes */
57
+ #define LIBNET_ETH_H 0x0e /**< Ethernet header: 14 bytes */
58
+ #define LIBNET_FDDI_H 0x15 /**< FDDI header: 21 bytes */
59
+ #define LIBNET_ICMPV4_H 0x04 /**< ICMP header base: 4 bytes */
60
+ #define LIBNET_ICMPV4_ECHO_H 0x08 /**< ICMP_ECHO header: 8 bytes */
61
+ #define LIBNET_ICMPV4_MASK_H 0x0c /**< ICMP_MASK header: 12 bytes */
62
+ #define LIBNET_ICMPV4_UNREACH_H 0x08 /**< ICMP_UNREACH header: 8 bytes */
63
+ #define LIBNET_ICMPV4_TIMXCEED_H 0x08 /**< ICMP_TIMXCEED header: 8 bytes */
64
+ #define LIBNET_ICMPV4_REDIRECT_H 0x08 /**< ICMP_REDIRECT header: 8 bytes */
65
+ #define LIBNET_ICMPV4_TS_H 0x14 /**< ICMP_TIMESTAMP headr:20 bytes */
66
+ #define LIBNET_ICMPV6_H 0x08 /**< ICMP6 header base: 8 bytes */
67
+ #define LIBNET_IGMP_H 0x08 /**< IGMP header: 8 bytes */
68
+ #define LIBNET_IPV4_H 0x14 /**< IPv4 header: 20 bytes */
69
+ #define LIBNET_IPV6_H 0x28 /**< IPv6 header: 40 bytes */
70
+ #define LIBNET_IPV6_FRAG_H 0x08 /**< IPv6 frag header: 8 bytes */
71
+ #define LIBNET_IPV6_ROUTING_H 0x04 /**< IPv6 frag header base:4 bytes */
72
+ #define LIBNET_IPV6_DESTOPTS_H 0x02 /**< IPv6 dest opts base: 2 bytes */
73
+ #define LIBNET_IPV6_HBHOPTS_H 0x02 /**< IPv6 hop/hop opt base:2 bytes */
74
+ #define LIBNET_IPSEC_ESP_HDR_H 0x0c /**< IPSEC ESP header: 12 bytes */
75
+ #define LIBNET_IPSEC_ESP_FTR_H 0x02 /**< IPSEC ESP footer: 2 bytes */
76
+ #define LIBNET_IPSEC_AH_H 0x10 /**< IPSEC AH header: 16 bytes */
77
+ #define LIBNET_ISL_H 0x1a /**< ISL header: 26 bytes */
78
+ #define LIBNET_GRE_H 0x04 /**< GRE header: 4 bytes */
79
+ #define LIBNET_GRE_SRE_H 0x04 /**< GRE SRE header: 4 bytes */
80
+ #define LIBNET_MPLS_H 0x04 /**< MPLS header: 4 bytes */
81
+ #define LIBNET_OSPF_H 0x10 /**< OSPF header: 16 bytes */
82
+ #define LIBNET_OSPF_HELLO_H 0x18 /**< OSPF hello header: 24 bytes */
83
+ #define LIBNET_OSPF_DBD_H 0x08 /**< OSPF DBD header: 8 bytes */
84
+ #define LIBNET_OSPF_LSR_H 0x0c /**< OSPF LSR header: 12 bytes */
85
+ #define LIBNET_OSPF_LSU_H 0x04 /**< OSPF LSU header: 4 bytes */
86
+ #define LIBNET_OSPF_LSA_H 0x14 /**< OSPF LSA header: 20 bytes */
87
+ #define LIBNET_OSPF_AUTH_H 0x08 /**< OSPF AUTH header: 8 bytes */
88
+ #define LIBNET_OSPF_CKSUM 0x10 /**< OSPF CKSUM header: 16 bytes */
89
+ #define LIBNET_OSPF_LS_RTR_H 0x10 /**< OSPF LS RTR header: 16 bytes */
90
+ #define LIBNET_OSPF_LS_NET_H 0x08 /**< OSPF LS NET header: 8 bytes */
91
+ #define LIBNET_OSPF_LS_SUM_H 0x0c /**< OSPF LS SUM header: 12 bytes */
92
+ #define LIBNET_OSPF_LS_AS_EXT_H 0x10 /**< OSPF LS AS header: 16 bytes */
93
+ #define LIBNET_NTP_H 0x30 /**< NTP header: 48 bytes */
94
+ #define LIBNET_RIP_H 0x18 /**< RIP header base: 24 bytes */
95
+ #define LIBNET_RPC_CALL_H 0x28 /**< RPC header: 40 bytes
96
+ * (assuming 8 byte auth header)
97
+ */
98
+ #define LIBNET_RPC_CALL_TCP_H 0x2c /**< RPC header: 44 bytes
99
+ * (with record marking)
100
+ */
101
+ #define LIBNET_SEBEK_H 0x30 /* sebek header: 48 bytes */
102
+ #define LIBNET_STP_CONF_H 0x23 /**< STP conf header: 35 bytes */
103
+ #define LIBNET_STP_TCN_H 0x04 /**< STP tcn header: 4 bytes */
104
+ #define LIBNET_TOKEN_RING_H 0x16 /**< Token Ring header: 22 bytes */
105
+ #define LIBNET_TCP_H 0x14 /**< TCP header: 20 bytes */
106
+ #define LIBNET_UDP_H 0x08 /**< UDP header: 8 bytes */
107
+ #define LIBNET_VRRP_H 0x08 /**< VRRP header: 8 bytes */
108
+
109
+ /**
110
+ * IEEE 802.1Q (Virtual Local Area Network) VLAN header, static header
111
+ * size: 18 bytes
112
+ */
113
+ struct libnet_802_1q_hdr
114
+ {
115
+ u_int8_t vlan_dhost[ETHER_ADDR_LEN]; /**< destination ethernet address */
116
+ u_int8_t vlan_shost[ETHER_ADDR_LEN]; /**< source ethernet address */
117
+ u_int16_t vlan_tpi; /**< tag protocol ID */
118
+ u_int16_t vlan_priority_c_vid; /**< priority | VLAN ID */
119
+ #define LIBNET_802_1Q_PRIMASK 0x0007 /**< priority mask */
120
+ #define LIBNET_802_1Q_CFIMASK 0x0001 /**< CFI mask */
121
+ #define LIBNET_802_1Q_VIDMASK 0x0fff /**< vid mask */
122
+ u_int16_t vlan_len; /**< length or type (802.3 / Eth 2) */
123
+ };
124
+
125
+ /**
126
+ * IEEE 802.1X EAP (Extensible Authentication Protocol) header, static header
127
+ * size: 4 bytes
128
+ */
129
+ struct libnet_802_1x_hdr
130
+ {
131
+ u_int8_t dot1x_version; /**< protocol version */
132
+ u_int8_t dot1x_type; /**< frame type */
133
+ #define LIBNET_802_1X_PACKET 0x00 /**< 802.1x packet */
134
+ #define LIBNET_802_1X_START 0x01 /**< 802.1x start */
135
+ #define LIBNET_802_1X_LOGOFF 0x02 /**< 802.1x logoff */
136
+ #define LIBNET_802_1X_KEY 0x03 /**< 802.1x key */
137
+ #define LIBNET_802_1X_ENCASFAL 0x04 /**< 802.1x encasfal */
138
+ u_int16_t dot1x_length; /**< total frame length */
139
+ };
140
+
141
+ /*
142
+ * IEEE 802.2 LLC header
143
+ * Link Layer Control
144
+ * static header size: 3 bytes
145
+ */
146
+ struct libnet_802_2_hdr
147
+ {
148
+ u_int8_t llc_dsap; /* destination service access point */
149
+ u_int8_t llc_ssap; /* source service access point */
150
+ #define LIBNET_SAP_STP 0x42
151
+ #define LIBNET_SAP_SNAP 0xaa
152
+ u_int8_t llc_control; /* control field */
153
+ };
154
+
155
+
156
+ /*
157
+ * IEEE 802.2 LLC/SNAP header
158
+ * SubNetwork Attachment Point
159
+ * static header size: 8 bytes
160
+ */
161
+ struct libnet_802_2snap_hdr
162
+ {
163
+ u_int8_t snap_dsap; /* destination service access point */
164
+ u_int8_t snap_ssap; /* destination service access point */
165
+ u_int8_t snap_control; /* control field */
166
+ u_int8_t snap_oui[3]; /* OUI */
167
+ u_int16_t snap_type; /* type */
168
+ };
169
+
170
+
171
+ /*
172
+ * 802.3 header
173
+ * IEEE Ethernet
174
+ * Static header size: 14 bytes
175
+ */
176
+ struct libnet_802_3_hdr
177
+ {
178
+ u_int8_t _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
179
+ u_int8_t _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */
180
+ u_int16_t _802_3_len; /* packet type ID */
181
+ };
182
+
183
+
184
+ /*
185
+ * ARP header
186
+ * Address Resolution Protocol
187
+ * Base header size: 8 bytes
188
+ */
189
+ struct libnet_arp_hdr
190
+ {
191
+ u_int16_t ar_hrd; /* format of hardware address */
192
+ #define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */
193
+ #define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
194
+ #define ARPHRD_EETHER 2 /* Experimental Ethernet */
195
+ #define ARPHRD_AX25 3 /* AX.25 Level 2 */
196
+ #define ARPHRD_PRONET 4 /* PROnet token ring */
197
+ #define ARPHRD_CHAOS 5 /* Chaosnet */
198
+ #define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */
199
+ #define ARPHRD_ARCNET 7 /* ARCnet */
200
+ #define ARPHRD_APPLETLK 8 /* APPLEtalk */
201
+ #define ARPHRD_LANSTAR 9 /* Lanstar */
202
+ #define ARPHRD_DLCI 15 /* Frame Relay DLCI */
203
+ #define ARPHRD_ATM 19 /* ATM */
204
+ #define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */
205
+ #define ARPHRD_IPSEC 31 /* IPsec tunnel */
206
+ u_int16_t ar_pro; /* format of protocol address */
207
+ u_int8_t ar_hln; /* length of hardware address */
208
+ u_int8_t ar_pln; /* length of protocol addres */
209
+ u_int16_t ar_op; /* operation type */
210
+ #define ARPOP_REQUEST 1 /* req to resolve address */
211
+ #define ARPOP_REPLY 2 /* resp to previous request */
212
+ #define ARPOP_REVREQUEST 3 /* req protocol address given hardware */
213
+ #define ARPOP_REVREPLY 4 /* resp giving protocol address */
214
+ #define ARPOP_INVREQUEST 8 /* req to identify peer */
215
+ #define ARPOP_INVREPLY 9 /* resp identifying peer */
216
+ /* address information allocated dynamically */
217
+ };
218
+
219
+ /*
220
+ * BGP4 header
221
+ * Border Gateway Protocol 4
222
+ * Base header size : 19 bytes
223
+ */
224
+ struct libnet_bgp4_header_hdr
225
+ {
226
+ #define LIBNET_BGP4_MARKER_SIZE 16
227
+ u_int8_t marker[LIBNET_BGP4_MARKER_SIZE];
228
+ u_int16_t len;
229
+ u_int8_t type;
230
+ #define LIBNET_BGP4_OPEN 1
231
+ #define LIBNET_BGP4_UPDATE 2
232
+ #define LIBNET_BGP4_NOTIFICATION 3
233
+ #define LIBNET_BGP4_KEEPALIVE 4
234
+ };
235
+
236
+ /*
237
+ * BGP4 open header
238
+ * Border Gateway Protocol 4
239
+ * Base header size : 10 bytes
240
+ */
241
+ struct libnet_bgp4_open_hdr
242
+ {
243
+ u_int8_t version;
244
+ u_int16_t src_as;
245
+ u_int16_t hold_time;
246
+ u_int32_t bgp_id;
247
+ u_int8_t opt_len;
248
+ };
249
+
250
+ /*
251
+ * BGP4 notification message
252
+ *
253
+ * Border Gateway Protocol 4
254
+ * Base header size : 2 bytes
255
+ *
256
+ * Use payload if you need data
257
+ */
258
+ struct libnet_bgp4_notification_hdr
259
+ {
260
+ #define LIBNET_BGP4_MESSAGE_HEADER_ERROR 1
261
+ #define LIBNET_BGP4_OPEN_MESSAGE_ERROR 2
262
+ #define LIBNET_BGP4_UPDATE_MESSAGE_ERROR 3
263
+ #define LIBNET_BGP4_HOLD_TIMER_EXPIRED 4
264
+ #define LIBNET_BGP4_FINITE_STATE__ERROR 5
265
+ #define LIBNET_BGP4_CEASE 6
266
+ u_int8_t err_code;
267
+
268
+ /* Message Header Error subcodes */
269
+ #define LIBNET_BGP4_CONNECTION_NOT_SYNCHRONIZED 1
270
+ #define LIBNET_BGP4_BAD_MESSAGE_LENGTH 2
271
+ #define LIBNET_BGP4_BAD_MESSAGE_TYPE 3
272
+ /* OPEN Message Error subcodes */
273
+ #define LIBNET_BGP4_UNSUPPORTED_VERSION_NUMBER 1
274
+ #define LIBNET_BGP4_BAD_PEER_AS 2
275
+ #define LIBNET_BGP4_BAD_BGP_IDENTIFIER 3
276
+ #define LIBNET_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4
277
+ #define LIBNET_BGP4_AUTHENTICATION_FAILURE 5
278
+ #define LIBNET_BGP4_UNACCEPTABLE_HOLD_TIME 6
279
+ /* UPDATE Message Error subcodes */
280
+ #define LIBNET_BGP4_MALFORMED_ATTRIBUTE_LIST
281
+ #define LIBNET_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE
282
+ #define LIBNET_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE
283
+ #define LIBNET_BGP4_ATTRIBUTE_FLAGS_ERROR
284
+ #define LIBNET_BGP4_ATTRIBUTE_LENGTH_ERROR
285
+ #define LIBNET_BGP4_INVALID_ORIGIN_ATTRIBUTE
286
+ #define LIBNET_BGP4_AS_ROUTING_LOOP
287
+ #define LIBNET_BGP4_INVALID_NEXT_HOP_ATTRIBUTE
288
+ #define LIBNET_BGP4_OPTIONAL_ATTRIBUTE_ERROR
289
+ #define LIBNET_BGP4_INVALID_NETWORK_FIELD
290
+ #define LIBNET_BGP4_MALFORMED_AS_PATH
291
+ u_int8_t err_subcode;
292
+ };
293
+
294
+
295
+
296
+ /*
297
+ * CDP header
298
+ * Cisco Discovery Protocol
299
+ * Base header size: 8 bytes
300
+ */
301
+
302
+ /*
303
+ * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
304
+ * Let's hope this one stays that way for a while!
305
+ */
306
+ #define LIBNET_PROTO_CDP 200
307
+ struct libnet_cdp_hdr
308
+ {
309
+ u_int8_t cdp_version; /* version (should always be 0x01) */
310
+ u_int8_t cdp_ttl; /* time reciever should hold info in this packet */
311
+ u_int16_t cdp_sum; /* checksum */
312
+ u_int16_t cdp_type; /* type */
313
+ #define LIBNET_CDP_DEVID 0x1 /* device id */
314
+ #define LIBNET_CDP_ADDRESS 0x2 /* address */
315
+ #define LIBNET_CDP_PORTID 0x3 /* port id */
316
+ #define LIBNET_CDP_CAPABIL 0x4 /* capabilities */
317
+ #define LIBNET_CDP_VERSION 0x5 /* version */
318
+ #define LIBNET_CDP_PLATFORM 0x6 /* platform */
319
+ #define LIBNET_CDP_IPPREFIX 0x7 /* ip prefix */
320
+ u_int16_t cdp_len; /* type + length + value */
321
+ /* value information done dynamically */
322
+
323
+ /* CDP capabilities */
324
+ #define LIBNET_CDP_CAP_L3R 0x01/* performs level 3 routing */
325
+ #define LIBNET_CDP_CAP_L2B 0x02/* performs level 2 transparent bridging */
326
+ #define LIBNET_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging */
327
+ #define LIBNET_CDP_CAP_L2S 0x08/* performs level 2 switching */
328
+ #define LIBNET_CDP_CAP_SR 0x10/* sends and recieves packets on a network */
329
+ #define LIBNET_CDP_CAP_NOI 0x20/* does not forward IGMP on non-router ports */
330
+ #define LIBNET_CDP_CAP_L1F 0x40/* provides level 1 functionality */
331
+ };
332
+
333
+
334
+ /*
335
+ * Used as an overlay for type/len/values
336
+ */
337
+ struct libnet_cdp_value_hdr
338
+ {
339
+ u_int16_t cdp_type;
340
+ u_int16_t cdp_len;
341
+ };
342
+
343
+
344
+ /*
345
+ * DHCP header
346
+ * Dynamic Host Configuration Protocol
347
+ * Static header size: f0 bytes
348
+ */
349
+ struct libnet_dhcpv4_hdr
350
+ {
351
+ u_int8_t dhcp_opcode; /* opcode */
352
+ #define LIBNET_DHCP_REQUEST 0x1
353
+ #define LIBNET_DHCP_REPLY 0x2
354
+ u_int8_t dhcp_htype; /* hardware address type */
355
+ u_int8_t dhcp_hlen; /* hardware address length */
356
+ u_int8_t dhcp_hopcount; /* used by proxy servers */
357
+ u_int32_t dhcp_xid; /* transaction ID */
358
+ u_int16_t dhcp_secs; /* number of seconds since trying to bootstrap */
359
+ u_int16_t dhcp_flags; /* flags for DHCP, unused for BOOTP */
360
+ u_int32_t dhcp_cip; /* client's IP */
361
+ u_int32_t dhcp_yip; /* your IP */
362
+ u_int32_t dhcp_sip; /* server's IP */
363
+ u_int32_t dhcp_gip; /* gateway IP */
364
+ u_int8_t dhcp_chaddr[16]; /* client hardware address */
365
+ u_int8_t dhcp_sname[64]; /* server host name */
366
+ u_int8_t dhcp_file[128]; /* boot file name */
367
+ u_int32_t dhcp_magic; /* BOOTP magic header */
368
+ #define DHCP_MAGIC 0x63825363
369
+ #define LIBNET_BOOTP_MIN_LEN 0x12c
370
+ #define LIBNET_DHCP_PAD 0x00
371
+ #define LIBNET_DHCP_SUBNETMASK 0x01
372
+ #define LIBNET_DHCP_TIMEOFFSET 0x02
373
+ #define LIBNET_DHCP_ROUTER 0x03
374
+ #define LIBNET_DHCP_TIMESERVER 0x04
375
+ #define LIBNET_DHCP_NAMESERVER 0x05
376
+ #define LIBNET_DHCP_DNS 0x06
377
+ #define LIBNET_DHCP_LOGSERV 0x07
378
+ #define LIBNET_DHCP_COOKIESERV 0x08
379
+ #define LIBNET_DHCP_LPRSERV 0x09
380
+ #define LIBNET_DHCP_IMPSERV 0x0a
381
+ #define LIBNET_DHCP_RESSERV 0x0b
382
+ #define LIBNET_DHCP_HOSTNAME 0x0c
383
+ #define LIBNET_DHCP_BOOTFILESIZE 0x0d
384
+ #define LIBNET_DHCP_DUMPFILE 0x0e
385
+ #define LIBNET_DHCP_DOMAINNAME 0x0f
386
+ #define LIBNET_DHCP_SWAPSERV 0x10
387
+ #define LIBNET_DHCP_ROOTPATH 0x11
388
+ #define LIBNET_DHCP_EXTENPATH 0x12
389
+ #define LIBNET_DHCP_IPFORWARD 0x13
390
+ #define LIBNET_DHCP_SRCROUTE 0x14
391
+ #define LIBNET_DHCP_POLICYFILTER 0x15
392
+ #define LIBNET_DHCP_MAXASMSIZE 0x16
393
+ #define LIBNET_DHCP_IPTTL 0x17
394
+ #define LIBNET_DHCP_MTUTIMEOUT 0x18
395
+ #define LIBNET_DHCP_MTUTABLE 0x19
396
+ #define LIBNET_DHCP_MTUSIZE 0x1a
397
+ #define LIBNET_DHCP_LOCALSUBNETS 0x1b
398
+ #define LIBNET_DHCP_BROADCASTADDR 0x1c
399
+ #define LIBNET_DHCP_DOMASKDISCOV 0x1d
400
+ #define LIBNET_DHCP_MASKSUPPLY 0x1e
401
+ #define LIBNET_DHCP_DOROUTEDISC 0x1f
402
+ #define LIBNET_DHCP_ROUTERSOLICIT 0x20
403
+ #define LIBNET_DHCP_STATICROUTE 0x21
404
+ #define LIBNET_DHCP_TRAILERENCAP 0x22
405
+ #define LIBNET_DHCP_ARPTIMEOUT 0x23
406
+ #define LIBNET_DHCP_ETHERENCAP 0x24
407
+ #define LIBNET_DHCP_TCPTTL 0x25
408
+ #define LIBNET_DHCP_TCPKEEPALIVE 0x26
409
+ #define LIBNET_DHCP_TCPALIVEGARBAGE 0x27
410
+ #define LIBNET_DHCP_NISDOMAIN 0x28
411
+ #define LIBNET_DHCP_NISSERVERS 0x29
412
+ #define LIBNET_DHCP_NISTIMESERV 0x2a
413
+ #define LIBNET_DHCP_VENDSPECIFIC 0x2b
414
+ #define LIBNET_DHCP_NBNS 0x2c
415
+ #define LIBNET_DHCP_NBDD 0x2d
416
+ #define LIBNET_DHCP_NBTCPIP 0x2e
417
+ #define LIBNET_DHCP_NBTCPSCOPE 0x2f
418
+ #define LIBNET_DHCP_XFONT 0x30
419
+ #define LIBNET_DHCP_XDISPLAYMGR 0x31
420
+ #define LIBNET_DHCP_DISCOVERADDR 0x32
421
+ #define LIBNET_DHCP_LEASETIME 0x33
422
+ #define LIBNET_DHCP_OPTIONOVERLOAD 0x34
423
+ #define LIBNET_DHCP_MESSAGETYPE 0x35
424
+ #define LIBNET_DHCP_SERVIDENT 0x36
425
+ #define LIBNET_DHCP_PARAMREQUEST 0x37
426
+ #define LIBNET_DHCP_MESSAGE 0x38
427
+ #define LIBNET_DHCP_MAXMSGSIZE 0x39
428
+ #define LIBNET_DHCP_RENEWTIME 0x3a
429
+ #define LIBNET_DHCP_REBINDTIME 0x3b
430
+ #define LIBNET_DHCP_CLASSSID 0x3c
431
+ #define LIBNET_DHCP_CLIENTID 0x3d
432
+ #define LIBNET_DHCP_NISPLUSDOMAIN 0x40
433
+ #define LIBNET_DHCP_NISPLUSSERVERS 0x41
434
+ #define LIBNET_DHCP_MOBILEIPAGENT 0x44
435
+ #define LIBNET_DHCP_SMTPSERVER 0x45
436
+ #define LIBNET_DHCP_POP3SERVER 0x46
437
+ #define LIBNET_DHCP_NNTPSERVER 0x47
438
+ #define LIBNET_DHCP_WWWSERVER 0x48
439
+ #define LIBNET_DHCP_FINGERSERVER 0x49
440
+ #define LIBNET_DHCP_IRCSERVER 0x4a
441
+ #define LIBNET_DHCP_STSERVER 0x4b
442
+ #define LIBNET_DHCP_STDASERVER 0x4c
443
+ #define LIBNET_DHCP_END 0xff
444
+
445
+ #define LIBNET_DHCP_MSGDISCOVER 0x01
446
+ #define LIBNET_DHCP_MSGOFFER 0x02
447
+ #define LIBNET_DHCP_MSGREQUEST 0x03
448
+ #define LIBNET_DHCP_MSGDECLINE 0x04
449
+ #define LIBNET_DHCP_MSGACK 0x05
450
+ #define LIBNET_DHCP_MSGNACK 0x06
451
+ #define LIBNET_DHCP_MSGRELEASE 0x07
452
+ #define LIBNET_DHCP_MSGINFORM 0x08
453
+ };
454
+
455
+
456
+ /*
457
+ * Base DNSv4 header
458
+ * Domain Name System
459
+ * Base header size: 12/14 bytes
460
+ */
461
+ /* this little guy got left out in the cold */
462
+ #define LIBNET_DNS_H LIBNET_UDP_DNSV4_H
463
+ struct libnet_dnsv4_hdr
464
+ {
465
+ u_int16_t h_len; /* length of the packet - only used with TCP */
466
+ u_int16_t id; /* DNS packet ID */
467
+ u_int16_t flags; /* DNS flags */
468
+ u_int16_t num_q; /* Number of questions */
469
+ u_int16_t num_answ_rr; /* Number of answer resource records */
470
+ u_int16_t num_auth_rr; /* Number of authority resource records */
471
+ u_int16_t num_addi_rr; /* Number of additional resource records */
472
+ };
473
+
474
+
475
+ /*
476
+ * Ethernet II header
477
+ * Static header size: 14 bytes
478
+ */
479
+ struct libnet_ethernet_hdr
480
+ {
481
+ u_int8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
482
+ u_int8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */
483
+ u_int16_t ether_type; /* protocol */
484
+ };
485
+
486
+ #ifndef ETHERTYPE_PUP
487
+ #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
488
+ #endif
489
+ #ifndef ETHERTYPE_IP
490
+ #define ETHERTYPE_IP 0x0800 /* IP protocol */
491
+ #endif
492
+ #ifndef ETHERTYPE_ARP
493
+ #define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */
494
+ #endif
495
+ #ifndef ETHERTYPE_REVARP
496
+ #define ETHERTYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
497
+ #endif
498
+ #ifndef ETHERTYPE_VLAN
499
+ #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
500
+ #endif
501
+ #ifndef ETHERTYPE_EAP
502
+ #define ETHERTYPE_EAP 0x888e /* IEEE 802.1X EAP authentication */
503
+ #endif
504
+ #ifndef ETHERTYPE_MPLS
505
+ #define ETHERTYPE_MPLS 0x8847 /* MPLS */
506
+ #endif
507
+ #ifndef ETHERTYPE_LOOPBACK
508
+ #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
509
+ #endif
510
+
511
+ struct libnet_ether_addr
512
+ {
513
+ u_int8_t ether_addr_octet[6]; /* Ethernet address */
514
+ };
515
+
516
+ /*
517
+ * Fiber Distributed Data Interface header
518
+ *
519
+ * Static header size: 21 bytes (LLC and 48-bit address addr only)
520
+ *
521
+ * Note: Organization field is 3 bytes which throws off the
522
+ * alignment of type. Therefore fddi_type (19 bytes in)
523
+ * is specified as two u_int8_ts.
524
+ */
525
+ struct libnet_fddi_hdr
526
+ {
527
+ u_int8_t fddi_frame_control; /* Class/Format/Priority */
528
+ #define LIBNET_FDDI_LLC_FRAME 0x10
529
+ #define LIBNET_FDDI_48BIT_ADDR 0x40
530
+ #define LIBNET_FDDI_FC_REQD LIBNET_FDDI_LLC_FRAME | LIBNET_FDDI_48BIT_ADDR
531
+ u_int8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi address */
532
+ u_int8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi address */
533
+ u_int8_t fddi_llc_dsap; /* DSAP */
534
+ u_int8_t fddi_llc_ssap; /* SSAP */
535
+ u_int8_t fddi_llc_control_field; /* Class/Format/Priority */
536
+ u_int8_t fddi_llc_org_code[LIBNET_ORG_CODE_SIZE]; /* Organization Code 3-bytes */
537
+ u_int8_t fddi_type; /* Protocol Type */
538
+ u_int8_t fddi_type1; /* see note above. */
539
+ #define FDDI_TYPE_IP 0x0800 /* IP protocol */
540
+ #define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */
541
+ #define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
542
+ };
543
+
544
+
545
+ struct libnet_fddi_addr
546
+ {
547
+ u_int8_t fddi_addr_octet[6]; /* FDDI address */
548
+ };
549
+
550
+
551
+ /*
552
+ * GRE header - RFC 1701 & 2637
553
+ * Generic Routing Encapsulation (GRE)
554
+ * Base header size: 4 bytes
555
+ */
556
+ struct libnet_gre_hdr
557
+ {
558
+ u_int16_t flags_ver;
559
+ #define GRE_CSUM 0x8000
560
+ #define GRE_ROUTING 0x4000
561
+ #define GRE_KEY 0x2000
562
+ #define GRE_SEQ 0x1000
563
+ #define GRE_STRICT 0x0800
564
+ #define GRE_REC 0x0700
565
+ #define GRE_ACK 0x0080
566
+
567
+ #define GRE_FLAGS_MASK 0x00F8
568
+ #define GRE_VERSION_MASK 0x0007
569
+
570
+ #define GRE_VERSION_0 0x0000
571
+ #define GRE_VERSION_1 0x0001
572
+
573
+ u_int16_t type;
574
+ #define GRE_SNA 0x0004
575
+ #define GRE_OSI_NETWORK_LAYER 0x00FE
576
+ #define GRE_PUP 0x0200
577
+ #define GRE_XNS 0x0600
578
+ #define GRE_IP 0x0800
579
+ #define GRE_CHAOS 0x0804
580
+ #define GRE_RFC_826_ARP 0x0806
581
+ #define GRE_FRAME_RELAY_ARP 0x0808
582
+ #define GRE_VINES 0x0BAD
583
+ #define GRE_VINES_ECHO 0x0BAE
584
+ #define GRE_VINES_LOOPBACK 0x0BAF
585
+ #define GRE_DECNET 0x6003
586
+ #define GRE_TRANSPARENT_ETHERNET_BRIDGING 0x6558
587
+ #define GRE_RAW_FRAME_RELAY 0x6559
588
+ #define GRE_APOLLO_DOMAIN 0x8019
589
+ #define GRE_ETHERTALK 0x809B
590
+ #define GRE_NOVELL_IPX 0x8137
591
+ #define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B
592
+ #define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C
593
+ #define GRE_SECURE_DATA 0x876D
594
+ #define GRE_PPP 0x880b /* taken from RFC 2637 */
595
+
596
+ union {
597
+ struct {
598
+ u_int16_t sum; /* optional */
599
+ u_int16_t offset; /* optional */
600
+ u_int32_t key; /* optional */
601
+ u_int32_t seq; /* optional */
602
+ } _gre;
603
+
604
+ struct {
605
+ u_int16_t payload_s; /* optional */
606
+ u_int16_t callID; /* optional */
607
+ u_int32_t seq; /* optional */
608
+ u_int32_t ack; /* optional */
609
+ } _egre;
610
+ }_data;
611
+
612
+ #define gre_sum _data._gre.sum
613
+ #define gre_offset _data._gre.offset
614
+ #define gre_key _data._gre.key
615
+ #define gre_seq _data._gre.seq
616
+
617
+ #define egre_payload_s _data._egre.payload_s
618
+ #define egre_callID _data._egre.callID
619
+ #define egre_seq _data._egre.seq
620
+ #define egre_ack _data._egre.ack
621
+ };
622
+
623
+
624
+ #ifndef IPPROTO_GRE
625
+ #define IPPROTO_GRE 47
626
+ #endif
627
+
628
+ /*
629
+ * Source Route Entries (SRE)
630
+ * This is used for GRE as the Routing field is a list of SREs - RFC 1701
631
+ * Base header size: 4 bytes
632
+ */
633
+ struct libnet_gre_sre_hdr
634
+ {
635
+ u_int16_t af; /* address familly */
636
+ u_int8_t sre_offset;
637
+ u_int8_t sre_length;
638
+ u_int8_t *routing;
639
+ };
640
+
641
+
642
+ /*
643
+ * IPv4 header
644
+ * Internet Protocol, version 4
645
+ * Static header size: 20 bytes
646
+ */
647
+ struct libnet_ipv4_hdr
648
+ {
649
+ #if (LIBNET_LIL_ENDIAN)
650
+ u_int8_t ip_hl:4, /* header length */
651
+ ip_v:4; /* version */
652
+ #endif
653
+ #if (LIBNET_BIG_ENDIAN)
654
+ u_int8_t ip_v:4, /* version */
655
+ ip_hl:4; /* header length */
656
+ #endif
657
+ u_int8_t ip_tos; /* type of service */
658
+ #ifndef IPTOS_LOWDELAY
659
+ #define IPTOS_LOWDELAY 0x10
660
+ #endif
661
+ #ifndef IPTOS_THROUGHPUT
662
+ #define IPTOS_THROUGHPUT 0x08
663
+ #endif
664
+ #ifndef IPTOS_RELIABILITY
665
+ #define IPTOS_RELIABILITY 0x04
666
+ #endif
667
+ #ifndef IPTOS_LOWCOST
668
+ #define IPTOS_LOWCOST 0x02
669
+ #endif
670
+ u_int16_t ip_len; /* total length */
671
+ u_int16_t ip_id; /* identification */
672
+ u_int16_t ip_off;
673
+ #ifndef IP_RF
674
+ #define IP_RF 0x8000 /* reserved fragment flag */
675
+ #endif
676
+ #ifndef IP_DF
677
+ #define IP_DF 0x4000 /* dont fragment flag */
678
+ #endif
679
+ #ifndef IP_MF
680
+ #define IP_MF 0x2000 /* more fragments flag */
681
+ #endif
682
+ #ifndef IP_OFFMASK
683
+ #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
684
+ #endif
685
+ u_int8_t ip_ttl; /* time to live */
686
+ u_int8_t ip_p; /* protocol */
687
+ u_int16_t ip_sum; /* checksum */
688
+ struct in_addr ip_src, ip_dst; /* source and dest address */
689
+ };
690
+
691
+ /*
692
+ * IP options
693
+ */
694
+ #ifndef IPOPT_EOL
695
+ #define IPOPT_EOL 0 /* end of option list */
696
+ #endif
697
+ #ifndef IPOPT_NOP
698
+ #define IPOPT_NOP 1 /* no operation */
699
+ #endif
700
+ #ifndef IPOPT_RR
701
+ #define IPOPT_RR 7 /* record packet route */
702
+ #endif
703
+ #ifndef IPOPT_TS
704
+ #define IPOPT_TS 68 /* timestamp */
705
+ #endif
706
+ #ifndef IPOPT_SECURITY
707
+ #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
708
+ #endif
709
+ #ifndef IPOPT_LSRR
710
+ #define IPOPT_LSRR 131 /* loose source route */
711
+ #endif
712
+ #ifndef IPOPT_SATID
713
+ #define IPOPT_SATID 136 /* satnet id */
714
+ #endif
715
+ #ifndef IPOPT_SSRR
716
+ #define IPOPT_SSRR 137 /* strict source route */
717
+ #endif
718
+
719
+ struct libnet_in6_addr
720
+ {
721
+ union
722
+ {
723
+ u_int8_t __u6_addr8[16];
724
+ u_int16_t __u6_addr16[8];
725
+ u_int32_t __u6_addr32[4];
726
+ } __u6_addr; /* 128-bit IP6 address */
727
+ };
728
+ #define libnet_s6_addr __u6_addr.__u6_addr8
729
+
730
+ /*
731
+ * IPv6 header
732
+ * Internet Protocol, version 6
733
+ * Static header size: 40 bytes
734
+ */
735
+ struct libnet_ipv6_hdr
736
+ {
737
+ u_int8_t ip_flags[4]; /* version, traffic class, flow label */
738
+ u_int16_t ip_len; /* total length */
739
+ u_int8_t ip_nh; /* next header */
740
+ u_int8_t ip_hl; /* hop limit */
741
+ struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */
742
+
743
+ };
744
+
745
+ /*
746
+ * IPv6 frag header
747
+ * Internet Protocol, version 6
748
+ * Static header size: 8 bytes
749
+ */
750
+ #define LIBNET_IPV6_NH_FRAGMENT 44
751
+ struct libnet_ipv6_frag_hdr
752
+ {
753
+ u_int8_t ip_nh; /* next header */
754
+ u_int8_t ip_reserved; /* reserved */
755
+ u_int16_t ip_frag; /* fragmentation stuff */
756
+ u_int32_t ip_id; /* id */
757
+ };
758
+
759
+ /*
760
+ * IPv6 routing header
761
+ * Internet Protocol, version 6
762
+ * Base header size: 4 bytes
763
+ */
764
+ #define LIBNET_IPV6_NH_ROUTING 43
765
+ struct libnet_ipv6_routing_hdr
766
+ {
767
+ u_int8_t ip_nh; /* next header */
768
+ u_int8_t ip_len; /* length of header in 8 octet units (sans 1st) */
769
+ u_int8_t ip_rtype; /* routing type */
770
+ u_int8_t ip_segments; /* segments left */
771
+ /* routing information allocated dynamically */
772
+ };
773
+
774
+ /*
775
+ * IPv6 destination options header
776
+ * Internet Protocol, version 6
777
+ * Base header size: 2 bytes
778
+ */
779
+ #define LIBNET_IPV6_NH_DESTOPTS 60
780
+ struct libnet_ipv6_destopts_hdr
781
+ {
782
+ u_int8_t ip_nh; /* next header */
783
+ u_int8_t ip_len; /* length of header in 8 octet units (sans 1st) */
784
+ /* destination options information allocated dynamically */
785
+ };
786
+
787
+ /*
788
+ * IPv6 hop by hop options header
789
+ * Internet Protocol, version 6
790
+ * Base header size: 2 bytes
791
+ */
792
+ #define LIBNET_IPV6_NH_HBH 0
793
+ struct libnet_ipv6_hbhopts_hdr
794
+ {
795
+ u_int8_t ip_nh; /* next header */
796
+ u_int8_t ip_len; /* length of header in 8 octet units (sans 1st) */
797
+ /* destination options information allocated dynamically */
798
+ };
799
+
800
+ /*
801
+ * ICMP6 header
802
+ * Internet Control Message Protocol v6
803
+ * Base header size: 8 bytes
804
+ */
805
+ #ifndef IPPROTO_ICMP6
806
+ #define IPPROTO_ICMP6 0x3a
807
+ #endif
808
+ struct libnet_icmpv6_hdr
809
+ {
810
+ u_int8_t icmp_type; /* ICMP type */
811
+ #ifndef ICMP6_ECHO
812
+ #define ICMP6_ECHO 128
813
+ #endif
814
+ #ifndef ICMP6_ECHOREPLY
815
+ #define ICMP6_ECHOREPLY 129
816
+ #endif
817
+ #ifndef ICMP6_UNREACH
818
+ #define ICMP6_UNREACH 1
819
+ #endif
820
+ #ifndef ICMP6_PKTTOOBIG
821
+ #define ICMP6_PKTTOOBIG 2
822
+ #endif
823
+ #ifndef ICMP6_TIMXCEED
824
+ #define ICMP6_TIMXCEED 3
825
+ #endif
826
+ #ifndef ICMP6_PARAMPROB
827
+ #define ICMP6_PARAMPROB 4
828
+ #endif
829
+ u_int8_t icmp_code; /* ICMP code */
830
+ u_int16_t icmp_sum; /* ICMP Checksum */
831
+ u_int16_t id; /* ICMP id */
832
+ u_int16_t seq; /* ICMP sequence number */
833
+ };
834
+
835
+
836
+
837
+ /*
838
+ * ICMP header
839
+ * Internet Control Message Protocol
840
+ * Base header size: 4 bytes
841
+ */
842
+ struct libnet_icmpv4_hdr
843
+ {
844
+ u_int8_t icmp_type; /* ICMP type */
845
+ #ifndef ICMP_ECHOREPLY
846
+ #define ICMP_ECHOREPLY 0
847
+ #endif
848
+ #ifndef ICMP_UNREACH
849
+ #define ICMP_UNREACH 3
850
+ #endif
851
+ #ifndef ICMP_SOURCEQUENCH
852
+ #define ICMP_SOURCEQUENCH 4
853
+ #endif
854
+ #ifndef ICMP_REDIRECT
855
+ #define ICMP_REDIRECT 5
856
+ #endif
857
+ #ifndef ICMP_ECHO
858
+ #define ICMP_ECHO 8
859
+ #endif
860
+ #ifndef ICMP_ROUTERADVERT
861
+ #define ICMP_ROUTERADVERT 9
862
+ #endif
863
+ #ifndef ICMP_ROUTERSOLICIT
864
+ #define ICMP_ROUTERSOLICIT 10
865
+ #endif
866
+ #ifndef ICMP_TIMXCEED
867
+ #define ICMP_TIMXCEED 11
868
+ #endif
869
+ #ifndef ICMP_PARAMPROB
870
+ #define ICMP_PARAMPROB 12
871
+ #endif
872
+ #ifndef ICMP_TSTAMP
873
+ #define ICMP_TSTAMP 13
874
+ #endif
875
+ #ifndef ICMP_TSTAMPREPLY
876
+ #define ICMP_TSTAMPREPLY 14
877
+ #endif
878
+ #ifndef ICMP_IREQ
879
+ #define ICMP_IREQ 15
880
+ #endif
881
+ #ifndef ICMP_IREQREPLY
882
+ #define ICMP_IREQREPLY 16
883
+ #endif
884
+ #ifndef ICMP_MASKREQ
885
+ #define ICMP_MASKREQ 17
886
+ #endif
887
+ #ifndef ICMP_MASKREPLY
888
+ #define ICMP_MASKREPLY 18
889
+ #endif
890
+ u_int8_t icmp_code; /* ICMP code */
891
+ #ifndef ICMP_UNREACH_NET
892
+ #define ICMP_UNREACH_NET 0
893
+ #endif
894
+ #ifndef ICMP_UNREACH_HOST
895
+ #define ICMP_UNREACH_HOST 1
896
+ #endif
897
+ #ifndef ICMP_UNREACH_PROTOCOL
898
+ #define ICMP_UNREACH_PROTOCOL 2
899
+ #endif
900
+ #ifndef ICMP_UNREACH_PORT
901
+ #define ICMP_UNREACH_PORT 3
902
+ #endif
903
+ #ifndef ICMP_UNREACH_NEEDFRAG
904
+ #define ICMP_UNREACH_NEEDFRAG 4
905
+ #endif
906
+ #ifndef ICMP_UNREACH_SRCFAIL
907
+ #define ICMP_UNREACH_SRCFAIL 5
908
+ #endif
909
+ #ifndef ICMP_UNREACH_NET_UNKNOWN
910
+ #define ICMP_UNREACH_NET_UNKNOWN 6
911
+ #endif
912
+ #ifndef ICMP_UNREACH_HOST_UNKNOWN
913
+ #define ICMP_UNREACH_HOST_UNKNOWN 7
914
+ #endif
915
+ #ifndef ICMP_UNREACH_ISOLATED
916
+ #define ICMP_UNREACH_ISOLATED 8
917
+ #endif
918
+ #ifndef ICMP_UNREACH_NET_PROHIB
919
+ #define ICMP_UNREACH_NET_PROHIB 9
920
+ #endif
921
+ #ifndef ICMP_UNREACH_HOST_PROHIB
922
+ #define ICMP_UNREACH_HOST_PROHIB 10
923
+ #endif
924
+ #ifndef ICMP_UNREACH_TOSNET
925
+ #define ICMP_UNREACH_TOSNET 11
926
+ #endif
927
+ #ifndef ICMP_UNREACH_TOSHOST
928
+ #define ICMP_UNREACH_TOSHOST 12
929
+ #endif
930
+ #ifndef ICMP_UNREACH_FILTER_PROHIB
931
+ #define ICMP_UNREACH_FILTER_PROHIB 13
932
+ #endif
933
+ #ifndef ICMP_UNREACH_HOST_PRECEDENCE
934
+ #define ICMP_UNREACH_HOST_PRECEDENCE 14
935
+ #endif
936
+ #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
937
+ #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
938
+ #endif
939
+ #ifndef ICMP_REDIRECT_NET
940
+ #define ICMP_REDIRECT_NET 0
941
+ #endif
942
+ #ifndef ICMP_REDIRECT_HOST
943
+ #define ICMP_REDIRECT_HOST 1
944
+ #endif
945
+ #ifndef ICMP_REDIRECT_TOSNET
946
+ #define ICMP_REDIRECT_TOSNET 2
947
+ #endif
948
+ #ifndef ICMP_REDIRECT_TOSHOST
949
+ #define ICMP_REDIRECT_TOSHOST 3
950
+ #endif
951
+ #ifndef ICMP_TIMXCEED_INTRANS
952
+ #define ICMP_TIMXCEED_INTRANS 0
953
+ #endif
954
+ #ifndef ICMP_TIMXCEED_REASS
955
+ #define ICMP_TIMXCEED_REASS 1
956
+ #endif
957
+ #ifndef ICMP_PARAMPROB_OPTABSENT
958
+ #define ICMP_PARAMPROB_OPTABSENT 1
959
+ #endif
960
+
961
+ u_int16_t icmp_sum; /* ICMP Checksum */
962
+
963
+ union
964
+ {
965
+ struct
966
+ {
967
+ u_int16_t id; /* ICMP id */
968
+ u_int16_t seq;/* ICMP sequence number */
969
+ } echo;
970
+
971
+ #undef icmp_id
972
+ #undef icmp_seq
973
+ #define icmp_id hun.echo.id
974
+ #define icmp_seq hun.echo.seq
975
+
976
+ u_int32_t gateway; /* gateway host */
977
+ struct
978
+ {
979
+ u_int16_t pad;/* padding */
980
+ u_int16_t mtu;/* MTU size */
981
+ } frag;
982
+ } hun;
983
+ union
984
+ {
985
+ struct
986
+ {
987
+ n_time its_otime;
988
+ n_time its_rtime;
989
+ n_time its_ttime;
990
+ } ts;
991
+ struct
992
+ {
993
+ struct libnet_ipv4_hdr idi_ip;
994
+ /* options and then 64 bits of data */
995
+ } ip;
996
+ u_int32_t mask;
997
+ int8_t data[1];
998
+
999
+ #undef icmp_mask
1000
+ #define icmp_mask dun.mask
1001
+ #undef icmp_data
1002
+ #define icmp_data dun.data
1003
+
1004
+ #undef icmp_otime
1005
+ #define icmp_otime dun.ts.its_otime
1006
+ #undef icmp_rtime
1007
+ #define icmp_rtime dun.ts.its_rtime
1008
+ #undef icmp_ttime
1009
+ #define icmp_ttime dun.ts.its_ttime
1010
+ }dun;
1011
+ };
1012
+
1013
+
1014
+ /*
1015
+ * IGMP header
1016
+ * Internet Group Message Protocol
1017
+ * Static header size: 8 bytes
1018
+ */
1019
+ struct libnet_igmp_hdr
1020
+ {
1021
+ u_int8_t igmp_type; /* IGMP type */
1022
+ #ifndef IGMP_MEMBERSHIP_QUERY
1023
+ #define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */
1024
+ #endif
1025
+ #ifndef IGMP_V1_MEMBERSHIP_REPORT
1026
+ #define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */
1027
+ #endif
1028
+ #ifndef IGMP_V2_MEMBERSHIP_REPORT
1029
+ #define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */
1030
+ #endif
1031
+ #ifndef IGMP_LEAVE_GROUP
1032
+ #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
1033
+ #endif
1034
+ u_int8_t igmp_code; /* IGMP code */
1035
+ u_int16_t igmp_sum; /* IGMP checksum */
1036
+ struct in_addr igmp_group;/* IGMP host IP */
1037
+ };
1038
+
1039
+
1040
+ /*
1041
+ * IPSEC header
1042
+ * Internet Protocol Security Protocol
1043
+ * Encapsulating Security Payload Header Static header size: 12 bytes
1044
+ * Encapsulating Security Payload Footer Base header size: 2 bytes
1045
+ * Authentication Header Static Size: 16 bytes
1046
+ */
1047
+ #ifndef IPPROTO_ESP
1048
+ #define IPPROTO_ESP 50 /* not everyone's got this */
1049
+ #endif
1050
+ struct libnet_esp_hdr
1051
+ {
1052
+ u_int32_t esp_spi; /* security parameter index */
1053
+ u_int32_t esp_seq; /* ESP sequence number */
1054
+ u_int32_t esp_iv; /* initialization vector */
1055
+ };
1056
+
1057
+ struct libnet_esp_ftr
1058
+ {
1059
+ u_int8_t esp_pad_len; /* padding length */
1060
+ u_int8_t esp_nh; /* next header pointer */
1061
+ int8_t *esp_auth; /* authentication data */
1062
+ };
1063
+
1064
+ #ifndef IPPROTO_AH
1065
+ #define IPPROTO_AH 51 /* not everyone's got this */
1066
+ #endif
1067
+ struct libnet_ah_hdr
1068
+ {
1069
+ u_int8_t ah_nh; /* next header */
1070
+ u_int8_t ah_len; /* payload length */
1071
+ u_int16_t ah_res; /* reserved */
1072
+ u_int32_t ah_spi; /* security parameter index */
1073
+ u_int32_t ah_seq; /* AH sequence number */
1074
+ u_int32_t ah_auth; /* authentication data */
1075
+ };
1076
+
1077
+
1078
+ /*
1079
+ * ISL header
1080
+ * Cisco Inter-Switch Link
1081
+ * Static header size: 26 bytes
1082
+ */
1083
+ /*
1084
+ * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
1085
+ * Let's hope this one stays that way for a while!
1086
+ */
1087
+ #define LIBNET_PROTO_ISL 201
1088
+ struct libnet_isl_hdr
1089
+ {
1090
+ u_int8_t isl_dhost[5]; /* destination address "01:00:0c:00:00" */
1091
+ #if (LIBNET_LIL_ENDIAN)
1092
+ u_int8_t isl_type:4, /* type of frame */
1093
+ isl_user:4; /* user defined bits */
1094
+ #endif
1095
+ #if (LIBNET_BIG_ENDIAN)
1096
+ u_int8_t isl_user:4, /* user defined bits */
1097
+ isl_type:4; /* type of frame */
1098
+ #endif
1099
+ u_int8_t isl_shost[6]; /* source address */
1100
+ u_int16_t isl_len; /* total length of packet - 18 bytes */
1101
+ u_int8_t isl_snap[6]; /* 0xaaaa03 + vendor code */
1102
+ u_int16_t isl_vid; /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator */
1103
+ u_int16_t isl_index; /* port index */
1104
+ u_int16_t isl_reserved; /* used for FDDI and token ring */
1105
+ /* ethernet frame and 4 byte isl crc */
1106
+ };
1107
+
1108
+ #ifndef IPPROTO_OSPF
1109
+ #define IPPROTO_OSPF 89 /* not everyone's got this */
1110
+ #endif
1111
+ #define IPPROTO_OSPF_LSA 890 /* made this up. Hope it's unused */
1112
+ #define LIBNET_MODX 4102 /* used in LSA checksum */
1113
+
1114
+ /*
1115
+ * Options used in multiple OSPF packets
1116
+ * More info can be found in section A.2 of RFC 2328.
1117
+ */
1118
+ #define LIBNET_OPT_EBIT 0x02 /* describes the way AS-external-LSAs are flooded */
1119
+ #define LIBNET_OPT_MCBIT 0x04 /* whether or not IP multicast dgrams are fwdd */
1120
+ #define LIBNET_OPT_NPBIT 0x08 /* describes handling of type-7 LSAs */
1121
+ #define LIBNET_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */
1122
+ #define LIBNET_OPT_DCBIT 0x20 /* describes handling of demand circuits */
1123
+
1124
+
1125
+ /*
1126
+ * MPLS header
1127
+ * Multi-Protocol Label Switching
1128
+ * Static header size: 4 bytes
1129
+ */
1130
+ struct libnet_mpls_hdr
1131
+ {
1132
+ u_int32_t mpls_les; /* 20 bits label, 3 bits exp, 1 bit bos, ttl */
1133
+ #define LIBNET_MPLS_BOS_ON 1
1134
+ #define LIBNET_MPLS_BOS_OFF 0
1135
+ };
1136
+
1137
+ /*
1138
+ * NTP header
1139
+ * Network Time Protocol
1140
+ * Static header size: 48 bytes
1141
+ */
1142
+ struct libnet_ntp_hdr_l_fp /* int32_t floating point (64-bit) */
1143
+ {
1144
+ u_int32_t integer; /* integer */
1145
+ u_int32_t fraction; /* fraction */
1146
+ };
1147
+
1148
+ struct libnet_ntp_hdr_s_fp /* int16_t floating point (32-bit) */
1149
+ {
1150
+ u_int16_t integer; /* integer */
1151
+ u_int16_t fraction; /* fraction */
1152
+ };
1153
+
1154
+
1155
+ struct libnet_ntp_hdr
1156
+ {
1157
+ u_int8_t ntp_li_vn_mode; /* leap indicator, version, mode */
1158
+ #define LIBNET_NTP_LI_NW 0x0 /* no warning */
1159
+ #define LIBNET_NTP_LI_AS 0x1 /* last minute has 61 seconds */
1160
+ #define LIBNET_NTP_LI_DS 0x2 /* last minute has 59 seconds */
1161
+ #define LIBNET_NTP_LI_AC 0x3 /* alarm condition */
1162
+
1163
+ #define LIBNET_NTP_VN_2 0x2 /* version 2 */
1164
+ #define LIBNET_NTP_VN_3 0x3 /* version 3 */
1165
+ #define LIBNET_NTP_VN_4 0x4 /* version 4 */
1166
+
1167
+ #define LIBNET_NTP_MODE_R 0x0 /* reserved */
1168
+ #define LIBNET_NTP_MODE_A 0x1 /* symmetric active */
1169
+ #define LIBNET_NTP_MODE_P 0x2 /* symmetric passive */
1170
+ #define LIBNET_NTP_MODE_C 0x3 /* client */
1171
+ #define LIBNET_NTP_MODE_S 0x4 /* server */
1172
+ #define LIBNET_NTP_MODE_B 0x5 /* broadcast */
1173
+ #define LIBNET_NTP_MODE_RC 0x6 /* reserved for NTP control message */
1174
+ #define LIBNET_NTP_MODE_RP 0x7 /* reserved for private use */
1175
+ u_int8_t ntp_stratum; /* stratum */
1176
+ #define LIBNET_NTP_STRATUM_UNAVAIL 0x0 /* unspecified or unavailable */
1177
+ #define LIBNET_NTP_STRATUM_PRIMARY 0x1 /* primary reference (radio clock) */
1178
+ /* 2 - 15 is secondary */
1179
+ /* 16 - 255 is reserved */
1180
+ u_int8_t ntp_poll; /* poll interval (should be 4 - 12) */
1181
+ u_int8_t ntp_precision; /* local clock precision */
1182
+ struct libnet_ntp_hdr_s_fp ntp_delay; /* roundtrip delay */
1183
+ struct libnet_ntp_hdr_s_fp ntp_dispersion; /* nominal error */
1184
+ u_int32_t ntp_reference_id; /* reference source id */
1185
+ #define LIBNET_NTP_REF_LOCAL 0x4c4f434c /* uncalibrated local clock */
1186
+ #define LIBNET_NTP_REF_PPS 0x50505300 /* atomic / pulse-per-second clock */
1187
+ #define LIBNET_NTP_REF_ACTS 0x41435453 /* NIST dialup modem */
1188
+ #define LIBNET_NTP_REF_USNO 0x55534e4f /* USNO modem service */
1189
+ #define LIBNET_NTP_REF_PTB 0x50544200 /* PTB (German) modem service */
1190
+ #define LIBNET_NTP_REF_TDF 0x54444600 /* Allouis (French) radio */
1191
+ #define LIBNET_NTP_REF_DCF 0x44434600 /* Mainflingen (German) radio */
1192
+ #define LIBNET_NTP_REF_MSF 0x4d534600 /* Rugby (UK) radio */
1193
+ #define LIBNET_NTP_REF_WWV 0x57575600 /* Ft Collins (US) radio */
1194
+ #define LIBNET_NTP_REF_WWVB 0x57575642 /* Boulder (US) radio */
1195
+ #define LIBNET_NTP_REF_WWVH 0x57575648 /* Kaui Hawaii (US) radio */
1196
+ #define LIBNET_NTP_REF_CHU 0x43485500 /* Ottaha (Canada) radio */
1197
+ #define LIBNET_NTP_REF_LORC 0x4c4f5243 /* LORAN-C radionavigation */
1198
+ #define LIBNET_NTP_REF_OMEG 0x4f4d4547 /* OMEGA radionavigation */
1199
+ #define LIBNET_NTP_REF_GPS 0x47505300 /* global positioning system */
1200
+ #define LIBNET_NTP_REF_GOES 0x474f4553 /* geostationary orbit env satellite */
1201
+ struct libnet_ntp_hdr_l_fp ntp_ref_ts; /* reference timestamp */
1202
+ struct libnet_ntp_hdr_l_fp ntp_orig_ts; /* originate timestamp */
1203
+ struct libnet_ntp_hdr_l_fp ntp_rec_ts; /* receive timestamp */
1204
+ struct libnet_ntp_hdr_l_fp ntp_xmt_ts; /* transmit timestamp */
1205
+ };
1206
+
1207
+
1208
+ /*
1209
+ * OSPFv2 header
1210
+ * Open Shortest Path First
1211
+ * Static header size: 16 bytes
1212
+ */
1213
+ struct libnet_ospf_hdr
1214
+ {
1215
+ u_int8_t ospf_v; /* version */
1216
+ #define OSPFVERSION 2
1217
+ u_int8_t ospf_type; /* type */
1218
+ #define LIBNET_OSPF_UMD 0 /* UMd monitoring packet */
1219
+ #define LIBNET_OSPF_HELLO 1 /* HELLO packet */
1220
+ #define LIBNET_OSPF_DBD 2 /* dataBase description packet */
1221
+ #define LIBNET_OSPF_LSR 3 /* link state request packet */
1222
+ #define LIBNET_OSPF_LSU 4 /* link state Update Packet */
1223
+ #define LIBNET_OSPF_LSA 5 /* link state acknowledgement packet */
1224
+ u_int16_t ospf_len; /* length */
1225
+ struct in_addr ospf_rtr_id; /* source router ID */
1226
+ struct in_addr ospf_area_id;/* roam ID */
1227
+ u_int16_t ospf_sum; /* checksum */
1228
+ u_int16_t ospf_auth_type; /* authentication type */
1229
+ #define LIBNET_OSPF_AUTH_NULL 0 /* null password */
1230
+ #define LIBNET_OSPF_AUTH_SIMPLE 1 /* simple, plaintext, 8 int8_t password */
1231
+ #define LIBNET_OSPF_AUTH_MD5 2 /* MD5 */
1232
+ };
1233
+
1234
+
1235
+ /*
1236
+ * OSPF authentication header
1237
+ * Open Shortest Path First
1238
+ * Static header size: 8 bytes
1239
+ */
1240
+ struct libnet_auth_hdr
1241
+ {
1242
+ u_int16_t ospf_auth_null; /* NULL */
1243
+ u_int8_t ospf_auth_keyid; /* authentication key ID */
1244
+ u_int8_t ospf_auth_len; /* auth data length */
1245
+ u_int ospf_auth_seq; /* cryptographic sequence number */
1246
+ };
1247
+
1248
+
1249
+ /*
1250
+ * OSPF hello header
1251
+ * Open Shortest Path First
1252
+ * Static header size: 28 bytes
1253
+ */
1254
+ struct libnet_ospf_hello_hdr
1255
+ {
1256
+ struct in_addr hello_nmask; /* netmask associated with the interface */
1257
+ u_int16_t hello_intrvl; /* num of seconds between routers last packet */
1258
+ u_int8_t hello_opts; /* Options for HELLO packets (look above) */
1259
+ u_int8_t hello_rtr_pri; /* router's priority (if 0, can't be backup) */
1260
+ u_int hello_dead_intvl; /* # of secs a router is silent till deemed down */
1261
+ struct in_addr hello_des_rtr; /* Designated router on the network */
1262
+ struct in_addr hello_bkup_rtr; /* Backup router */
1263
+ struct in_addr hello_nbr; /* neighbor router, memcpy more as needed */
1264
+ };
1265
+
1266
+
1267
+ /*
1268
+ * Database Description header.
1269
+ */
1270
+ struct libnet_dbd_hdr
1271
+ {
1272
+ u_int16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can use */
1273
+ u_int8_t dbd_opts; /* DBD packet options (from above) */
1274
+ u_int8_t dbd_type; /* type of exchange occurring */
1275
+ #define LIBNET_DBD_IBI 0x01 /* init */
1276
+ #define LIBNET_DBD_MBIT 0x02 /* more DBD packets are to come */
1277
+ #define LIBNET_DBD_MSBIT 0x04 /* If 1, sender is the master in the exchange */
1278
+ u_int dbd_seq; /* DBD sequence number */
1279
+ };
1280
+
1281
+
1282
+ /*
1283
+ * used for the LS type field in all LS* headers
1284
+ */
1285
+ #define LIBNET_LS_TYPE_RTR 1 /* router-LSA */
1286
+ #define LIBNET_LS_TYPE_NET 2 /* network-LSA */
1287
+ #define LIBNET_LS_TYPE_IP 3 /* summary-LSA (IP Network) */
1288
+ #define LIBNET_LS_TYPE_ASBR 4 /* summary-LSA (ASBR) */
1289
+ #define LIBNET_LS_TYPE_ASEXT 5 /* AS-external-LSA */
1290
+
1291
+
1292
+ /*
1293
+ * Link State Request header
1294
+ */
1295
+ struct libnet_lsr_hdr
1296
+ {
1297
+ u_int lsr_type; /* type of LS being requested */
1298
+ u_int lsr_lsid; /* link state ID */
1299
+ struct in_addr lsr_adrtr; /* advertising router (memcpy more as needed) */
1300
+ };
1301
+
1302
+
1303
+ /*
1304
+ * Link State Update header
1305
+ */
1306
+ struct libnet_lsu_hdr
1307
+ {
1308
+ u_int lsu_num; /* number of LSAs that will be broadcasted */
1309
+ };
1310
+
1311
+
1312
+ /*
1313
+ * Link State Acknowledgement header.
1314
+ */
1315
+ struct libnet_lsa_hdr
1316
+ {
1317
+ u_int16_t lsa_age; /* time in seconds since the LSA was originated */
1318
+ u_int8_t lsa_opts; /* look above for OPTS_* */
1319
+ u_int8_t lsa_type; /* look below for LS_TYPE_* */
1320
+ u_int lsa_id; /* link State ID */
1321
+ struct in_addr lsa_adv; /* router ID of Advertising router */
1322
+ u_int lsa_seq; /* LSA sequence number to detect old/bad ones */
1323
+ u_int16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age */
1324
+ u_int16_t lsa_len; /* length in bytes including the 20 byte header */
1325
+ };
1326
+
1327
+
1328
+ /*
1329
+ * Router LSA data format
1330
+ *
1331
+ * Other stuff for TOS can be added for backward compatability, for this
1332
+ * version, only OSPFv2 is being FULLY supported.
1333
+ */
1334
+ struct libnet_rtr_lsa_hdr
1335
+ {
1336
+ u_int16_t rtr_flags; /* set to help describe packet */
1337
+ #define LIBNET_RTR_FLAGS_W 0x0100 /* W bit */
1338
+ #define LIBNET_RTR_FLAGS_E 0x0200 /* E bit */
1339
+ #define LIBNET_RTR_FLAGS_B 0x0400 /* B bit */
1340
+ u_int16_t rtr_num; /* number of links within that packet */
1341
+ u_int rtr_link_id; /* describes link_data (look below) */
1342
+ #define LIBNET_LINK_ID_NBR_ID 1 /* Neighbors router ID, also can be 4 */
1343
+ #define LIBNET_LINK_ID_IP_DES 2 /* IP address of designated router */
1344
+ #define LIBNET_LINK_ID_SUB 3 /* IP subnet number */
1345
+ u_int rtr_link_data; /* Depending on link_id, info is here */
1346
+ u_int8_t rtr_type; /* Description of router link */
1347
+ #define LIBNET_RTR_TYPE_PTP 1 /* Point-To-Point */
1348
+ #define LIBNET_RTR_TYPE_TRANS 2 /* Connection to a "transit network" */
1349
+ #define LIBNET_RTR_TYPE_STUB 3 /* Connectin to a "stub network" */
1350
+ #define RTR_TYPE_VRTL 4 /* connects to a "virtual link" */
1351
+ u_int8_t rtr_tos_num; /* number of different TOS metrics for this link */
1352
+ u_int16_t rtr_metric; /* the "cost" of using this link */
1353
+ };
1354
+
1355
+
1356
+ /*
1357
+ * Network LSA data format.
1358
+ */
1359
+ struct libnet_net_lsa_hdr
1360
+ {
1361
+ struct in_addr net_nmask; /* Netmask for that network */
1362
+ u_int net_rtr_id; /* ID of router attached to that network */
1363
+ };
1364
+
1365
+
1366
+ /*
1367
+ * Summary LSA data format.
1368
+ */
1369
+ struct libnet_sum_lsa_hdr
1370
+ {
1371
+ struct in_addr sum_nmask; /* Netmask of destination IP address */
1372
+ u_int sum_metric; /* Same as in rtr_lsa (&0xfff to use last 24bit */
1373
+ u_int sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metric */
1374
+ };
1375
+
1376
+
1377
+ /*
1378
+ * AS External LSA data format.
1379
+ * & 0xfff logic operator for as_metric to get last 24bits.
1380
+ */
1381
+ struct libnet_as_lsa_hdr
1382
+ {
1383
+ struct in_addr as_nmask; /* Netmask for advertised destination */
1384
+ u_int as_metric; /* May have to set E bit in first 8bits */
1385
+ #define LIBNET_AS_E_BIT_ON 0x80000000 /* as_metric */
1386
+ struct in_addr as_fwd_addr; /* Forwarding address */
1387
+ u_int as_rte_tag; /* External route tag */
1388
+ };
1389
+
1390
+
1391
+ /*
1392
+ * Base RIP header
1393
+ * Routing Information Protocol
1394
+ * Base header size: 24 bytes
1395
+ */
1396
+ struct libnet_rip_hdr
1397
+ {
1398
+ u_int8_t rip_cmd; /* RIP command */
1399
+ #define RIPCMD_REQUEST 1 /* want info */
1400
+ #define RIPCMD_RESPONSE 2 /* responding to request */
1401
+ #define RIPCMD_TRACEON 3 /* turn tracing on */
1402
+ #define RIPCMD_TRACEOFF 4 /* turn it off */
1403
+ #define RIPCMD_POLL 5 /* like request, but anyone answers */
1404
+ #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */
1405
+ #define RIPCMD_MAX 7 /* ? command */
1406
+ u_int8_t rip_ver; /* RIP version */
1407
+ #define RIPVER_0 0
1408
+ #define RIPVER_1 1
1409
+ #define RIPVER_2 2
1410
+ u_int16_t rip_rd; /* Zero (v1) or Routing Domain (v2) */
1411
+ u_int16_t rip_af; /* Address family */
1412
+ u_int16_t rip_rt; /* Zero (v1) or Route Tag (v2) */
1413
+ u_int32_t rip_addr; /* IP address */
1414
+ u_int32_t rip_mask; /* Zero (v1) or Subnet Mask (v2) */
1415
+ u_int32_t rip_next_hop; /* Zero (v1) or Next hop IP address (v2) */
1416
+ u_int32_t rip_metric; /* Metric */
1417
+ };
1418
+
1419
+ /*
1420
+ * RPC headers
1421
+ * Remote Procedure Call
1422
+ */
1423
+ #define LIBNET_RPC_CALL 0
1424
+ #define LIBNET_RPC_REPLY 1
1425
+ #define LIBNET_RPC_VERS 2
1426
+ #define LIBNET_RPC_LAST_FRAG 0x80000000
1427
+
1428
+ /*
1429
+ * Portmap defines
1430
+ */
1431
+ #define LIBNET_PMAP_PROGRAM 100000
1432
+ #define LIBNET_PMAP_PROC_NULL 0
1433
+ #define LIBNET_PMAP_PROC_SET 1
1434
+ #define LIBNET_PMAP_PROC_UNSET 2
1435
+ #define LIBNET_PMAP_PROC_GETADDR 3
1436
+ #define LIBNET_PMAP_PROC_DUMP 4
1437
+ #define LIBNET_PMAP_PROC_CALLIT 5
1438
+ #define LIBNET_PMAP_PROC_BCAST 5 /* Not a typo */
1439
+ #define LIBNET_PMAP_PROC_GETTIME 6
1440
+ #define LIBNET_PMAP_PROC_UADDR2TADDR 7
1441
+ #define LIBNET_PMAP_PROC_TADDR2UADDR 8
1442
+ #define LIBNET_PMAP_PROC_GETVERSADDR 9
1443
+ #define LIBNET_PMAP_PROC_INDIRECT 10
1444
+ #define LIBNET_PMAP_PROC_GETADDRLIST 11
1445
+ #define LIBNET_PMAP_PROC_GETSTAT 12
1446
+
1447
+ /* There will be more to add... */
1448
+
1449
+ struct libnet_rpc_opaque_auth
1450
+ {
1451
+ u_int32_t rpc_auth_flavor;
1452
+ u_int32_t rpc_auth_length;
1453
+ // u_int8_t *rpc_auth_data;
1454
+ };
1455
+
1456
+ struct libnet_rpc_call
1457
+ {
1458
+ u_int32_t rpc_rpcvers; /* RPC version - must be 2 */
1459
+ u_int32_t rpc_prognum; /* Program Number */
1460
+ u_int32_t rpc_vers; /* Program Version */
1461
+ u_int32_t rpc_procedure; /* RPC procedure */
1462
+ struct libnet_rpc_opaque_auth rpc_credentials;
1463
+ struct libnet_rpc_opaque_auth rpc_verifier;
1464
+ };
1465
+
1466
+ struct libnet_rpc_call_hdr
1467
+ {
1468
+ u_int32_t rpc_xid; /* xid (transaction identifier) */
1469
+ u_int32_t rpc_type;
1470
+ struct libnet_rpc_call rpc_call;
1471
+ };
1472
+
1473
+ struct libnet_rpc_call_tcp_hdr
1474
+ {
1475
+ u_int32_t rpc_record_marking; /* used with byte stream protocols */
1476
+ struct libnet_rpc_call_hdr rpc_common;
1477
+ };
1478
+
1479
+ /*
1480
+ * STP configuration header
1481
+ * Spanning Tree Protocol
1482
+ * Static header size: 35 bytes
1483
+ */
1484
+ struct libnet_stp_conf_hdr
1485
+ {
1486
+ u_int16_t stp_id; /* protocol id */
1487
+ u_int8_t stp_version; /* protocol version */
1488
+ u_int8_t stp_bpdu_type; /* bridge protocol data unit type */
1489
+ u_int8_t stp_flags; /* control flags */
1490
+ u_int8_t stp_rootid[8]; /* root id */
1491
+ u_int32_t stp_rootpc; /* root path cost */
1492
+ u_int8_t stp_bridgeid[8]; /* bridge id */
1493
+ u_int16_t stp_portid; /* port id */
1494
+ u_int16_t stp_mage; /* message age */
1495
+ u_int16_t stp_maxage; /* max age */
1496
+ u_int16_t stp_hellot; /* hello time */
1497
+ u_int16_t stp_fdelay; /* forward delay */
1498
+ };
1499
+
1500
+
1501
+ /*
1502
+ * STP topology change notification header
1503
+ * Spanning Tree Protocol
1504
+ * Static header size: 4 bytes
1505
+ */
1506
+ struct libnet_stp_tcn_hdr
1507
+ {
1508
+ u_int16_t stp_id; /* protocol id */
1509
+ u_int8_t stp_version; /* protocol version */
1510
+ u_int8_t stp_bpdu_type; /* bridge protocol data unit type */
1511
+ };
1512
+
1513
+
1514
+ /*
1515
+ * TCP header
1516
+ * Transmission Control Protocol
1517
+ * Static header size: 20 bytes
1518
+ */
1519
+ struct libnet_tcp_hdr
1520
+ {
1521
+ u_int16_t th_sport; /* source port */
1522
+ u_int16_t th_dport; /* destination port */
1523
+ u_int32_t th_seq; /* sequence number */
1524
+ u_int32_t th_ack; /* acknowledgement number */
1525
+ #if (LIBNET_LIL_ENDIAN)
1526
+ u_int8_t th_x2:4, /* (unused) */
1527
+ th_off:4; /* data offset */
1528
+ #endif
1529
+ #if (LIBNET_BIG_ENDIAN)
1530
+ u_int8_t th_off:4, /* data offset */
1531
+ th_x2:4; /* (unused) */
1532
+ #endif
1533
+ u_int8_t th_flags; /* control flags */
1534
+ #ifndef TH_FIN
1535
+ #define TH_FIN 0x01 /* finished send data */
1536
+ #endif
1537
+ #ifndef TH_SYN
1538
+ #define TH_SYN 0x02 /* synchronize sequence numbers */
1539
+ #endif
1540
+ #ifndef TH_RST
1541
+ #define TH_RST 0x04 /* reset the connection */
1542
+ #endif
1543
+ #ifndef TH_PUSH
1544
+ #define TH_PUSH 0x08 /* push data to the app layer */
1545
+ #endif
1546
+ #ifndef TH_ACK
1547
+ #define TH_ACK 0x10 /* acknowledge */
1548
+ #endif
1549
+ #ifndef TH_URG
1550
+ #define TH_URG 0x20 /* urgent! */
1551
+ #endif
1552
+ #ifndef TH_ECE
1553
+ #define TH_ECE 0x40
1554
+ #endif
1555
+ #ifndef TH_CWR
1556
+ #define TH_CWR 0x80
1557
+ #endif
1558
+ u_int16_t th_win; /* window */
1559
+ u_int16_t th_sum; /* checksum */
1560
+ u_int16_t th_urp; /* urgent pointer */
1561
+ };
1562
+
1563
+ /*
1564
+ * Token Ring Header
1565
+ */
1566
+ struct libnet_token_ring_hdr
1567
+ {
1568
+ u_int8_t token_ring_access_control;
1569
+ #define LIBNET_TOKEN_RING_FRAME 0x10
1570
+ u_int8_t token_ring_frame_control;
1571
+ #define LIBNET_TOKEN_RING_LLC_FRAME 0x40
1572
+ u_int8_t token_ring_dhost[TOKEN_RING_ADDR_LEN];
1573
+ u_int8_t token_ring_shost[TOKEN_RING_ADDR_LEN];
1574
+ u_int8_t token_ring_llc_dsap;
1575
+ u_int8_t token_ring_llc_ssap;
1576
+ u_int8_t token_ring_llc_control_field;
1577
+ u_int8_t token_ring_llc_org_code[LIBNET_ORG_CODE_SIZE];
1578
+ u_int16_t token_ring_type;
1579
+ #define TOKEN_RING_TYPE_IP 0x0800 /* IP protocol */
1580
+ #define TOKEN_RING_TYPE_ARP 0x0806 /* addr. resolution protocol */
1581
+ #define TOKEN_RING_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
1582
+ };
1583
+
1584
+ struct libnet_token_ring_addr
1585
+ {
1586
+ u_int8_t token_ring_addr_octet[6]; /* Token Ring address */
1587
+ };
1588
+
1589
+ /*
1590
+ * UDP header
1591
+ * User Data Protocol
1592
+ * Static header size: 8 bytes
1593
+ */
1594
+ struct libnet_udp_hdr
1595
+ {
1596
+ u_int16_t uh_sport; /* soure port */
1597
+ u_int16_t uh_dport; /* destination port */
1598
+ u_int16_t uh_ulen; /* length */
1599
+ u_int16_t uh_sum; /* checksum */
1600
+ };
1601
+
1602
+ /*
1603
+ * Sebek header
1604
+ * Static header size: 48 bytes
1605
+ */
1606
+ struct libnet_sebek_hdr
1607
+ {
1608
+ u_int32_t magic; /* identify packets that should be hidden */
1609
+ u_int16_t version; /* protocol version, currently 1 */
1610
+ #define SEBEK_PROTO_VERSION 1
1611
+ u_int16_t type; /* type of record (read data is type 0, write data is type 1) */
1612
+ #define SEBEK_TYPE_READ 0 /* Currently, only read is supported */
1613
+ #define SEBEK_TYPE_WRITE 1
1614
+ u_int32_t counter; /* PDU counter used to identify when packet are lost */
1615
+ u_int32_t time_sec; /* seconds since EPOCH according to the honeypot */
1616
+ u_int32_t time_usec; /* residual microseconds */
1617
+ u_int32_t pid; /* PID */
1618
+ u_int32_t uid; /* UID */
1619
+ u_int32_t fd; /* FD */
1620
+ #define SEBEK_CMD_LENGTH 12
1621
+ u_int8_t cmd[SEBEK_CMD_LENGTH]; /* 12 first characters of the command */
1622
+ u_int32_t length; /* length in bytes of the PDU's body */
1623
+ };
1624
+
1625
+
1626
+ /*
1627
+ * VRRP header
1628
+ * Virtual Router Redundancy Protocol
1629
+ * Static header size: 8 bytes
1630
+ */
1631
+ #ifndef IPPROTO_VRRP
1632
+ #define IPPROTO_VRRP 112 /* not everyone's got this */
1633
+ #endif
1634
+ struct libnet_vrrp_hdr
1635
+ {
1636
+ #if (LIBNET_LIL_ENDIAN)
1637
+ u_int8_t vrrp_v:4, /* protocol version */
1638
+ vrrp_t:4; /* packet type */
1639
+ #endif
1640
+ #if (LIBNET_BIG_ENDIAN)
1641
+ u_int8_t vrrp_t:4, /* packet type */
1642
+ vrrp_v:4; /* protocol version */
1643
+ #endif
1644
+ #define LIBNET_VRRP_VERSION_01 0x1
1645
+ #define LIBNET_VRRP_VERSION_02 0x2
1646
+ #define LIBNET_VRRP_TYPE_ADVERT 0x1
1647
+ u_int8_t vrrp_vrouter_id; /* virtual router id */
1648
+ u_int8_t vrrp_priority; /* priority */
1649
+ u_int8_t vrrp_ip_count; /* number of IP addresses */
1650
+ u_int8_t vrrp_auth_type; /* authorization type */
1651
+ #define LIBNET_VRRP_AUTH_NONE 0x1
1652
+ #define LIBNET_VRRP_AUTH_PASSWD 0x2
1653
+ #define LIBNET_VRRP_AUTH_IPAH 0x3
1654
+ u_int8_t vrrp_advert_int; /* advertisement interval */
1655
+ u_int16_t vrrp_sum; /* checksum */
1656
+ /* additional addresses */
1657
+ /* authentication info */
1658
+ };
1659
+
1660
+ #endif /* __LIBNET_HEADERS_H */
1661
+
1662
+ /* EOF */