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
data/test/tc_arp.rb ADDED
@@ -0,0 +1,169 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+
3
+ require 'test/unit'
4
+ require 'libnet4r'
5
+
6
+ class TC_Libnet_ARP < Test::Unit::TestCase
7
+ def test_unpack
8
+ bytes = [
9
+ 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xaa, 0xbb, 0xcc, 0xdd,
10
+ 0xee, 0xff, 0xc0, 0xa8, 0x01, 0x64, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
11
+ 0xc0, 0xa8, 0x01, 0x7b
12
+ ].pack("C*")
13
+
14
+ a = Libnet::ARP.decode(bytes)
15
+
16
+ assert_equal(0x0001, a.htype)
17
+ assert_equal(0x0800, a.protocol)
18
+ assert_equal(6, a.hlen)
19
+ assert_equal(4, a.plen)
20
+ assert_equal(1, a.operation)
21
+ assert_equal([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff].pack("C*"), a.sender_haddr)
22
+ assert_equal([0xc0, 0xa8, 0x01, 0x64].pack("C*"), a.sender_paddr)
23
+ assert_equal([0x11, 0x22, 0x33, 0x44, 0x55, 0x66].pack("C*"), a.target_haddr)
24
+ assert_equal([0xc0, 0xa8, 0x01, 0x7b].pack("C*"), a.target_paddr)
25
+ assert_nil(a.payload)
26
+
27
+ assert_raise ArgumentError do
28
+ Libnet::ARP.decode("foobar")
29
+ end
30
+ end
31
+
32
+ def test_pack
33
+ exp_bytes = [
34
+ 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xaa, 0xbb, 0xcc, 0xdd,
35
+ 0xee, 0xff, 0xc0, 0xa8, 0x01, 0x64, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
36
+ 0xc0, 0xa8, 0x01, 0x7b
37
+ ].pack("C*")
38
+
39
+ # build the ARP header object separately
40
+ a = Libnet::ARP.new
41
+
42
+ a.htype = 1
43
+ a.protocol = 0x0800
44
+ a.hlen = 6
45
+ a.plen = 4
46
+ a.operation = 1
47
+ a.sender_haddr = 'aa:bb:cc:dd:ee:ff'
48
+ a.sender_paddr = '192.168.1.100'
49
+ a.target_haddr = '11:22:33:44:55:66'
50
+ a.target_paddr = '192.168.1.123'
51
+
52
+ l = Libnet.new
53
+
54
+ assert_nil(a.ptag)
55
+
56
+ l.build_arp(a)
57
+
58
+ assert(a.ptag > 0)
59
+ assert_equal(exp_bytes, l.pack)
60
+
61
+ # build the ARP header as a yielded object
62
+ l = Libnet.new
63
+
64
+ l.build_arp do |a|
65
+ a.htype = 1
66
+ a.protocol = 0x0800
67
+ a.hlen = 6
68
+ a.plen = 4
69
+ a.operation = 1
70
+ a.sender_haddr = 'aa:bb:cc:dd:ee:ff'
71
+ a.sender_paddr = '192.168.1.100'
72
+ a.target_haddr = '11:22:33:44:55:66'
73
+ a.target_paddr = '192.168.1.123'
74
+ end
75
+
76
+ assert(a.ptag > 0)
77
+
78
+ assert_equal(exp_bytes, l.pack)
79
+ end
80
+
81
+ def test_modify_ptag
82
+ arp1 = [
83
+ 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xaa, 0xbb, 0xcc, 0xdd,
84
+ 0xee, 0xff, 0xc0, 0xa8, 0x01, 0x64, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
85
+ 0xc0, 0xa8, 0x01, 0x7b
86
+ ].pack("C*")
87
+ arp2 = [
88
+ 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x02, 0xaa, 0xbb, 0xcc, 0xdd,
89
+ 0xee, 0xff, 0xc0, 0xa8, 0x01, 0x64, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
90
+ 0xc0, 0xa8, 0x01, 0x7b
91
+ ].pack("C*")
92
+
93
+ l = Libnet.new
94
+
95
+ a = l.build_arp do |a|
96
+ a.htype = 1
97
+ a.protocol = 0x0800
98
+ a.hlen = 6
99
+ a.plen = 4
100
+ a.operation = 1
101
+ a.sender_haddr = 'aa:bb:cc:dd:ee:ff'
102
+ a.sender_paddr = '192.168.1.100'
103
+ a.target_haddr = '11:22:33:44:55:66'
104
+ a.target_paddr = '192.168.1.123'
105
+ end
106
+
107
+ assert(a.ptag > 0)
108
+
109
+ ptag = a.ptag
110
+
111
+ assert_equal(arp1, l.pack)
112
+
113
+ a.operation = 2
114
+
115
+ l.build_arp(a)
116
+
117
+ assert_equal(ptag, a.ptag)
118
+
119
+ assert_equal(arp2, l.pack)
120
+ end
121
+
122
+ def test_missing_fields
123
+ l = Libnet.new
124
+
125
+ assert_raise ArgumentError do
126
+ l.build_arp { |e| }
127
+ end
128
+
129
+ assert_raise ArgumentError do
130
+ l.build_arp do |a|
131
+ a.sender_haddr = 'aa:bb:cc:dd:ee:ff'
132
+ a.target_haddr = '11:22:33:44:55:66'
133
+ end
134
+ end
135
+ end
136
+
137
+ def test_frame
138
+ exp_bytes = [
139
+ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0x22, 0x33, 0x22, 0x33, 0x22, 0x33,
140
+ 0x08, 0x06,
141
+ 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xaa, 0xbb, 0xcc, 0xdd,
142
+ 0xee, 0xff, 0xc0, 0xa8, 0x01, 0x64, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
143
+ 0xc0, 0xa8, 0x01, 0x7b
144
+ ].pack("C*")
145
+
146
+ l = Libnet.new(:link)
147
+
148
+ a = l.build_arp do |a|
149
+ a.htype = 1
150
+ a.protocol = 0x0800
151
+ a.hlen = 6
152
+ a.plen = 4
153
+ a.operation = 1
154
+ a.sender_haddr = 'aa:bb:cc:dd:ee:ff'
155
+ a.sender_paddr = '192.168.1.100'
156
+ a.target_haddr = '11:22:33:44:55:66'
157
+ a.target_paddr = '192.168.1.123'
158
+ end
159
+
160
+ e = l.build_ethernet do |e|
161
+ e.dst = '12:34:56:78:90:ab'
162
+ e.src = '22:33:22:33:22:33'
163
+ e.type = 0x0806
164
+ end
165
+
166
+ assert_equal(exp_bytes, l.pack)
167
+ end
168
+ end
169
+
data/test/tc_class.rb ADDED
@@ -0,0 +1,219 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+
3
+ require 'test/unit'
4
+ require 'libnet4r'
5
+
6
+ class TC_Libnet_Class < Test::Unit::TestCase
7
+ def test_addr2name4
8
+ assert_respond_to(Libnet, :addr2name4)
9
+
10
+ ip = 0xcdea6d12
11
+
12
+ assert_equal("rubyforge.org", Libnet.addr2name4(ip))
13
+ assert_equal("rubyforge.org", Libnet.addr2name4(ip, true))
14
+ assert_equal("205.234.109.18", Libnet.addr2name4(ip, false))
15
+ end
16
+
17
+ # FIXME: I don't know of a valid IPv6 address to use here
18
+ def test_addr2name6
19
+ assert_respond_to(Libnet, :addr2name6)
20
+
21
+ ip = Libnet.ipv6_aton("fe80::20d:93ff:fe2f:3704")
22
+
23
+ assert_equal("fe80::20d:93ff:fe2f:3704", Libnet.addr2name6(ip, false))
24
+ end
25
+
26
+ def test_hex_aton
27
+ assert_respond_to(Libnet, :hex_aton)
28
+
29
+ bytes1 = [0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff].pack("C*")
30
+ bytes2 = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab].pack("C*")
31
+
32
+ assert_equal(bytes1, Libnet.hex_aton("aa:bb:cc:dd:ee:ff"))
33
+ assert_equal(bytes2, Libnet.hex_aton("01:23:45:67:89:ab"))
34
+
35
+ assert_raise ArgumentError do
36
+ Libnet.hex_aton("aa:bb:cc:dd:ee:fg")
37
+ end
38
+ end
39
+
40
+ def test_ipv4_aton
41
+ assert_respond_to(Libnet, :ipv4_aton)
42
+
43
+ assert_equal(0xcdea6d12, Libnet.ipv4_aton("205.234.109.18"))
44
+
45
+ # check for invalid ip address
46
+ assert_raise ArgumentError do
47
+ Libnet.ipv4_aton("256.234.109.18")
48
+ end
49
+
50
+ assert_raise ArgumentError do
51
+ Libnet.ipv4_aton("205.234.109")
52
+ end
53
+
54
+ assert_raise ArgumentError do
55
+ Libnet.ipv4_aton("205.234.109.ab")
56
+ end
57
+ end
58
+
59
+ def test_ipv4_ntoa
60
+ assert_respond_to(Libnet, :ipv4_ntoa)
61
+
62
+ assert_equal("205.234.109.18", Libnet.ipv4_ntoa(0xcdea6d12))
63
+ end
64
+
65
+ def test_ipv6_aton
66
+ ip6_1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].pack("C*")
67
+ ip6_2 = [
68
+ 0x80, 0x5b, 0x2d, 0x9d, 0xdc, 0x28, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x57,
69
+ 0xd4, 0xc8, 0x1f, 0xff
70
+ ].pack("C*")
71
+
72
+ assert_respond_to(Libnet, :ipv6_aton)
73
+
74
+ assert_equal(ip6_1, Libnet.ipv6_aton("::"))
75
+ assert_equal(ip6_2, Libnet.ipv6_aton("805b:2d9d:dc28::fc57:d4c8:1fff"))
76
+
77
+ # check for invalid ip address
78
+ assert_raise ArgumentError do
79
+ Libnet.ipv6_aton("1234")
80
+ end
81
+
82
+ assert_raise ArgumentError do
83
+ Libnet.ipv6_aton("1234::4321:abcd::dcba")
84
+ end
85
+ end
86
+
87
+ def test_ipv6_ntoa
88
+ ip6_1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0].pack("C*")
89
+ ip6_2 = [
90
+ 0x80, 0x5b, 0x2d, 0x9d, 0xdc, 0x28, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x57,
91
+ 0xd4, 0xc8, 0x1f, 0xff
92
+ ].pack("C*")
93
+
94
+ assert_respond_to(Libnet, :ipv6_ntoa)
95
+
96
+ assert_equal("::", Libnet.ipv6_ntoa(ip6_1))
97
+ assert_equal("805b:2d9d:dc28::fc57:d4c8:1fff", Libnet.ipv6_ntoa(ip6_2))
98
+
99
+ assert_raise ArgumentError do
100
+ Libnet.hexdump(Libnet.ipv6_ntoa("foobar"))
101
+ end
102
+ end
103
+
104
+ def test_hexdump
105
+ assert_respond_to(Libnet, :hexdump)
106
+
107
+ bytes = [
108
+ 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0x00, 0x11, 0x22, 0x33,
109
+ 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
110
+ 0xcb
111
+ ].pack("C*")
112
+
113
+ dump = <<_END_
114
+ 0x00000000: deadbeef feedface 00112233 44556677
115
+ 0x00000010: 8899aabb ccddeeff cb
116
+ _END_
117
+
118
+ assert_equal(dump, Libnet.hexdump(bytes))
119
+ end
120
+
121
+ def test_write
122
+ l = Libnet.new(:link)
123
+
124
+ l.build_arp do |a|
125
+ a.htype = 1
126
+ a.protocol = 0x0800
127
+ a.hlen = 6
128
+ a.plen = 4
129
+ a.operation = 1
130
+ a.sender_haddr = 'aa:bb:cc:dd:ee:ff'
131
+ a.sender_paddr = '192.168.1.100'
132
+ a.target_haddr = '11:22:33:44:55:66'
133
+ a.target_paddr = '192.168.1.123'
134
+ end
135
+
136
+ l.build_ethernet do |e|
137
+ e.dst = '12:34:56:78:90:ab'
138
+ e.src = '22:33:22:33:22:33'
139
+ e.type = 0x0806
140
+ end
141
+
142
+ if Process.uid > 0 && Process.euid > 0
143
+ # user is not root, so we should get an exception here
144
+ assert_raise RuntimeError do
145
+ l.write
146
+ end
147
+ else
148
+ # user is root, so this should work
149
+ assert_equal(42, l.write)
150
+ end
151
+ end
152
+
153
+ def test_write_bytes
154
+ eth = [
155
+ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
156
+ 0x12, 0x34, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
157
+ 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65
158
+ ].pack("C*")
159
+ ip4 = [
160
+ 0x45, 0x12, 0x00, 0x40, 0x43, 0x21, 0x00, 0x00, 0x48, 0x11, 0xac, 0x24,
161
+ 0xc0, 0xa8, 0x01, 0x02, 0xc0, 0xa8, 0x01, 0x03, 0x74, 0x68, 0x65, 0x20,
162
+ 0x71, 0x75, 0x69, 0x63, 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20,
163
+ 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x65, 0x64, 0x20, 0x6f,
164
+ 0x76, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79,
165
+ 0x20, 0x64, 0x6f, 0x67
166
+ ].pack("C*")
167
+ ip6 = [
168
+ 0x62, 0x2d, 0xbe, 0xef, 0x00, 0x54, 0x11, 0x18, 0x00, 0x11, 0x22, 0x33,
169
+ 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
170
+ 0xaa, 0xbb, 0xaa, 0xbb, 0xcc, 0xdd, 0xcc, 0xdd, 0xee, 0xff, 0xee, 0xff,
171
+ 0x22, 0x33, 0x22, 0x33, 0x74, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63,
172
+ 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f, 0x78, 0x20,
173
+ 0x6a, 0x75, 0x6d, 0x70, 0x65, 0x64, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x20,
174
+ 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79, 0x20, 0x64, 0x6f, 0x67
175
+ ].pack("C*")
176
+
177
+ l = Libnet.new(:link)
178
+
179
+ if Process.uid > 0 && Process.euid > 0
180
+ # user is not root, so we should get an exception here
181
+ assert_raise RuntimeError do
182
+ l.write_bytes(eth)
183
+ end
184
+ else
185
+ # user is root, so this should work
186
+ n = l.write_bytes(eth)
187
+ assert_equal(eth.length, n)
188
+ end
189
+
190
+ l = Libnet.new(:raw4)
191
+
192
+ if Process.uid > 0 && Process.euid > 0
193
+ # user is not root, so we should get an exception here
194
+ assert_raise RuntimeError do
195
+ l.write_bytes(ip4)
196
+ end
197
+ else
198
+ # user is root, so this should work
199
+ n = l.write_bytes(ip4)
200
+ assert_equal(ip4.length, n)
201
+ end
202
+
203
+ l = Libnet.new(:raw6)
204
+
205
+ if Process.uid > 0 && Process.euid > 0
206
+ # user is not root, so we should get an exception here
207
+ assert_raise RuntimeError do
208
+ l.write_bytes(ip6)
209
+ end
210
+ else
211
+ # FIXME: I keep getting "no route to host" errors here, not sure how to
212
+ # fix this yet
213
+ # # user is root, so this should work
214
+ # n =l.write_bytes(ip6)
215
+ # assert_equal(ip6.length, n)
216
+ end
217
+ end
218
+ end
219
+
@@ -0,0 +1,97 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+
3
+ require 'test/unit'
4
+ require 'libnet4r'
5
+
6
+ class TC_Libnet_Ethernet < Test::Unit::TestCase
7
+ def test_unpack
8
+ eth = [
9
+ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
10
+ 0x12, 0x34, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
11
+ 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65
12
+ ].pack("C*")
13
+
14
+ e = Libnet::Ethernet.decode(eth)
15
+
16
+ assert_equal([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff].pack("C*"), e.dst)
17
+ assert_equal([0x11, 0x22, 0x33, 0x44, 0x55, 0x66].pack("C*"), e.src)
18
+ assert_equal(0x1234, e.type)
19
+ assert_equal("this is the message", e.payload)
20
+
21
+ assert_raise ArgumentError do
22
+ Libnet::Ethernet.decode("foobar")
23
+ end
24
+ end
25
+
26
+ def test_pack
27
+ eth = [
28
+ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
29
+ 0x12, 0x34, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
30
+ 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65
31
+ ].pack("C*")
32
+
33
+ e = Libnet::Ethernet.new
34
+
35
+ e.dst = 'aa:bb:cc:dd:ee:ff'
36
+ e.src = [0x11, 0x22, 0x33, 0x44, 0x55, 0x66].pack("C*")
37
+ e.type = 0x1234
38
+ e.payload = "this is the message"
39
+
40
+ l = Libnet.new
41
+
42
+ assert_nil(e.ptag)
43
+
44
+ l.build_ethernet(e)
45
+
46
+ assert(e.ptag > 0)
47
+ assert_equal(eth, l.pack)
48
+
49
+ l = Libnet.new
50
+ e = nil
51
+
52
+ l.build_ethernet do |e|
53
+ e.dst = 'aa:bb:cc:dd:ee:ff'
54
+ e.src = [0x11, 0x22, 0x33, 0x44, 0x55, 0x66].pack("C*")
55
+ e.type = 0x1234
56
+ e.payload = "this is the message"
57
+ end
58
+
59
+ assert(e.ptag > 0)
60
+ assert_equal(eth, l.pack)
61
+ end
62
+
63
+ def test_modify_ptag
64
+ eth1 = [
65
+ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
66
+ 0x12, 0x34, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
67
+ 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65
68
+ ].pack("C*")
69
+
70
+ eth2 = [
71
+ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
72
+ 0xab, 0xcd, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
73
+ 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65
74
+ ].pack("C*")
75
+
76
+ l = Libnet.new
77
+
78
+ e = l.build_ethernet do |e|
79
+ e.dst = 'aa:bb:cc:dd:ee:ff'
80
+ e.src = '11:22:33:44:55:66'
81
+ e.type = 0x1234
82
+ e.payload = "this is the message"
83
+ end
84
+
85
+ assert_not_nil(e.ptag)
86
+ ptag = e.ptag
87
+
88
+ assert_equal(eth1, l.pack)
89
+
90
+ e.type = 0xabcd
91
+
92
+ l.build_ethernet(e)
93
+
94
+ assert_equal(ptag, e.ptag)
95
+ assert_equal(eth2, l.pack)
96
+ end
97
+ end
data/test/tc_header.rb ADDED
@@ -0,0 +1,163 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+
3
+ require 'test/unit'
4
+ require 'libnet4r'
5
+
6
+ class TestHeader1 < Libnet::Header
7
+ unsigned_field :foo, 4
8
+ unsigned_field :bar, 2, :optional => true, :aliases => [ :bar2, :bar3 ]
9
+ unsigned_field :baz, 1, :read_only => true, :aliases => [ :baz2 ]
10
+ octets_field :qux
11
+ end
12
+
13
+ class TestHeader2 < Libnet::Header
14
+ unsigned_field :checksum, 4
15
+ end
16
+
17
+ class TC_Libnet_Header < Test::Unit::TestCase
18
+ def test_fields
19
+ assert_equal([:foo, :qux, :bar, :baz], TestHeader1.fields)
20
+ assert_equal([:foo, :qux], TestHeader1.required_fields)
21
+ assert_equal([:bar], TestHeader1.optional_fields)
22
+ assert_equal([:baz], TestHeader1.read_only_fields)
23
+
24
+ assert_equal([:checksum], TestHeader2.fields)
25
+ assert_equal([:checksum], TestHeader2.required_fields)
26
+ assert_equal([], TestHeader2.optional_fields)
27
+ assert_equal([], TestHeader2.read_only_fields)
28
+ end
29
+
30
+ def test_decode
31
+ assert_respond_to(TestHeader1, :decode)
32
+
33
+ # subclasses must implement the decode method
34
+ assert_raise NotImplementedError do
35
+ p = TestHeader1.new("foobarbaz")
36
+ end
37
+ end
38
+
39
+ def test_field_assignment
40
+ p = TestHeader1.new
41
+
42
+ # writeable fields should have assigment methods
43
+ assert_respond_to(p, :foo=)
44
+ assert_respond_to(p, :bar=)
45
+ assert_respond_to(p, :qux=)
46
+
47
+ assert_equal(p.foo = 1, 1)
48
+ assert_equal(p.bar = 2, 2)
49
+ assert_equal(p.qux = "stuff", "stuff")
50
+
51
+ # read-only fields should not have assignment methods
52
+ assert_raise NoMethodError do
53
+ p.baz = 1
54
+ end
55
+ end
56
+
57
+ def test_read_query
58
+ p = TestHeader1.new
59
+
60
+ assert_respond_to(p, :foo)
61
+ assert_respond_to(p, :foo?)
62
+ assert_respond_to(p, :bar)
63
+ assert_respond_to(p, :bar?)
64
+ assert_respond_to(p, :baz)
65
+ assert_respond_to(p, :baz?)
66
+ assert_respond_to(p, :qux)
67
+ assert_respond_to(p, :qux?)
68
+
69
+ assert_equal(false, p.foo?)
70
+ assert_equal(false, p.bar?)
71
+ assert_equal(false, p.baz?)
72
+ assert_equal(false, p.qux?)
73
+
74
+ p.foo = 1
75
+ p.bar = 2
76
+ p.qux = "stuff"
77
+
78
+ assert_equal(true, p.foo?)
79
+ assert_equal(true, p.bar?)
80
+ assert_equal(false, p.baz?)
81
+ assert_equal(true, p.qux?)
82
+
83
+ assert_equal(p.foo, 1)
84
+ assert_equal(p.bar, 2)
85
+ assert_equal(p.qux, "stuff")
86
+ end
87
+
88
+ def test_alias
89
+ p = TestHeader1.new
90
+
91
+ assert_respond_to(p, :bar2)
92
+ assert_respond_to(p, :bar2=)
93
+ assert_respond_to(p, :bar2?)
94
+ assert_respond_to(p, :bar3)
95
+ assert_respond_to(p, :bar3=)
96
+ assert_respond_to(p, :bar3?)
97
+
98
+ assert_respond_to(p, :baz2)
99
+ assert_respond_to(p, :baz2?)
100
+
101
+ assert_equal(false, p.respond_to?(:baz2=))
102
+ end
103
+
104
+ def test_range_checks
105
+ p = TestHeader1.new
106
+
107
+ assert_raise ArgumentError do
108
+ p.foo = -1
109
+ end
110
+
111
+ assert_equal(p.foo = 0, 0)
112
+ assert_equal(p.foo = 0xffffffff, 0xffffffff)
113
+
114
+ assert_raise ArgumentError do
115
+ p.foo = 0x100000000
116
+ end
117
+ end
118
+
119
+ def test_ptag
120
+ p = TestHeader1.new
121
+
122
+ assert_respond_to(p, :ptag)
123
+ end
124
+
125
+ def test_auto_checksum_toggle
126
+ p1 = TestHeader1.new
127
+ p2 = TestHeader2.new
128
+
129
+ assert_raise NoMethodError do
130
+ p1.auto_checksum?
131
+ end
132
+
133
+ assert_raise NoMethodError do
134
+ p1.auto_checksum = false
135
+ end
136
+
137
+ assert_respond_to(p2, :auto_checksum?)
138
+ assert_respond_to(p2, :auto_checksum=)
139
+ end
140
+
141
+ def test_check_packable
142
+ p = TestHeader1.new
143
+
144
+ assert(p.private_methods.include?('check_packable'))
145
+
146
+ assert_raise ArgumentError, "the following TestHeader1 required fields have not been set: foo, qux" do
147
+ p.send(:check_packable)
148
+ end
149
+
150
+ p.foo = 1
151
+
152
+ assert_raise ArgumentError, "the following TestHeader1 required fields have not been set: qux" do
153
+ p.send(:check_packable)
154
+ end
155
+
156
+ p.qux = "stuff"
157
+
158
+ assert_nothing_raised ArgumentError do
159
+ p.send(:check_packable)
160
+ end
161
+ end
162
+ end
163
+
data/test/tc_init.rb ADDED
@@ -0,0 +1,25 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+
3
+ require 'test/unit'
4
+ require 'libnet4r'
5
+
6
+ class TC_Libnet_Init
7
+ def test_init
8
+ # default injection type should be :raw4
9
+ assert_equal(Libnet.new.injection_type, :raw4)
10
+
11
+ assert_equal(Libnet.new(:raw4).injection_type, :raw4)
12
+ assert_equal(Libnet.new('raw4').injection_type, :raw4)
13
+ assert_equal(Libnet.new(:raw).injection_type, :raw4)
14
+ assert_equal(Libnet.new('raw').injection_type, :raw4)
15
+
16
+ assert_equal(Libnet.new(:link).injection_type, :link)
17
+ assert_equal(Libnet.new('link').injection_type, :link)
18
+
19
+ assert_equal(Libnet.new(:raw4, 'en0').device, 'en0')
20
+
21
+ assert_raise ArgumentError do
22
+ Libnet.new(:foo)
23
+ end
24
+ end
25
+ end