dhcpsapi 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/dhcpsapi/client.rb +106 -0
- data/lib/dhcpsapi/common.rb +2 -0
- data/lib/dhcpsapi/option.rb +55 -0
- data/lib/dhcpsapi/option_value.rb +6 -6
- data/lib/dhcpsapi/reservation.rb +40 -0
- data/lib/dhcpsapi/subnet.rb +68 -1
- data/lib/dhcpsapi/version.rb +1 -1
- data/lib/dhcpsapi/win2008/client.rb +1 -1
- data/lib/dhcpsapi/win2008/option_value.rb +2 -2
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bfc31397c8a1374d67bfd616b56d0a3574db087
|
4
|
+
data.tar.gz: 9baad924ef537c688417295c4abeefad2b81a29b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ceaedfc38b2ea86a5ce57ada4c3c3766af5cb71625f826a9db780e22f60c6ee8e01601d00ae6c63d740d152ff740c599ef9bfa952876a7c1e9e64b5b9922e7ec
|
7
|
+
data.tar.gz: 1e4b3978ab731608d82e7b976f9cc80df5db020f9f08e7aca3630a2f3db5599e2bd5bc98b64a34afc279e024504673cbcfad6ea48fa32dd96cd833387ddbec6d
|
data/README.md
CHANGED
data/lib/dhcpsapi/client.rb
CHANGED
@@ -35,6 +35,25 @@ module DhcpsApi
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# TODO: parse lease time and owner_host
|
38
|
+
# creates a new subnet client.
|
39
|
+
#
|
40
|
+
# @example create a new client
|
41
|
+
#
|
42
|
+
# api.create_client('192.168.42.42', '255.255.255.0', '00:01:02:03:04:05', 'test-client', 'test client comment', 0)
|
43
|
+
#
|
44
|
+
# @param client_ip_address [String] Client ip address
|
45
|
+
# @param client_subnet_mask [String] Client subnet mask
|
46
|
+
# @param client_mac_address [String] Client hardware address
|
47
|
+
# @param client_name [String] Client name
|
48
|
+
# @param client_comment [String] Client comment
|
49
|
+
# @param lease_expires [Date] Client lease expiration date and time
|
50
|
+
# @param client_type [ClientType] Client type
|
51
|
+
#
|
52
|
+
# @return [Hash]
|
53
|
+
#
|
54
|
+
# @see DHCP_CLIENT_INFO_V4 DHCP_CLIENT_INFO_V4 documentation for the list of available fields.
|
55
|
+
# @see ClientType ClientType documentation for the list of available client types.
|
56
|
+
#
|
38
57
|
def create_client(client_ip_address, client_subnet_mask, client_mac_address,
|
39
58
|
client_name, client_comment, lease_expires, client_type = DhcpsApi::ClientType::CLIENT_TYPE_BOTH)
|
40
59
|
to_create = DhcpsApi::DHCP_CLIENT_INFO_V4.new
|
@@ -56,6 +75,25 @@ module DhcpsApi
|
|
56
75
|
end
|
57
76
|
|
58
77
|
# TODO: parse lease time and owner_host
|
78
|
+
# Modifies an existing subnet client.
|
79
|
+
#
|
80
|
+
# @example modify a client
|
81
|
+
#
|
82
|
+
# api.modify_client('192.168.42.42', '255.255.255.0', '00:01:02:03:04:05', 'test-client', 'test client comment', 0)
|
83
|
+
#
|
84
|
+
# @param client_ip_address [String] Client ip address
|
85
|
+
# @param client_subnet_mask [String] Client subnet mask
|
86
|
+
# @param client_mac_address [String] Client hardware address
|
87
|
+
# @param client_name [String] Client name
|
88
|
+
# @param client_comment [String] Client comment
|
89
|
+
# @param lease_expires [Date] Client lease expiration date and time
|
90
|
+
# @param client_type [ClientType] Client type
|
91
|
+
#
|
92
|
+
# @return [Hash]
|
93
|
+
#
|
94
|
+
# @see DHCP_CLIENT_INFO_V4 DHCP_CLIENT_INFO_V4 documentation for the list of available fields.
|
95
|
+
# @see ClientType ClientType documentation for the list of available client types.
|
96
|
+
#
|
59
97
|
def modify_client(client_ip_address, client_subnet_mask, client_mac_address,
|
60
98
|
client_name, client_comment, lease_expires, client_type = DhcpsApi::ClientType::CLIENT_TYPE_BOTH)
|
61
99
|
to_modify = DhcpsApi::DHCP_CLIENT_INFO_V4.new
|
@@ -80,6 +118,19 @@ module DhcpsApi
|
|
80
118
|
uint32_to_ip(ip_to_uint32(client[:client_ip_address]) & ip_to_uint32(client[:subnet_mask]))
|
81
119
|
end
|
82
120
|
|
121
|
+
# Retrieves subnet client using client mac address.
|
122
|
+
#
|
123
|
+
# @example retrieve a client
|
124
|
+
#
|
125
|
+
# api.get_client_by_mac_address('192.168.42.0', '00:01:02:03:04:05')
|
126
|
+
#
|
127
|
+
# @param subnet_address [String] Subnet address
|
128
|
+
# @param client_mac_address [String] Client hardware address
|
129
|
+
#
|
130
|
+
# @return [Hash]
|
131
|
+
#
|
132
|
+
# @see DHCP_CLIENT_INFO_V4 DHCP_CLIENT_INFO_V4 documentation for the list of available fields.
|
133
|
+
#
|
83
134
|
def get_client_by_mac_address(subnet_address, client_mac_address)
|
84
135
|
search_info = DhcpsApi::DHCP_SEARCH_INFO.new
|
85
136
|
search_info[:search_type] = DhcpsApi::DHCP_SEARCH_INFO_TYPE::DhcpClientHardwareAddress
|
@@ -88,6 +139,18 @@ module DhcpsApi
|
|
88
139
|
get_client(search_info, client_mac_address)
|
89
140
|
end
|
90
141
|
|
142
|
+
# Retrieves subnet client using client ip address.
|
143
|
+
#
|
144
|
+
# @example retrieve a client
|
145
|
+
#
|
146
|
+
# api.get_client_by_ip_address('192.168.42.42')
|
147
|
+
#
|
148
|
+
# @param client_ip_address [String] Client ip address
|
149
|
+
#
|
150
|
+
# @return [Hash]
|
151
|
+
#
|
152
|
+
# @see DHCP_CLIENT_INFO_V4 DHCP_CLIENT_INFO_V4 documentation for the list of available fields.
|
153
|
+
#
|
91
154
|
def get_client_by_ip_address(client_ip_address)
|
92
155
|
search_info = DhcpsApi::DHCP_SEARCH_INFO.new
|
93
156
|
search_info[:search_type] = DhcpsApi::DHCP_SEARCH_INFO_TYPE::DhcpClientIpAddress
|
@@ -96,6 +159,18 @@ module DhcpsApi
|
|
96
159
|
get_client(search_info, client_ip_address)
|
97
160
|
end
|
98
161
|
|
162
|
+
# Retrieves subnet client using client name.
|
163
|
+
#
|
164
|
+
# @example retrieve a client
|
165
|
+
#
|
166
|
+
# api.get_client_by_name('test-client')
|
167
|
+
#
|
168
|
+
# @param client_name [String] Client name
|
169
|
+
#
|
170
|
+
# @return [Hash]
|
171
|
+
#
|
172
|
+
# @see DHCP_CLIENT_INFO_V4 DHCP_CLIENT_INFO_V4 documentation for the list of available fields.
|
173
|
+
#
|
99
174
|
def get_client_by_name(client_name)
|
100
175
|
search_info = DhcpsApi::DHCP_SEARCH_INFO.new
|
101
176
|
search_info[:search_type] = DhcpsApi::DHCP_SEARCH_INFO_TYPE::DhcpClientName
|
@@ -104,6 +179,17 @@ module DhcpsApi
|
|
104
179
|
get_client(search_info, client_name)
|
105
180
|
end
|
106
181
|
|
182
|
+
# Deletes subnet client using client mac address.
|
183
|
+
#
|
184
|
+
# @example delete a client
|
185
|
+
#
|
186
|
+
# api.delete_client_by_mac_address('192.168.42.0', '00:01:02:03:04:05')
|
187
|
+
#
|
188
|
+
# @param subnet_address [String] Subnet address
|
189
|
+
# @param client_mac_address [String] Client hardware address
|
190
|
+
#
|
191
|
+
# @return [void]
|
192
|
+
#
|
107
193
|
def delete_client_by_mac_address(subnet_address, client_mac_address)
|
108
194
|
search_info = DhcpsApi::DHCP_SEARCH_INFO.new
|
109
195
|
search_info[:search_type] = DhcpsApi::DHCP_SEARCH_INFO_TYPE::DhcpClientHardwareAddress
|
@@ -113,6 +199,16 @@ module DhcpsApi
|
|
113
199
|
raise DhcpsApi::Error.new("Error deleting client.", error) if error != 0
|
114
200
|
end
|
115
201
|
|
202
|
+
# Deletes subnet client using client ip address.
|
203
|
+
#
|
204
|
+
# @example delete a client
|
205
|
+
#
|
206
|
+
# api.delete_client_by_ip_address('192.168.42.42')
|
207
|
+
#
|
208
|
+
# @param client_ip_address [String] Client ip address
|
209
|
+
#
|
210
|
+
# @return [void]
|
211
|
+
#
|
116
212
|
def delete_client_by_ip_address(client_ip_address)
|
117
213
|
search_info = DhcpsApi::DHCP_SEARCH_INFO.new
|
118
214
|
search_info[:search_type] = DhcpsApi::DHCP_SEARCH_INFO_TYPE::DhcpClientIpAddress
|
@@ -122,6 +218,16 @@ module DhcpsApi
|
|
122
218
|
raise DhcpsApi::Error.new("Error deleting client.", error) if error != 0
|
123
219
|
end
|
124
220
|
|
221
|
+
# Deletes subnet client using client name.
|
222
|
+
#
|
223
|
+
# @example delete a client
|
224
|
+
#
|
225
|
+
# api.delete_client_by_name('test-client')
|
226
|
+
#
|
227
|
+
# @param client_name [String] Client name
|
228
|
+
#
|
229
|
+
# @return [void]
|
230
|
+
#
|
125
231
|
def delete_client_by_name(client_name)
|
126
232
|
search_info = DhcpsApi::DHCP_SEARCH_INFO.new
|
127
233
|
search_info[:search_type] = DhcpsApi::DHCP_SEARCH_INFO_TYPE::DhcpClientName
|
data/lib/dhcpsapi/common.rb
CHANGED
data/lib/dhcpsapi/option.rb
CHANGED
@@ -2,6 +2,25 @@ module DhcpsApi
|
|
2
2
|
module Option
|
3
3
|
include CommonMethods
|
4
4
|
|
5
|
+
# creates a new dhcp option.
|
6
|
+
#
|
7
|
+
# @example create a new multi-valued string option with default values
|
8
|
+
#
|
9
|
+
# api.create_option(201, 'test_option', 'test option comment', DhcpsApi::DHCP_OPTION_DATA_TYPE::DhcpStringDataOption, true, 'default value', 'another default value')
|
10
|
+
#
|
11
|
+
# @param option_id [Fixnum] Option id
|
12
|
+
# @param option_name [String] Option name
|
13
|
+
# @param option_comment [String] Option comment
|
14
|
+
# @param option_type [DhcpsApi::DHCP_OPTION_DATA_TYPE] Option type
|
15
|
+
# @param is_array [Boolean] Is the option single- or multi-valued
|
16
|
+
# @param vendor_name [String] Option vendor name, nil (default) for none
|
17
|
+
# @param default_values [] one or more default values
|
18
|
+
#
|
19
|
+
# @return [Hash]
|
20
|
+
#
|
21
|
+
# @see DHCP_OPTION DHCP_OPTION documentation for the list of available fields.
|
22
|
+
# @see DHCP_OPTION_DATA_TYPE DHCP_OPTION_DATA_TYPE documentation for the list of available option types.
|
23
|
+
#
|
5
24
|
def create_option(option_id, option_name, option_comment, option_type, is_array, vendor_name = nil, *default_values)
|
6
25
|
is_vendor = vendor_name.nil? ? 0 : DhcpsApi::DHCP_FLAGS_OPTION_IS_VENDOR
|
7
26
|
option_info = DhcpsApi::DHCP_OPTION.new
|
@@ -22,6 +41,19 @@ module DhcpsApi
|
|
22
41
|
option_info.as_ruby_struct
|
23
42
|
end
|
24
43
|
|
44
|
+
# retrieves a dhcp option.
|
45
|
+
#
|
46
|
+
# @example retrieve a dhcp option
|
47
|
+
#
|
48
|
+
# api.get_option(201, nil)
|
49
|
+
#
|
50
|
+
# @param option_id [Fixnum] Option id
|
51
|
+
# @param vendor_name [String] Option vendor name, nil (default) for none
|
52
|
+
#
|
53
|
+
# @return [Hash]
|
54
|
+
#
|
55
|
+
# @see DHCP_OPTION DHCP_OPTION documentation for the list of available fields.
|
56
|
+
#
|
25
57
|
def get_option(option_id, vendor_name = nil)
|
26
58
|
is_vendor = vendor_name.nil? ? 0 : DhcpsApi::DHCP_FLAGS_OPTION_IS_VENDOR
|
27
59
|
option_info_ptr_ptr = FFI::MemoryPointer.new(:pointer)
|
@@ -46,6 +78,17 @@ module DhcpsApi
|
|
46
78
|
to_return
|
47
79
|
end
|
48
80
|
|
81
|
+
# deletes a dhcp option.
|
82
|
+
#
|
83
|
+
# @example delete a dhcp option
|
84
|
+
#
|
85
|
+
# api.delete_option(201, nil)
|
86
|
+
#
|
87
|
+
# @param option_id [Fixnum] Option id
|
88
|
+
# @param vendor_name [String] Option vendor name, nil (default) for none
|
89
|
+
#
|
90
|
+
# @return [void]
|
91
|
+
#
|
49
92
|
def delete_option(option_id, vendor_name = nil)
|
50
93
|
error = DhcpsApi::Win2008::Option.DhcpRemoveOptionV5(to_wchar_string(server_ip_address),
|
51
94
|
vendor_name.nil? ? 0 : DhcpsApi::DHCP_FLAGS_OPTION_IS_VENDOR,
|
@@ -55,6 +98,18 @@ module DhcpsApi
|
|
55
98
|
raise DhcpsApi::Error.new("Error deleting option.", error) if error != 0
|
56
99
|
end
|
57
100
|
|
101
|
+
# lists available dhcp options.
|
102
|
+
#
|
103
|
+
# @example list dhcp options
|
104
|
+
#
|
105
|
+
# api.list_options(nil)
|
106
|
+
#
|
107
|
+
# @param vendor_name [String] Option vendor name, nil (default) for none
|
108
|
+
#
|
109
|
+
# @return [Array<Hash>]
|
110
|
+
#
|
111
|
+
# @see DHCP_OPTION DHCP_OPTION documentation for the list of available fields.
|
112
|
+
#
|
58
113
|
def list_options(class_name = nil, vendor_name = nil)
|
59
114
|
items, _ = retrieve_items(:dhcp_enum_options_v5, class_name, vendor_name, 1024, 0)
|
60
115
|
items
|
@@ -365,7 +365,7 @@ module DhcpsApi
|
|
365
365
|
is_vendor,
|
366
366
|
option_id,
|
367
367
|
nil,
|
368
|
-
vendor_name.nil? ? nil :
|
368
|
+
vendor_name.nil? ? nil : to_wchar_string(vendor_name),
|
369
369
|
scope_info.pointer,
|
370
370
|
option_data.pointer)
|
371
371
|
raise DhcpsApi::Error.new("Error setting option value.", error) if error != 0
|
@@ -379,8 +379,8 @@ module DhcpsApi
|
|
379
379
|
is_vendor,
|
380
380
|
option_id,
|
381
381
|
nil,
|
382
|
-
vendor_name.nil? ? nil :
|
383
|
-
scope_info,
|
382
|
+
vendor_name.nil? ? nil : to_wchar_string(vendor_name),
|
383
|
+
scope_info.pointer,
|
384
384
|
option_value_ptr_ptr)
|
385
385
|
|
386
386
|
if is_error?(error)
|
@@ -404,8 +404,8 @@ module DhcpsApi
|
|
404
404
|
is_vendor,
|
405
405
|
option_id,
|
406
406
|
nil,
|
407
|
-
vendor_name.nil? ? nil :
|
408
|
-
scope_info)
|
407
|
+
vendor_name.nil? ? nil : to_wchar_string(vendor_name),
|
408
|
+
scope_info.pointer)
|
409
409
|
|
410
410
|
raise DhcpsApi::Error.new("Error deleting option value.", error) if error != 0
|
411
411
|
end
|
@@ -420,7 +420,7 @@ module DhcpsApi
|
|
420
420
|
error = DhcpsApi::Win2008::OptionValue.DhcpEnumOptionValuesV5(to_wchar_string(server_ip_address),
|
421
421
|
is_vendor,
|
422
422
|
nil,
|
423
|
-
vendor_name.nil? ? nil :
|
423
|
+
vendor_name.nil? ? nil : to_wchar_string(vendor_name),
|
424
424
|
scope_info.pointer,
|
425
425
|
resume_handle_ptr,
|
426
426
|
preferred_maximum,
|
data/lib/dhcpsapi/reservation.rb
CHANGED
@@ -2,11 +2,39 @@ module DhcpsApi
|
|
2
2
|
module Reservation
|
3
3
|
include CommonMethods
|
4
4
|
|
5
|
+
# Lists subnet reservations.
|
6
|
+
#
|
7
|
+
# @example List subnet reservations
|
8
|
+
#
|
9
|
+
# api.list_reservations('192.168.42.0')
|
10
|
+
#
|
11
|
+
# @param reservation_ip [String] Reservation ip address
|
12
|
+
#
|
13
|
+
# @return [Array<Hash>]
|
14
|
+
#
|
15
|
+
# @see DHCP_IP_RESERVATION_INFO DHCP_IP_RESERVATION_INFO documentation for the list of available fields.
|
16
|
+
#
|
5
17
|
def list_reservations(subnet_address)
|
6
18
|
items, _ = retrieve_items(:dhcp_v4_enum_subnet_reservations, subnet_address, 1024, 0)
|
7
19
|
items
|
8
20
|
end
|
9
21
|
|
22
|
+
# Creates a new reservation.
|
23
|
+
#
|
24
|
+
# @example Create a new reservation
|
25
|
+
#
|
26
|
+
# api.create_reservation('192.168.42.100', '255.255.255.0', '00:01:02:03:04:05', 'test_reservation', 'test reservation comment')
|
27
|
+
#
|
28
|
+
# @param reservation_ip [String] Reservation ip address
|
29
|
+
# @param reservation_subnet_mask [String] Reservation subnet mask
|
30
|
+
# @param reservation_mac [String] Reservation mac address
|
31
|
+
# @param reservation_name [String] Reservation name
|
32
|
+
# @param reservation_comment [String] Reservation comment
|
33
|
+
#
|
34
|
+
# @return [Hash]
|
35
|
+
#
|
36
|
+
# @see DHCP_IP_RESERVATION_INFO DHCP_IP_RESERVATION_INFO documentation for the list of available fields.
|
37
|
+
#
|
10
38
|
def create_reservation(reservation_ip, reservation_subnet_mask, reservation_mac, reservation_name, reservation_comment = '')
|
11
39
|
subnet_element = DhcpsApi::DHCP_SUBNET_ELEMENT_DATA_V4.new
|
12
40
|
subnet_element[:element_type] = DhcpsApi::DHCP_SUBNET_ELEMENT_TYPE::DhcpReservedIps
|
@@ -28,6 +56,18 @@ module DhcpsApi
|
|
28
56
|
subnet_element.as_ruby_struct
|
29
57
|
end
|
30
58
|
|
59
|
+
# Deletes subnet reservations.
|
60
|
+
#
|
61
|
+
# @example Delete subnet reservations
|
62
|
+
#
|
63
|
+
# api.delete_reservations('192.168.42.42', '192.168.42.0', '00:01:02:03:04:05')
|
64
|
+
#
|
65
|
+
# @param reservation_ip [String] Reservation ip address
|
66
|
+
# @param subnet_address [String] Subnet ip address
|
67
|
+
# @param reservation_mac [String] Reservation mac address
|
68
|
+
#
|
69
|
+
# @return [void]
|
70
|
+
#
|
31
71
|
def delete_reservation(reservation_ip, subnet_address, reservation_mac)
|
32
72
|
to_delete = DhcpsApi::DHCP_SUBNET_ELEMENT_DATA_V4.new
|
33
73
|
to_delete[:element_type] = DhcpsApi::DHCP_SUBNET_ELEMENT_TYPE::DhcpReservedIps
|
data/lib/dhcpsapi/subnet.rb
CHANGED
@@ -2,15 +2,49 @@ module DhcpsApi
|
|
2
2
|
module Subnet
|
3
3
|
include CommonMethods
|
4
4
|
|
5
|
+
# Lists subnets.
|
6
|
+
#
|
7
|
+
# @example list available subnets
|
8
|
+
#
|
9
|
+
# api.list_subnets
|
10
|
+
#
|
11
|
+
# @return [Array<Hash>]
|
12
|
+
#
|
13
|
+
# @see DHCP_SUBNET_INFO DHCP_SUBNET_INFO documentation for the list of available fields.
|
5
14
|
def list_subnets
|
6
15
|
subnets = enum_subnets
|
7
16
|
subnets.map {|subnet| dhcp_get_subnet_info(subnet)}
|
8
17
|
end
|
9
18
|
|
19
|
+
# Retrieves subnet information.
|
20
|
+
#
|
21
|
+
# @example Retrieve a subnet
|
22
|
+
#
|
23
|
+
# api.get_subnet('192.168.42.0')
|
24
|
+
#
|
25
|
+
# @param subnet_address [String] Subnet ip address
|
26
|
+
#
|
27
|
+
# @return [Hash]
|
28
|
+
#
|
29
|
+
# @see DHCP_SUBNET_INFO DHCP_SUBNET_INFO documentation for the list of available fields.
|
10
30
|
def get_subnet(subnet_address)
|
11
31
|
dhcp_get_subnet_info(ip_to_uint32(subnet_address))
|
12
32
|
end
|
13
33
|
|
34
|
+
# Creates a new subnet.
|
35
|
+
#
|
36
|
+
# @example create a subnet
|
37
|
+
#
|
38
|
+
# api.create_subnet('192.168.42.0', '255.255.255.0', 'test-subnet', 'test subnet comment')
|
39
|
+
#
|
40
|
+
# @param subnet_address [String] Subnet ip address
|
41
|
+
# @param subnet_mask [String] Subnet ip address mask
|
42
|
+
# @param subnet_name [String] Subnet name
|
43
|
+
# @param subnet_comment [String] Subnet comment
|
44
|
+
#
|
45
|
+
# @return [Hash]
|
46
|
+
#
|
47
|
+
# @see DHCP_SUBNET_INFO DHCP_SUBNET_INFO documentation for the list of available fields.
|
14
48
|
def create_subnet(subnet_address, subnet_mask, subnet_name, subnet_comment)
|
15
49
|
subnet_info = DhcpsApi::DHCP_SUBNET_INFO.new
|
16
50
|
subnet_info[:subnet_address] = ip_to_uint32(subnet_address)
|
@@ -24,11 +58,31 @@ module DhcpsApi
|
|
24
58
|
subnet_info.as_ruby_struct
|
25
59
|
end
|
26
60
|
|
61
|
+
# Deletes subnet.
|
62
|
+
#
|
63
|
+
# @example Delete a subnet
|
64
|
+
#
|
65
|
+
# api.delete_subnet('192.168.42.0')
|
66
|
+
#
|
67
|
+
# @return [void]
|
27
68
|
def delete_subnet(subnet_address, force_flag = DhcpsApi::DHCP_FORCE_FLAG::DhcpNoForce)
|
28
69
|
error = DhcpsApi::Win2008::Subnet.DhcpDeleteSubnet(to_wchar_string(server_ip_address), ip_to_uint32(subnet_address), force_flag)
|
29
70
|
raise DhcpsApi::Error.new("Error deleting subnet.", error) if error != 0
|
30
71
|
end
|
31
72
|
|
73
|
+
# Creates a new subnet ip address range.
|
74
|
+
#
|
75
|
+
# @example create a subnet ip address range
|
76
|
+
#
|
77
|
+
# api.create_subnet_ip_range('192.168.42.0', '192.168.42.100', '192.168.42.150')
|
78
|
+
#
|
79
|
+
# @param subnet_address [String] Subnet ip address
|
80
|
+
# @param start_address [String] Range start ip address
|
81
|
+
# @param end_address [String] Range end ip address
|
82
|
+
#
|
83
|
+
# @return [Hash]
|
84
|
+
#
|
85
|
+
# @see DHCP_SUBNET_ELEMENT_DATA_V4 DHCP_SUBNET_ELEMENT_DATA_V4 documentation for the list of available fields.
|
32
86
|
def add_subnet_ip_range(subnet_address, start_address, end_address)
|
33
87
|
subnet_element = DhcpsApi::DHCP_SUBNET_ELEMENT_DATA_V4.new
|
34
88
|
subnet_element[:element_type] = DhcpsApi::DHCP_SUBNET_ELEMENT_TYPE::DhcpIpRanges
|
@@ -42,6 +96,17 @@ module DhcpsApi
|
|
42
96
|
subnet_element.as_ruby_struct
|
43
97
|
end
|
44
98
|
|
99
|
+
# Deletes a subnet ip address range.
|
100
|
+
#
|
101
|
+
# @example delete a subnet ip address range
|
102
|
+
#
|
103
|
+
# api.delete_subnet_ip_range('192.168.42.0', '192.168.42.100', '192.168.42.150')
|
104
|
+
#
|
105
|
+
# @param subnet_address [String] Subnet ip address
|
106
|
+
# @param start_address [String] Range start ip address
|
107
|
+
# @param end_address [String] Range end ip address
|
108
|
+
#
|
109
|
+
# @return [void]
|
45
110
|
def delete_subnet_ip_range(subnet_address, start_address, end_address)
|
46
111
|
to_delete = DhcpsApi::DHCP_SUBNET_ELEMENT_DATA_V4.new
|
47
112
|
to_delete[:element_type] = DhcpsApi::DHCP_SUBNET_ELEMENT_TYPE::DhcpIpRanges
|
@@ -57,12 +122,14 @@ module DhcpsApi
|
|
57
122
|
raise DhcpsApi::Error.new("Error deleting reservation.", error) if error != 0
|
58
123
|
end
|
59
124
|
|
125
|
+
private
|
126
|
+
|
60
127
|
def enum_subnets
|
61
128
|
items, _ = retrieve_items(:dhcp_enum_subnets, 1024, 0)
|
62
129
|
items
|
63
130
|
end
|
64
131
|
|
65
|
-
#
|
132
|
+
# expected subnet_address is DHCP_IP_ADDRESS
|
66
133
|
def dhcp_get_subnet_info(subnet_address)
|
67
134
|
subnet_info_ptr_ptr = FFI::MemoryPointer.new(:pointer)
|
68
135
|
|
data/lib/dhcpsapi/version.rb
CHANGED
@@ -40,7 +40,7 @@ module DhcpsApi::Win2008
|
|
40
40
|
_Out_ LPDHCP_CLIENT_INFO_V4 *ClientInfo
|
41
41
|
);
|
42
42
|
=end
|
43
|
-
attach_function :DhcpGetClientInfoV4, [:pointer,
|
43
|
+
attach_function :DhcpGetClientInfoV4, [:pointer, :pointer, :pointer], :uint32
|
44
44
|
|
45
45
|
|
46
46
|
=begin
|
@@ -31,7 +31,7 @@ module DhcpsApi::Win2008
|
|
31
31
|
_Out_ LPDHCP_OPTION_VALUE *OptionValue
|
32
32
|
);
|
33
33
|
=end
|
34
|
-
attach_function :DhcpGetOptionValueV5, [:pointer, :uint32, :uint32, :pointer, :pointer,
|
34
|
+
attach_function :DhcpGetOptionValueV5, [:pointer, :uint32, :uint32, :pointer, :pointer, :pointer, :pointer], :uint32
|
35
35
|
|
36
36
|
=begin
|
37
37
|
DWORD DhcpRemoveOptionValueV5(
|
@@ -43,7 +43,7 @@ module DhcpsApi::Win2008
|
|
43
43
|
_In_ DHCP_CONST DHCP_OPTION_SCOPE_INFO ScopeInfo
|
44
44
|
);
|
45
45
|
=end
|
46
|
-
attach_function :DhcpRemoveOptionValueV5, [:pointer, :uint32, :uint32, :pointer, :pointer,
|
46
|
+
attach_function :DhcpRemoveOptionValueV5, [:pointer, :uint32, :uint32, :pointer, :pointer, :pointer], :uint32
|
47
47
|
|
48
48
|
=begin
|
49
49
|
DWORD DhcpSetOptionValueV5(
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dhcpsapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitri Dolguikh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Ruby wrappers for MS DHCP api
|
@@ -109,17 +109,17 @@ require_paths:
|
|
109
109
|
- lib
|
110
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - '>='
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - '>='
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.4.8
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Ruby wrappers for MS DHCP api
|