lib-bootp 0.2.3 → 0.2.4
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.
- checksums.yaml +4 -4
- data/lib/lib/bootp/packet/flags.rb +2 -2
- data/lib/lib/bootp/packet/hardware_address_type.rb +2 -2
- data/lib/lib/bootp/packet/hop_count.rb +2 -2
- data/lib/lib/bootp/packet/op_code.rb +2 -2
- data/lib/lib/bootp/packet/transaction_id.rb +3 -3
- data/lib/lib/bootp/version.rb +1 -1
- data/lib/lib/bootp.rb +23 -30
- data/lib-bootp.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bed60f10af914d6832cb7d6b35edecdf91b7216410f912bdc6fbf6b28326e937
|
4
|
+
data.tar.gz: 6e185e3ac0c45d43beaff60ddee746e475ccbcff507499409330dcfa9cfb0a0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 463b1ef322b4aed9ee14cb81a6cb6297d28a6b35e6c7d289a131965a8b24040bf5371b5be51f82fd46dc470ed24a9ac7241eb9e94db8483c548ba36879194edb
|
7
|
+
data.tar.gz: 3516025c3729975d85563278db1611746b5cdd3fedda7f914337c23d3603079ee11af8327f983f568cd817994e4e668cb7e2eecf7a86f9501ccc3fa0a7dda7dd
|
@@ -16,8 +16,8 @@ module Lib
|
|
16
16
|
def_delegator :@htype, :to_i
|
17
17
|
|
18
18
|
def initialize(htype=1)
|
19
|
-
|
20
|
-
@htype
|
19
|
+
@htype = htype.is_a?(Hash) ? htype.transform_keys(&:to_sym)[:code].to_i : htype
|
20
|
+
raise ArgumentError, "Hardware address type out of range : #{@htype}" unless (0..12).include? @htype
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_s
|
@@ -16,8 +16,8 @@ module Lib
|
|
16
16
|
def_delegators :@hops, :to_s, :to_i
|
17
17
|
|
18
18
|
def initialize(hops=0)
|
19
|
-
|
20
|
-
@hops
|
19
|
+
@hops = hops.to_i #.is_a?(Hash) ? hops.transform_keys(&:to_sym)[:code].to_i : hops.to_i
|
20
|
+
raise ArgumentError, "Hop Count out of range: #{@hops}" if @hops > 255
|
21
21
|
end
|
22
22
|
|
23
23
|
def <=>(other)
|
@@ -17,8 +17,8 @@ module Lib
|
|
17
17
|
def_delegator :@op, :to_i
|
18
18
|
|
19
19
|
def initialize(op=1)
|
20
|
-
|
21
|
-
@op
|
20
|
+
@op = op.is_a?(Hash) ? op.transform_keys(&:to_sym)[:code].to_i : op
|
21
|
+
raise ArgumentError, "OP Code out of range : #{@op}" unless [1,2].include? @op.to_i
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_s
|
@@ -17,10 +17,10 @@ module Lib
|
|
17
17
|
|
18
18
|
def initialize(xid = nil)
|
19
19
|
xid = generate if xid.nil?
|
20
|
-
|
21
|
-
|
20
|
+
@xid = xid.to_i
|
21
|
+
unless @xid >= 0 && @xid <= 0xFFFFFFFF
|
22
|
+
raise ArgumentError, "Not valid XID - #{@xid} - should by 4 octet length"
|
22
23
|
end
|
23
|
-
@xid = xid
|
24
24
|
end
|
25
25
|
|
26
26
|
def <=>(other)
|
data/lib/lib/bootp/version.rb
CHANGED
data/lib/lib/bootp.rb
CHANGED
@@ -37,20 +37,24 @@ module Lib
|
|
37
37
|
|
38
38
|
def initialize(op: 1, htype: 1, hlen: 6, hops: 0, xid: nil, secs: 0, flags: 0, ciaddr: 0, yiaddr: 0, siaddr: 0, giaddr: 0, chaddr: nil, sname: '.', file: '.')
|
39
39
|
@packets = {}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
40
|
+
if block_given?
|
41
|
+
yield self
|
42
|
+
else
|
43
|
+
@packets[:op] = (op.is_a? Lib::BOOTP::Packet::OpCode) ? op : Lib::BOOTP::Packet::OpCode.new(op)
|
44
|
+
@packets[:htype] = (htype.is_a? Lib::BOOTP::Packet::HardwareAddressType) ? htype : Lib::BOOTP::Packet::HardwareAddressType.new(htype)
|
45
|
+
@packets[:hlen] = (hlen.is_a? Lib::BOOTP::Packet::HardwareAddressLength) ? hlen : Lib::BOOTP::Packet::HardwareAddressLength.new(hlen)
|
46
|
+
@packets[:hops] = (hops.is_a? Lib::BOOTP::Packet::HopCount) ? hops : Lib::BOOTP::Packet::HopCount.new(hops)
|
47
|
+
@packets[:xid] = (xid.is_a? Lib::BOOTP::Packet::TransactionID) ? xid : Lib::BOOTP::Packet::TransactionID.new(xid)
|
48
|
+
@packets[:secs] = (secs.is_a? Lib::BOOTP::Packet::Seconds) ? secs : Lib::BOOTP::Packet::Seconds.new(secs)
|
49
|
+
@packets[:flags] = (flags.is_a? Lib::BOOTP::Packet::Flags) ? flags : Lib::BOOTP::Packet::Flags.new(flags)
|
50
|
+
@packets[:ciaddr] = (ciaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? ciaddr : Lib::BOOTP::Packet::IPAddress.new(ciaddr)
|
51
|
+
@packets[:yiaddr] = (yiaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? yiaddr : Lib::BOOTP::Packet::IPAddress.new(yiaddr)
|
52
|
+
@packets[:siaddr] = (siaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? siaddr : Lib::BOOTP::Packet::IPAddress.new(siaddr)
|
53
|
+
@packets[:giaddr] = (giaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? giaddr : Lib::BOOTP::Packet::IPAddress.new(giaddr)
|
54
|
+
@packets[:chaddr] = (chaddr.is_a? Lib::BOOTP::Packet::ClientHardwareAddress) ? chaddr : Lib::BOOTP::Packet::ClientHardwareAddress.new(chaddr)
|
55
|
+
@packets[:sname] = (sname.is_a? Lib::BOOTP::Packet::ServerHostName) ? sname : Lib::BOOTP::Packet::ServerHostName.new(sname)
|
56
|
+
@packets[:file] = (file.is_a? Lib::BOOTP::Packet::BootFile) ? file : Lib::BOOTP::Packet::BootFile.new(file)
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
60
|
def op=(op)
|
@@ -174,22 +178,11 @@ module Lib
|
|
174
178
|
|
175
179
|
def self.from_json(json)
|
176
180
|
json = json.is_a?(Hash) ? json: JSON.parse(json)
|
177
|
-
self.new
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
xid: json['xid'].to_i,
|
183
|
-
secs: json['secs'].to_i,
|
184
|
-
flags: json['flags'].to_i,
|
185
|
-
ciaddr: json['ciaddr']['address'].to_s,
|
186
|
-
yiaddr: json['yiaddr']['address'].to_s,
|
187
|
-
siaddr: json['siaddr']['address'].to_s,
|
188
|
-
giaddr: json['giaddr']['address'].to_s,
|
189
|
-
chaddr: json['chaddr'].to_s,
|
190
|
-
sname: json['sname'].to_s,
|
191
|
-
file: json['file'].to_s
|
192
|
-
)
|
181
|
+
self.new do |p|
|
182
|
+
json.each_pair do |k,v|
|
183
|
+
p.send("#{k}=".to_sym, v) rescue NoMethodError
|
184
|
+
end
|
185
|
+
end
|
193
186
|
end
|
194
187
|
|
195
188
|
end
|
data/lib-bootp.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
26
|
|
27
|
-
spec.add_dependency 'net-address', '~> 0.2.
|
27
|
+
spec.add_dependency 'net-address', '~> 0.2.2'
|
28
28
|
|
29
29
|
spec.required_ruby_version = '>= 3.0.0'
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lib-bootp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Wojcieszonek
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.2.
|
61
|
+
version: 0.2.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.2.
|
68
|
+
version: 0.2.2
|
69
69
|
description: Set of classes to low level handle the BOOTP protocol
|
70
70
|
email:
|
71
71
|
- piotr@wojcieszonek.pl
|