dnet-ffi 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +7 -0
- data/LICENSE +20 -0
- data/README.rdoc +37 -0
- data/Rakefile +64 -0
- data/VERSION +1 -0
- data/dnet-ffi.gemspec +99 -0
- data/lib/dnet.rb +35 -0
- data/lib/dnet/addr.rb +204 -0
- data/lib/dnet/arp.rb +168 -0
- data/lib/dnet/blob.rb +246 -0
- data/lib/dnet/bsd.rb +123 -0
- data/lib/dnet/constants.rb +555 -0
- data/lib/dnet/eth.rb +143 -0
- data/lib/dnet/fw.rb +106 -0
- data/lib/dnet/helpers.rb +164 -0
- data/lib/dnet/icmp.rb +304 -0
- data/lib/dnet/intf.rb +194 -0
- data/lib/dnet/ip.rb +315 -0
- data/lib/dnet/ip6.rb +59 -0
- data/lib/dnet/rand.rb +33 -0
- data/lib/dnet/route.rb +103 -0
- data/lib/dnet/tcp.rb +103 -0
- data/lib/dnet/tun.rb +24 -0
- data/lib/dnet/typedefs.rb +12 -0
- data/lib/dnet/udp.rb +31 -0
- data/lib/dnet/util.rb +70 -0
- data/samples/eth_send_raw.rb +29 -0
- data/samples/ifconfig-alike.rb +44 -0
- data/samples/udp_send_raw.rb +74 -0
- data/spec/addr_spec.rb +15 -0
- data/spec/arp_spec.rb +95 -0
- data/spec/blob_spec.rb +15 -0
- data/spec/bsd_spec.rb +60 -0
- data/spec/dnet-ffi_spec.rb +31 -0
- data/spec/eth_spec.rb +47 -0
- data/spec/fw_spec.rb +15 -0
- data/spec/intf_spec.rb +98 -0
- data/spec/ip6_spec.rb +15 -0
- data/spec/ip_spec.rb +15 -0
- data/spec/rand_spec.rb +15 -0
- data/spec/route_spec.rb +94 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/tun_spec.rb +15 -0
- metadata +121 -0
data/spec/ip6_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Dnet::Addr" do
|
4
|
+
context "dnet(3) function bindings" do
|
5
|
+
funcs = %w{ ip6_checksum }
|
6
|
+
|
7
|
+
funcs.each do |func|
|
8
|
+
it "should have bound: #{func}()" do
|
9
|
+
::Dnet.respond_to?(func).should == true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/ip_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Dnet::Ip" do
|
4
|
+
context "dnet(3) ip_* function bindings" do
|
5
|
+
funcs = %w{ ip_open ip_add_option ip_checksum ip_send ip_close }
|
6
|
+
|
7
|
+
funcs.each do |func|
|
8
|
+
it "should have bound: #{func}()" do
|
9
|
+
::Dnet.respond_to?(func).should == true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/rand_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Dnet::Rand" do
|
4
|
+
context "dnet(3) rand_* function bindings" do
|
5
|
+
funcs = %w{ rand_open rand_get rand_set rand_add rand_uint8 rand_uint16 rand_uint32 rand_shuffle rand_close }
|
6
|
+
|
7
|
+
funcs.each do |func|
|
8
|
+
it "should have bound: #{func}()" do
|
9
|
+
::Dnet.respond_to?(func).should == true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/route_spec.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Dnet::Route" do
|
4
|
+
context "dnet(3) route_* function bindings" do
|
5
|
+
funcs = %w{ route_open route_add route_delete route_get route_loop route_close }
|
6
|
+
|
7
|
+
funcs.each do |func|
|
8
|
+
it "should have bound: #{func}()" do
|
9
|
+
::Dnet.respond_to?(func).should == true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
context "the Dnet::Route module" do
|
16
|
+
it "should be a module" do
|
17
|
+
Route.kind_of?(Module).should == true
|
18
|
+
end
|
19
|
+
|
20
|
+
[:open, :each_entry, :entries].each do |meth|
|
21
|
+
it "should provide a method called #{meth}()" do
|
22
|
+
Route.respond_to?(meth).should == true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "the each_entry() method" do
|
27
|
+
it "should fire a block for each entry" do
|
28
|
+
i=0
|
29
|
+
Route.each_entry {|e| i+=1 }
|
30
|
+
i.should_not == 0
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should yield route entries to a block as Route::Entry objects" do
|
34
|
+
Route.each_entry {|e| e.kind_of?(Route::Entry).should == true }
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
context "the entries() method" do
|
40
|
+
before(:all) do
|
41
|
+
@entries = Route.entries()
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return an array" do
|
45
|
+
@entries.kind_of?(Array).should == true
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should produce a non-emtpy list" do
|
49
|
+
@entries.empty?.should == false
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should produce route entries as Route::Entry objects" do
|
53
|
+
@entries.each {|e| e.kind_of?(Route::Entry).should == true }
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
context "the Dnet::Route::Handle class" do
|
61
|
+
context "instance" do
|
62
|
+
before(:all) do
|
63
|
+
@h = Route::Handle.new
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have opened a handle" do
|
67
|
+
@h.handle.kind_of?(::FFI::Pointer).should == true
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should provide a way to get a list of entries" do
|
71
|
+
@h.respond_to?(:entries).should == true
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should provide that list as an array" do
|
75
|
+
@h.entries().kind_of?(Array).should == true
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should provide route entries in that array" do
|
79
|
+
@h.entries().each{|e| e.kind_of?(Route::Entry).should == true}
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should provide an iterator for entries" do
|
83
|
+
@h.respond_to?(:loop).should == true
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should provide route entries through the iterator" do
|
87
|
+
@h.loop {|x| x.kind_of?(Route::Entry).should == true }
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'dnet'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
|
7
|
+
include Dnet
|
8
|
+
|
9
|
+
p ARGV
|
10
|
+
|
11
|
+
NET_DEV = ENV['DNET_TEST_INTERFACE']
|
12
|
+
|
13
|
+
Spec::Runner.configure do |config|
|
14
|
+
|
15
|
+
end
|
data/spec/tun_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Dnet::Tun" do
|
4
|
+
context "dnet(3) tun_* function bindings" do
|
5
|
+
funcs = %w{ tun_open tun_fileno tun_name tun_send tun_recv tun_close }
|
6
|
+
|
7
|
+
funcs.each do |func|
|
8
|
+
it "should have bound: #{func}()" do
|
9
|
+
::Dnet.respond_to?(func).should == true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dnet-ffi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Monti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-17 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Ruby FFI bindings for the libdnet raw network library
|
26
|
+
email: emonti@matasano.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- dnet-ffi.gemspec
|
42
|
+
- lib/dnet.rb
|
43
|
+
- lib/dnet/addr.rb
|
44
|
+
- lib/dnet/arp.rb
|
45
|
+
- lib/dnet/blob.rb
|
46
|
+
- lib/dnet/bsd.rb
|
47
|
+
- lib/dnet/constants.rb
|
48
|
+
- lib/dnet/eth.rb
|
49
|
+
- lib/dnet/fw.rb
|
50
|
+
- lib/dnet/helpers.rb
|
51
|
+
- lib/dnet/icmp.rb
|
52
|
+
- lib/dnet/intf.rb
|
53
|
+
- lib/dnet/ip.rb
|
54
|
+
- lib/dnet/ip6.rb
|
55
|
+
- lib/dnet/rand.rb
|
56
|
+
- lib/dnet/route.rb
|
57
|
+
- lib/dnet/tcp.rb
|
58
|
+
- lib/dnet/tun.rb
|
59
|
+
- lib/dnet/typedefs.rb
|
60
|
+
- lib/dnet/udp.rb
|
61
|
+
- lib/dnet/util.rb
|
62
|
+
- samples/eth_send_raw.rb
|
63
|
+
- samples/ifconfig-alike.rb
|
64
|
+
- samples/udp_send_raw.rb
|
65
|
+
- spec/addr_spec.rb
|
66
|
+
- spec/arp_spec.rb
|
67
|
+
- spec/blob_spec.rb
|
68
|
+
- spec/bsd_spec.rb
|
69
|
+
- spec/dnet-ffi_spec.rb
|
70
|
+
- spec/eth_spec.rb
|
71
|
+
- spec/fw_spec.rb
|
72
|
+
- spec/intf_spec.rb
|
73
|
+
- spec/ip6_spec.rb
|
74
|
+
- spec/ip_spec.rb
|
75
|
+
- spec/rand_spec.rb
|
76
|
+
- spec/route_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
- spec/tun_spec.rb
|
79
|
+
has_rdoc: true
|
80
|
+
homepage: http://github.com/emonti/dnet-ffi
|
81
|
+
licenses: []
|
82
|
+
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options:
|
85
|
+
- --charset=UTF-8
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
93
|
+
version:
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: "0"
|
99
|
+
version:
|
100
|
+
requirements: []
|
101
|
+
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.3.4
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Ruby FFI bindings for libdnet
|
107
|
+
test_files:
|
108
|
+
- spec/addr_spec.rb
|
109
|
+
- spec/arp_spec.rb
|
110
|
+
- spec/blob_spec.rb
|
111
|
+
- spec/bsd_spec.rb
|
112
|
+
- spec/dnet-ffi_spec.rb
|
113
|
+
- spec/eth_spec.rb
|
114
|
+
- spec/fw_spec.rb
|
115
|
+
- spec/intf_spec.rb
|
116
|
+
- spec/ip6_spec.rb
|
117
|
+
- spec/ip_spec.rb
|
118
|
+
- spec/rand_spec.rb
|
119
|
+
- spec/route_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/tun_spec.rb
|