net-dhcp 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/Rakefile +7 -0
- data/lib/net-dhcp/version.rb +1 -1
- data/lib/net/dhcp/core.rb +17 -11
- data/net-dhcp.gemspec +1 -1
- data/test/{dhcp_test.rb → test_dhcp.rb} +3 -4
- metadata +15 -15
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
*1.1.1
|
2
|
+
|
3
|
+
* Replace incorrect equality check with assignment in Message#from_udp_payload to correct behaviour when an unrecognised option or message is encountered [mjtko]
|
4
|
+
* Allow callers to disable the debug output emitted in Message#from_udp_payload for unrecognised options or messages [mjtko]
|
5
|
+
* Added rake test task [mjtko]
|
6
|
+
* Correct test_from_udp_payload test assertion [mjtko]
|
7
|
+
* Default to 00:00:00:00:00:00 in Message#initialize if local MAC address can't be read [mjtko]
|
8
|
+
|
1
9
|
*1.1.0
|
2
10
|
|
3
11
|
* Added BroadcastAddressOption and cleaned up the output for some options to make them more readable [rakshasa]
|
data/Rakefile
CHANGED
@@ -40,3 +40,10 @@ Rake::RDocTask.new do |rdoc|
|
|
40
40
|
rdoc.rdoc_files.include('README*')
|
41
41
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
42
42
|
end
|
43
|
+
|
44
|
+
require 'rake/testtask'
|
45
|
+
Rake::TestTask.new do |t|
|
46
|
+
t.libs << "test"
|
47
|
+
t.test_files = FileList['test/test*.rb']
|
48
|
+
t.verbose = true
|
49
|
+
end
|
data/lib/net-dhcp/version.rb
CHANGED
data/lib/net/dhcp/core.rb
CHANGED
@@ -33,7 +33,8 @@ module DHCP
|
|
33
33
|
|
34
34
|
alias == eql?
|
35
35
|
|
36
|
-
def Message.from_udp_payload(data)
|
36
|
+
def Message.from_udp_payload(data, opts={})
|
37
|
+
opts = {:debug => true}.merge(opts)
|
37
38
|
values = data.unpack('C4Nn2N4C16C192NC*')
|
38
39
|
|
39
40
|
params = {
|
@@ -74,11 +75,13 @@ module DHCP
|
|
74
75
|
|
75
76
|
# check what is the type of dhcp option
|
76
77
|
opt_class = $DHCP_MSG_OPTIONS[p[:type]]
|
77
|
-
if
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
if opt_class.nil?
|
79
|
+
if opts[:debug]
|
80
|
+
puts '-------------------- please further investigate!!'
|
81
|
+
puts p[:type]
|
82
|
+
puts '-------------------- /'
|
83
|
+
end
|
84
|
+
opt_class = Option
|
82
85
|
end
|
83
86
|
if (opt_class == MessageTypeOption)
|
84
87
|
msg_class = $DHCP_MSG_CLASSES[p[:payload].first]
|
@@ -87,11 +90,13 @@ module DHCP
|
|
87
90
|
next_opt = values.shift
|
88
91
|
end
|
89
92
|
|
90
|
-
if
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
93
|
+
if msg_class.nil?
|
94
|
+
if opts[:debug]
|
95
|
+
puts '-------------------- please further investigate!!'
|
96
|
+
p params[:options]
|
97
|
+
puts '-------------------- /'
|
98
|
+
end
|
99
|
+
msg_class = Message
|
95
100
|
end
|
96
101
|
msg_class.new(params)
|
97
102
|
end
|
@@ -139,6 +144,7 @@ module DHCP
|
|
139
144
|
raise 'chaddr field should be of 16 bytes' unless self.chaddr.size == 16
|
140
145
|
else
|
141
146
|
mac = `/sbin/ifconfig | grep HWaddr | cut -c39- | head -1`.chomp.strip.gsub(/:/,'')
|
147
|
+
mac = '000000000000' if mac.empty?
|
142
148
|
self.chaddr = [mac].pack('H*').unpack('CCCCCC')
|
143
149
|
self.chaddr += [0x00]*(16-self.chaddr.size)
|
144
150
|
end
|
data/net-dhcp.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'net-dhcp'
|
6
6
|
s.version = Net::Dhcp::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.date = "
|
8
|
+
s.date = "2012-01-21"
|
9
9
|
s.authors = ['daniel martin gomez (etd)', 'syonbori', 'Mark J. Titorenko']
|
10
10
|
s.email = 'mark.titorenko@alces-software.com'
|
11
11
|
s.homepage = 'http://github.com/mjtko/net-dhcp-ruby'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
# dhcp_test.rb
|
2
3
|
# 4 de octubre de 2007
|
3
4
|
#
|
@@ -6,7 +7,7 @@ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
|
6
7
|
|
7
8
|
require 'test/unit'
|
8
9
|
|
9
|
-
require 'dhcp'
|
10
|
+
require 'net-dhcp'
|
10
11
|
|
11
12
|
class TestDhcp_test < Test::Unit::TestCase
|
12
13
|
# def setup
|
@@ -63,9 +64,7 @@ class TestDhcp_test < Test::Unit::TestCase
|
|
63
64
|
d1 = DHCP::Discover.new
|
64
65
|
d2 = DHCP::Message.from_udp_payload(d1.pack)
|
65
66
|
|
66
|
-
|
67
|
-
puts d1.eql?(d2)
|
68
|
-
puts(d1 == d2)
|
67
|
+
assert d1.eql?(d2), 'udp data is not correctly parsed'
|
69
68
|
end
|
70
69
|
|
71
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-dhcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2012-01-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
18
|
-
requirement: &
|
18
|
+
requirement: &70354871060620 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: '0'
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70354871060620
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
|
-
requirement: &
|
29
|
+
requirement: &70354871060140 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *70354871060140
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: bueller
|
40
|
-
requirement: &
|
40
|
+
requirement: &70354871059700 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *70354871059700
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
|
-
requirement: &
|
51
|
+
requirement: &70354871059240 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *70354871059240
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rcov
|
62
|
-
requirement: &
|
62
|
+
requirement: &70354871058740 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *70354871058740
|
71
71
|
description: The aim of Net::DHCP is to provide a set of classes to low level handle
|
72
72
|
the DHCP protocol (rfc2131, rfc2132, etc.). With Net::DHCP you will be able to craft
|
73
73
|
custom DHCP packages and have access to all the fields defined for the protocol.
|
@@ -99,7 +99,7 @@ files:
|
|
99
99
|
- net-dhcp.gemspec
|
100
100
|
- spec/net-dhcp_spec.rb
|
101
101
|
- spec/spec_helper.rb
|
102
|
-
- test/
|
102
|
+
- test/test_dhcp.rb
|
103
103
|
homepage: http://github.com/mjtko/net-dhcp-ruby
|
104
104
|
licenses: []
|
105
105
|
post_install_message:
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
hash:
|
117
|
+
hash: -2659112004771839654
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
@@ -130,4 +130,4 @@ summary: set of classes to low level handle the DHCP protocol
|
|
130
130
|
test_files:
|
131
131
|
- spec/net-dhcp_spec.rb
|
132
132
|
- spec/spec_helper.rb
|
133
|
-
- test/
|
133
|
+
- test/test_dhcp.rb
|