lib-dhcp 0.1.2 → 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.
- checksums.yaml +5 -5
- data/.gitignore +3 -1
- data/lib/lib/dhcp/messages/lease_query.rb +31 -1
- data/lib/lib/dhcp/options/option.rb +4 -2
- data/lib/lib/dhcp/options/option91.rb +38 -2
- data/lib/lib/dhcp/options/option92.rb +11 -3
- data/lib/lib/dhcp/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53121146f58779b496d7c7c9e77e958c63acc29c
|
4
|
+
data.tar.gz: 52f05fc29b2759d0436b4585d96c5c9c96bccc23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44aa6bc04389a95fd3ef79ca190bf6fa8bc383dc6dc8179792f7af91e3de0d8bf1c9be8744003323a8e227404f9e8d295b84aba9914dea57b1e4265ab8e0852c
|
7
|
+
data.tar.gz: '091386845addca0b7380db9aaed49921c23e9406ae77252f7e597ea719e05cc62addc15798b4beefc33ec27de8926831d8ee871e11dc19b86afe5ad60ae4f086'
|
data/.gitignore
CHANGED
@@ -34,6 +34,7 @@ module Lib
|
|
34
34
|
raise TypeError, "Can't convert #{options.class.name} to Lib::DHCP::Option"
|
35
35
|
end
|
36
36
|
self.options.add Lib::DHCP::Option53.new(LEASE_QUERY)
|
37
|
+
|
37
38
|
end
|
38
39
|
|
39
40
|
def pack
|
@@ -50,13 +51,42 @@ module Lib
|
|
50
51
|
res
|
51
52
|
end
|
52
53
|
|
54
|
+
def query_by_ip?
|
55
|
+
(ciaddr != 0) ? true : false
|
56
|
+
end
|
57
|
+
|
58
|
+
def query_by_mac?
|
59
|
+
(htype != 0 and hlen != 0 and chaddr != 0) ? true : false
|
60
|
+
end
|
61
|
+
|
62
|
+
def query_by_client_id?
|
63
|
+
option61.nil? ? false : true
|
64
|
+
end
|
65
|
+
|
53
66
|
protected :op=
|
54
67
|
# noinspection RubyResolve
|
55
68
|
protected :option53=
|
56
69
|
|
57
70
|
protected
|
58
71
|
def sanity_check
|
59
|
-
|
72
|
+
if query_by_ip?
|
73
|
+
raise Lib::DHCP::SanityCheck::LeaseQuery, 'The values of htype, hlen, and chaddr MUST be set to zero '+
|
74
|
+
'in the query by IP' unless self.htype == 0 and self.hlen == 0 and self.chaddr == 0
|
75
|
+
raise Lib::DHCP::SanityCheck::LeaseQuery, 'The Client-identifier option (option 61) MUST NOT appear in the ' +
|
76
|
+
'query by IP' unless self.option61.nil?
|
77
|
+
elsif query_by_mac?
|
78
|
+
raise Lib::DHCP::SanityCheck::LeaseQuery, 'The "ciaddr" field MUST be set to zero in the query ' +
|
79
|
+
'by MAC address' unless self.ciaddr == 0
|
80
|
+
raise Lib::DHCP::SanityCheck::LeaseQuery, 'The Client-identifier option (option 61) MUST NOT appear in the ' +
|
81
|
+
'query by MAC' if self.option61
|
82
|
+
elsif query_by_client_id?
|
83
|
+
raise Lib::DHCP::SanityCheck::LeaseQuery, 'The "ciaddr" field MUST be set to zero in the query ' +
|
84
|
+
'by Client identifier' unless self.ciaddr == 0
|
85
|
+
raise Lib::DHCP::SanityCheck::LeaseQuery, 'The values of htype, hlen, and chaddr MUST be set to zero in ' +
|
86
|
+
'the query by Client identifier' unless self.htype == 0 or self.hlen == 0 and self.chaddr != 0
|
87
|
+
else
|
88
|
+
raise Lib::DHCP::SanityCheck::LeaseQuery, 'Unknown query type'
|
89
|
+
end
|
60
90
|
end
|
61
91
|
end
|
62
92
|
end
|
@@ -140,6 +140,8 @@ module Lib
|
|
140
140
|
STREET_TALK_DIRECTORY_SERVER= 0x4c
|
141
141
|
USER_CLASS= 0x4d
|
142
142
|
RELAY_AGENT = 0x52
|
143
|
+
CLIENT_LAST_TRANSACTION_TIME= 0x5b
|
144
|
+
ASSOCIATED_IP = 0x5c
|
143
145
|
PRIVATE= 0xaf
|
144
146
|
END_OPTION = 0xff
|
145
147
|
|
@@ -235,8 +237,8 @@ module Lib
|
|
235
237
|
88 => 'BCMCS Controller Domain Name list',
|
236
238
|
89 => 'BCMCS Controller IPv4 address list.',
|
237
239
|
90 => 'Authentication',
|
238
|
-
91 => '
|
239
|
-
92 => '
|
240
|
+
91 => 'Client last transaction time',
|
241
|
+
92 => 'Associated IP',
|
240
242
|
93 => 'Client System Architecture Type',
|
241
243
|
119 => 'Domain Search',
|
242
244
|
121 => 'Classless Static Route Option',
|
@@ -10,8 +10,44 @@ require_relative 'type/raw'
|
|
10
10
|
module Lib
|
11
11
|
module DHCP
|
12
12
|
class Option91 < Option
|
13
|
-
#
|
14
|
-
|
13
|
+
# This option allows the receiver to determine the time of the
|
14
|
+
# most recent access of the client. It is particularly useful
|
15
|
+
# when DHCPLEASEACTIVE messages from two different DHCP servers
|
16
|
+
# need to be compared, although it can be useful in other
|
17
|
+
# situations. The value is a duration in seconds from the
|
18
|
+
# current time into the past when this IP address was most
|
19
|
+
# recently the subject of communication between the client and
|
20
|
+
# the DHCP server.
|
21
|
+
# The code for the this option is 91. The length of the this option is 4 octets.
|
22
|
+
|
23
|
+
def_delegators :@payload, :to_s
|
24
|
+
|
25
|
+
def initialize(time)
|
26
|
+
super CLIENT_LAST_TRANSACTION_TIME, time.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def payload=(time)
|
30
|
+
@payload = time.to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
def pack
|
34
|
+
[@oid, 4, @payload].pack('C2N')
|
35
|
+
end
|
36
|
+
|
37
|
+
def len
|
38
|
+
4
|
39
|
+
end
|
40
|
+
|
41
|
+
alias_method :time, :payload
|
42
|
+
alias_method :time=, :payload=
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def self.unpack(oid, len, payload)
|
47
|
+
raise ArgumentError, "OID Mismatch for #{NAME[oid]} - #{oid}" unless oid.to_i == CLIENT_LAST_TRANSACTION_TIME
|
48
|
+
raise ArgumentError, "Wrong #{NAME[oid]} length - #{len}" unless len == 4
|
49
|
+
self.new payload.unpack('N').first.to_i
|
50
|
+
end
|
15
51
|
end
|
16
52
|
end
|
17
53
|
end
|
@@ -5,13 +5,21 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
require_relative 'option'
|
8
|
-
|
8
|
+
require 'lib/dhcp/options/type/ip_array'
|
9
9
|
|
10
10
|
module Lib
|
11
11
|
module DHCP
|
12
12
|
class Option92 < Option
|
13
|
-
|
14
|
-
|
13
|
+
|
14
|
+
# This option is used to return all of the IP addresses
|
15
|
+
# associated with the DHCP client specified in a particular DHCPLEASEQUERY message.
|
16
|
+
# The code for this option is 92. The minimum length for this option is 4 octets,
|
17
|
+
# and the length MUST always be a multiple of 4.
|
18
|
+
|
19
|
+
include Type::IPArray
|
20
|
+
|
21
|
+
alias_method :associated_ip, :payload
|
22
|
+
alias_method :associated_ip=, :payload=
|
15
23
|
end
|
16
24
|
end
|
17
25
|
end
|
data/lib/lib/dhcp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lib-dhcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Wojcieszonek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -402,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
402
402
|
version: '0'
|
403
403
|
requirements: []
|
404
404
|
rubyforge_project:
|
405
|
-
rubygems_version: 2.
|
405
|
+
rubygems_version: 2.6.14
|
406
406
|
signing_key:
|
407
407
|
specification_version: 4
|
408
408
|
summary: DHCP protocol library.
|