lib-bootp 0.2.3 → 0.2.5
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 +44 -46
- 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: 0eba596b6a76e310f08fe03b3e229e64a2867bcd94a39c88a9777dc60165135c
|
4
|
+
data.tar.gz: ccd6b4385ec0ac74a8aaa1eb72048961d687223202fdad6bfab55d271d872a4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15d7ed3014191104c8c7ad349510e6a11bdf288979ab889017a164819ed45efed9d5f08055f097704baae6e856cc9bbfabce8f222e50f17d2289bab5bda6771d
|
7
|
+
data.tar.gz: c16a739bdeda069887641a7d30d92cc49b6fe078b859fc69c37ebe10de60a68ea9437f72f161ec2fdb8160cd2ef12a65a657005707e390c8bdf101437fc7d131
|
@@ -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
@@ -36,82 +36,85 @@ module Lib
|
|
36
36
|
hash_attr_reader :packets, :op, :htype, :hlen, :hops, :xid, :secs, :flags, :ciaddr, :yiaddr, :siaddr, :giaddr, :chaddr, :sname, :file
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
39
|
+
if block_given?
|
40
|
+
yield self
|
41
|
+
else
|
42
|
+
packets[:op] = (op.is_a? Lib::BOOTP::Packet::OpCode) ? op : Lib::BOOTP::Packet::OpCode.new(op)
|
43
|
+
packets[:htype] = (htype.is_a? Lib::BOOTP::Packet::HardwareAddressType) ? htype : Lib::BOOTP::Packet::HardwareAddressType.new(htype)
|
44
|
+
packets[:hlen] = (hlen.is_a? Lib::BOOTP::Packet::HardwareAddressLength) ? hlen : Lib::BOOTP::Packet::HardwareAddressLength.new(hlen)
|
45
|
+
packets[:hops] = (hops.is_a? Lib::BOOTP::Packet::HopCount) ? hops : Lib::BOOTP::Packet::HopCount.new(hops)
|
46
|
+
packets[:xid] = (xid.is_a? Lib::BOOTP::Packet::TransactionID) ? xid : Lib::BOOTP::Packet::TransactionID.new(xid)
|
47
|
+
packets[:secs] = (secs.is_a? Lib::BOOTP::Packet::Seconds) ? secs : Lib::BOOTP::Packet::Seconds.new(secs)
|
48
|
+
packets[:flags] = (flags.is_a? Lib::BOOTP::Packet::Flags) ? flags : Lib::BOOTP::Packet::Flags.new(flags)
|
49
|
+
packets[:ciaddr] = (ciaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? ciaddr : Lib::BOOTP::Packet::IPAddress.new(ciaddr)
|
50
|
+
packets[:yiaddr] = (yiaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? yiaddr : Lib::BOOTP::Packet::IPAddress.new(yiaddr)
|
51
|
+
packets[:siaddr] = (siaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? siaddr : Lib::BOOTP::Packet::IPAddress.new(siaddr)
|
52
|
+
packets[:giaddr] = (giaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? giaddr : Lib::BOOTP::Packet::IPAddress.new(giaddr)
|
53
|
+
packets[:chaddr] = (chaddr.is_a? Lib::BOOTP::Packet::ClientHardwareAddress) ? chaddr : Lib::BOOTP::Packet::ClientHardwareAddress.new(chaddr)
|
54
|
+
packets[:sname] = (sname.is_a? Lib::BOOTP::Packet::ServerHostName) ? sname : Lib::BOOTP::Packet::ServerHostName.new(sname)
|
55
|
+
packets[:file] = (file.is_a? Lib::BOOTP::Packet::BootFile) ? file : Lib::BOOTP::Packet::BootFile.new(file)
|
56
|
+
end
|
54
57
|
end
|
55
58
|
|
56
59
|
def op=(op)
|
57
|
-
|
60
|
+
packets[:op] = (op.is_a? Lib::BOOTP::Packet::OpCode) ? op : Lib::BOOTP::Packet::OpCode.new(op)
|
58
61
|
end
|
59
62
|
|
60
63
|
def htype=(htype)
|
61
|
-
|
64
|
+
packets[:htype] = (htype.is_a? Lib::BOOTP::Packet::HardwareAddressType) ? htype : Lib::BOOTP::Packet::HardwareAddressType.new(htype)
|
62
65
|
end
|
63
66
|
|
64
67
|
def hlen=(hlen)
|
65
|
-
|
68
|
+
packets[:hlen] = (hlen.is_a? Lib::BOOTP::Packet::HardwareAddressLength) ? hlen : Lib::BOOTP::Packet::HardwareAddressLength.new(hlen)
|
66
69
|
end
|
67
70
|
|
68
71
|
def hops=(hops)
|
69
|
-
|
72
|
+
packets[:hops] = (hops.is_a? Lib::BOOTP::Packet::HopCount) ? hops : Lib::BOOTP::Packet::HopCount.new(hops)
|
70
73
|
end
|
71
74
|
|
72
75
|
def xid=(xid)
|
73
|
-
|
76
|
+
packets[:xid] = (xid.is_a? Lib::BOOTP::Packet::TransactionID) ? xid : Lib::BOOTP::Packet::TransactionID.new(xid)
|
74
77
|
end
|
75
78
|
|
76
79
|
def secs=(secs)
|
77
|
-
|
80
|
+
packets[:secs] = (secs.is_a? Lib::BOOTP::Packet::Seconds) ? secs : Lib::BOOTP::Packet::Seconds.new(secs)
|
78
81
|
end
|
79
82
|
|
80
83
|
def flags=(flags)
|
81
|
-
|
84
|
+
packets[:flags] = (flags.is_a? Lib::BOOTP::Packet::Flags) ? flags : Lib::BOOTP::Packet::Flags.new(flags)
|
82
85
|
end
|
83
86
|
|
84
87
|
def ciaddr=(ciaddr)
|
85
|
-
|
88
|
+
packets[:ciaddr] = (ciaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? ciaddr : Lib::BOOTP::Packet::IPAddress.new(ciaddr)
|
86
89
|
end
|
87
90
|
|
88
91
|
def yiaddr=(yiaddr)
|
89
|
-
|
92
|
+
packets[:yiaddr] = (yiaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? yiaddr : Lib::BOOTP::Packet::IPAddress.new(yiaddr)
|
90
93
|
end
|
91
94
|
|
92
95
|
def siaddr=(siaddr)
|
93
|
-
|
96
|
+
packets[:siaddr] = (siaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? siaddr : Lib::BOOTP::Packet::IPAddress.new(siaddr)
|
94
97
|
end
|
95
98
|
|
96
99
|
def giaddr=(giaddr)
|
97
|
-
|
100
|
+
packets[:giaddr] = (giaddr.is_a? Lib::BOOTP::Packet::IPAddress) ? giaddr : Lib::BOOTP::Packet::IPAddress.new(giaddr)
|
98
101
|
end
|
99
102
|
|
100
103
|
def chaddr=(chaddr)
|
101
|
-
|
104
|
+
packets[:chaddr] = (chaddr.is_a? Lib::BOOTP::Packet::ClientHardwareAddress) ? chaddr : Lib::BOOTP::Packet::ClientHardwareAddress.new(chaddr)
|
102
105
|
end
|
103
106
|
|
104
107
|
def sname=(sname)
|
105
|
-
|
108
|
+
packets[:sname] = (sname.is_a? Lib::BOOTP::Packet::ServerHostName) ? sname : Lib::BOOTP::Packet::ServerHostName.new(sname)
|
106
109
|
end
|
107
110
|
|
108
111
|
def file=(file)
|
109
|
-
|
112
|
+
packets[:file] = (file.is_a? Lib::BOOTP::Packet::BootFile) ? file : Lib::BOOTP::Packet::BootFile.new(file)
|
110
113
|
end
|
111
114
|
|
112
115
|
|
113
116
|
def to_h
|
114
|
-
|
117
|
+
packets
|
115
118
|
end
|
116
119
|
|
117
120
|
def to_s
|
@@ -174,22 +177,17 @@ module Lib
|
|
174
177
|
|
175
178
|
def self.from_json(json)
|
176
179
|
json = json.is_a?(Hash) ? json: JSON.parse(json)
|
177
|
-
self.new
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
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
|
-
)
|
180
|
+
self.new do |p|
|
181
|
+
json.each_pair do |k,v|
|
182
|
+
p.send("#{k}=".to_sym, v) rescue NoMethodError
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
protected
|
188
|
+
|
189
|
+
def packets
|
190
|
+
@packets ||= {}
|
193
191
|
end
|
194
192
|
|
195
193
|
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.5
|
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
|