dhcpsapi 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c3c32df74a4738ccc05219df765b858b30fe368
4
- data.tar.gz: 6fc6ed7910bdf75877407802c338730db698b935
3
+ metadata.gz: 3287715b0d2e3c50cf1be8df79f06db118c13d6e
4
+ data.tar.gz: 14fc8fe2e68f3a0ec64a43568d3d8e454a25f6ea
5
5
  SHA512:
6
- metadata.gz: 18ebca5b25059504047da371e6cdaa32f954522fe890a5e139ef5db49982c47f9820097d8ceebbcaeff1a273240cbbe2a01eddbe344e9c53953e39bb5ec6c3e1
7
- data.tar.gz: beb3fd6c5930c53378af0954e27bc08b3f729c2ef6f42309c44b834a18645939bd7dc5cd7c37dc91cdd4916b88ae8291c4f3f31a469f13a8dd3e731a3e628082
6
+ metadata.gz: e8db883b8de7ace5b47217d15a4f28c019aad3b0bff3540f03547683c92a45ceb8a4fee30219a855f4d49735f34177e32ad0927044484a9afb39cc37b4567d5d
7
+ data.tar.gz: 184a8fae50cbce438dcf5bda28ce954e9bcf6dbf85e9e65b578aab82256f55e7d2dadef82af97bd2ae2f513d8cd719553506d5657d56cc6b9b605fa00189aea2
data/README.md CHANGED
@@ -33,7 +33,7 @@ Running integration tests requires a locally available MS DHCP server. These tes
33
33
 
34
34
  This software is licensed under the Apache 2 license, quoted below.
35
35
 
36
- Copyright (c) 2016 Dmitri Dolguikh <dmitri@appliedlogic.ca>
36
+ Copyright (c) 2016 Dmitri Dolguikh <dmitri at appliedlogic dot ca>
37
37
 
38
38
  Licensed under the Apache License, Version 2.0 (the "License");
39
39
  you may not use this file except in compliance with the License.
@@ -102,6 +102,7 @@ module DhcpsApi
102
102
  #
103
103
  # @return [Hash]
104
104
  #
105
+ # @see DHCP_CLASS_INFO DHCP_CLASS_INFO documentation for the list of available fields.
105
106
  def create_class(class_name, comment, is_vendor, data)
106
107
  to_create = DhcpsApi::DHCP_CLASS_INFO.new
107
108
  to_create[:class_name] = FFI::MemoryPointer.from_string(to_wchar_string(class_name))
@@ -1,15 +1,24 @@
1
1
  module DhcpsApi
2
- =begin
3
- typedef struct _DHCP_RESERVED_SCOPE {
4
- DHCP_IP_ADDRESS ReservedIpAddress;
5
- DHCP_IP_ADDRESS ReservedIpSubnetAddress;
6
- } DHCP_RESERVED_SCOPE, *LPDHCP_RESERVED_SCOPE;
7
- =end
2
+ #
3
+ # DHCP_RESERVED_SCOPE data structure describes an reserved DHCP scope.
4
+ #
5
+ # Available fields:
6
+ # :reserved_ip_address [String],
7
+ # :reserved_ip_subnet_address [String]
8
+ #
9
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/aa363369(v=vs.85).aspx
10
+ #
8
11
  class DHCP_RESERVED_SCOPE < DHCPS_Struct
9
12
  layout :reserved_ip_address, :uint32,
10
13
  :reserved_ip_subnet_address, :uint32
11
14
  end
12
15
 
16
+
17
+ #
18
+ # DHCP_OPTION_SCOPE_TYPE enumeration defines the set of possible DHCP option scopes.
19
+ #
20
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/aa363363(v=vs.85).aspx
21
+ #
13
22
  class DHCP_OPTION_SCOPE_TYPE
14
23
  # The DHCP options correspond to the default scope.
15
24
  DhcpDefaultOptions = 0
@@ -23,18 +32,18 @@ module DhcpsApi
23
32
  DhcpMScopeOptions = 4
24
33
  end
25
34
 
26
- =begin
27
- typedef struct _DHCP_OPTION_SCOPE_INFO {
28
- DHCP_OPTION_SCOPE_TYPE ScopeType;
29
- union {
30
- DHCP_IP_ADDRESS SubnetScopeInfo;
31
- DHCP_RESERVED_SCOPE ReservedScopeInfo;
32
- LPWSTR MScopeInfo;
33
- PVOID DefaultScopeInfo;
34
- PVOID GlobalScopeInfo; //Pointer to a DHCP_OPTION_ARRAY structure that contains the global DHCP server options.
35
- } ScopeInfo;
36
- } DHCP_OPTION_SCOPE_INFO, *LPDHCP_OPTION_SCOPE_INFO;
37
- =end
35
+ #
36
+ # DHCP_RESERVED_SCOPE_UNION describes a DHCP scope.
37
+ #
38
+ # Available fields:
39
+ # :subnet_scope_info [String],
40
+ # :reserved_scope_info [DHCP_RESERVED_SCOPE],
41
+ # :m_scope_info [String],
42
+ # :default_scope_info, unused
43
+ # :global_scope_info
44
+ #
45
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/aa363361(v=vs.85).aspx
46
+ #
38
47
  class DHCP_OPTION_SCOPE_INFO_UNION < FFI::Union
39
48
  layout :subnet_scope_info, :uint32,
40
49
  :reserved_scope_info, DHCP_RESERVED_SCOPE,
@@ -43,6 +52,15 @@ module DhcpsApi
43
52
  :global_scope_info, :pointer
44
53
  end
45
54
 
55
+ #
56
+ # DHCP_OPTION_SCOPE_INFO defines information about the options provided for a certain DHCP scope.
57
+ #
58
+ # Available fields:
59
+ # :scope_type [Fixnum], see DHCP_OPTION_SCOPE_TYPE
60
+ # :scope_info [DHCP_OPTION_SCOPE_INFO_UNION],
61
+ #
62
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/aa363361(v=vs.85).aspx
63
+ #
46
64
  class DHCP_OPTION_SCOPE_INFO < DHCPS_Struct
47
65
  layout :scope_type, :uint32,
48
66
  :scope_info, DHCP_OPTION_SCOPE_INFO_UNION
@@ -82,23 +100,29 @@ module DhcpsApi
82
100
  end
83
101
  end
84
102
 
85
- =begin
86
- typedef struct _DHCP_OPTION_VALUE {
87
- DHCP_OPTION_ID OptionID;
88
- DHCP_OPTION_DATA Value;
89
- } DHCP_OPTION_VALUE, *LPDHCP_OPTION_VALUE;
90
- =end
103
+ #
104
+ # DHCP_OPTION_VALUE defines a DHCP option value.
105
+ #
106
+ # Available fields:
107
+ # :option_id [Fixnum], Option id
108
+ # :value [DHCP_OPTION_DATA], option value
109
+ #
110
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/aa363367(v=vs.85).aspx
111
+ #
91
112
  class DHCP_OPTION_VALUE < DHCPS_Struct
92
113
  layout :option_id, :uint32,
93
114
  :value, DHCP_OPTION_DATA
94
115
  end
95
116
 
96
- =begin
97
- typedef struct _DHCP_OPTION_VALUE_ARRAY {
98
- DWORD NumElements;
99
- LPDHCP_OPTION_VALUE Values;
100
- } DHCP_OPTION_VALUE_ARRAY, *LPDHCP_OPTION_VALUE_ARRAY;
101
- =end
117
+ #
118
+ # DHCP_OPTION_VALUE_ARRAY defines a list of DHCP option values.
119
+ #
120
+ # Available fields:
121
+ # :bum_elements [Fixnum], The number of option values in the list
122
+ # :values [Array<DHCP_OPTION_DATA>], Array of option values
123
+ #
124
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/bb891963(v=vs.85).aspx
125
+ #
102
126
  class DHCP_OPTION_VALUE_ARRAY < DHCPS_Struct
103
127
  layout :num_elements, :uint32,
104
128
  :values, :pointer
@@ -165,7 +189,22 @@ typedef struct _DHCP_OPTION_VALUE {
165
189
  attach_function :DhcpSetOptionValueV5, [:pointer, :uint32, :uint32, :pointer, :pointer, :pointer, :pointer], :uint32
166
190
 
167
191
  module OptionValue
168
- # see DHCP_OPTION_DATA_TYPE for option_type values
192
+ # Sets an option value for a subnet.
193
+ #
194
+ # @example Set a subnet option value
195
+ #
196
+ # api.set_subnet_option_value(3, '192.168.42.0', DhcpsApi::DHCP_OPTION_DATA_TYPE::DhcpIpAddressOption, ['192.168.42.1', '192.168.42.2'])
197
+ #
198
+ # @param option_id [Fixnum] Option id
199
+ # @param subnet_ip_address [String] Subnet ip address
200
+ # @param option_type [DHCP_OPTION_DATA_TYPE] Option type
201
+ # @param values [Array] Array of values (or an array of one element if option supports one value only)
202
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
203
+ #
204
+ # @return [void]
205
+ #
206
+ # @see DHCP_OPTION_DATA_TYPE DHCP_OPTION_DATA_TYPE documentation for the list of available option types.
207
+ #
169
208
  def set_subnet_option_value(option_id, subnet_ip_address, option_type, values, vendor_name = nil)
170
209
  dhcp_set_option_value_v5(
171
210
  option_id,
@@ -176,7 +215,23 @@ typedef struct _DHCP_OPTION_VALUE {
176
215
  )
177
216
  end
178
217
 
179
- # see DHCP_OPTION_DATA_TYPE for option_type values
218
+ # Sets an option value for a reservation.
219
+ #
220
+ # @example Set a reservation option value
221
+ #
222
+ # api.set_reservationt_option_value(3, '192.168.42.100', '192.168.42.0', DhcpsApi::DHCP_OPTION_DATA_TYPE::DhcpIpAddressOption, ['192.168.42.1', '192.168.42.2'])
223
+ #
224
+ # @param option_id [Fixnum] Option id
225
+ # @param subnet_ip_address [String] Reservation ip address
226
+ # @param subnet_ip_address [String] Subnet ip address
227
+ # @param option_type [DHCP_OPTION_DATA_TYPE] Option type
228
+ # @param values [Array] array of values (or an array of one element if option supports one value only)
229
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
230
+ #
231
+ # @return [void]
232
+ #
233
+ # @see DHCP_OPTION_DATA_TYPE DHCP_OPTION_DATA_TYPE documentation for the list of available option types.
234
+ #
180
235
  def set_reserved_option_value(option_id, reserved_ip_address, subnet_ip_address, option_type, values, vendor_name = nil)
181
236
  dhcp_set_option_value_v5(
182
237
  option_id,
@@ -187,7 +242,22 @@ typedef struct _DHCP_OPTION_VALUE {
187
242
  )
188
243
  end
189
244
 
190
- # see DHCP_OPTION_DATA_TYPE for option_type values
245
+ # Sets an option value for a multicast scope.
246
+ #
247
+ # @example Set a multicast scope option value
248
+ #
249
+ # api.set_multicast_option_value(26, '224.0.0.0', DhcpsApi::DHCP_OPTION_DATA_TYPE::DhcpWordOption, [1500])
250
+ #
251
+ # @param option_id [Fixnum] Option id
252
+ # @param multicast_scope_name [String] Multicast scope ip address
253
+ # @param option_type [DHCP_OPTION_DATA_TYPE] Option type
254
+ # @param values [Array] array of values (or an array of one element if option supports one value only)
255
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
256
+ #
257
+ # @return [void]
258
+ #
259
+ # @see DHCP_OPTION_DATA_TYPE DHCP_OPTION_DATA_TYPE documentation for the list of available option types.
260
+ #
191
261
  def set_multicast_option_value(option_id, multicast_scope_name, option_type, values, vendor_name = nil)
192
262
  dhcp_set_option_value_v5(
193
263
  option_id,
@@ -198,7 +268,21 @@ typedef struct _DHCP_OPTION_VALUE {
198
268
  )
199
269
  end
200
270
 
201
- # see DHCP_OPTION_DATA_TYPE for option_type values
271
+ # Sets an option value for a default scope.
272
+ #
273
+ # @example Set an option value
274
+ #
275
+ # api.set_option_value(26, DhcpsApi::DHCP_OPTION_DATA_TYPE::DhcpWordOption, [1500])
276
+ #
277
+ # @param option_id [Fixnum] Option id
278
+ # @param option_type [DHCP_OPTION_DATA_TYPE] Option type
279
+ # @param values [Array] array of values (or an array of one element if option supports one value only)
280
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
281
+ #
282
+ # @return [void]
283
+ #
284
+ # @see DHCP_OPTION_DATA_TYPE DHCP_OPTION_DATA_TYPE documentation for the list of available option types.
285
+ #
202
286
  def set_option_value(option_id, option_type, values, vendor_name = nil)
203
287
  dhcp_set_option_value_v5(
204
288
  option_id,
@@ -209,6 +293,20 @@ typedef struct _DHCP_OPTION_VALUE {
209
293
  )
210
294
  end
211
295
 
296
+ # Retrieves an option value for a subnet.
297
+ #
298
+ # @example Retrieve a subnet option value
299
+ #
300
+ # api.get_subnet_option_value(3, '192.168.42.0')
301
+ #
302
+ # @param option_id [Fixnum] Option id
303
+ # @param subnet_ip_address [String] Subnet ip address
304
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
305
+ #
306
+ # @return [Hash]
307
+ #
308
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
309
+ #
212
310
  def get_subnet_option_value(option_id, subnet_ip_address, vendor_name = nil)
213
311
  dhcp_get_option_value_v5(
214
312
  option_id,
@@ -217,6 +315,21 @@ typedef struct _DHCP_OPTION_VALUE {
217
315
  )
218
316
  end
219
317
 
318
+ # Retrieves an option value for a reservation.
319
+ #
320
+ # @example Retrieve a reservation option value
321
+ #
322
+ # api.get_reserved_option_value(3, '192.168.42.100', 192.168.42.0')
323
+ #
324
+ # @param option_id [Fixnum] Option id
325
+ # @param reserved_ip_address [String] Reservation ip address
326
+ # @param subnet_ip_address [String] Subnet ip address
327
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
328
+ #
329
+ # @return [Hash]
330
+ #
331
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
332
+ #
220
333
  def get_reserved_option_value(option_id, reserved_ip_address, subnet_ip_address, vendor_name = nil)
221
334
  dhcp_get_option_value_v5(
222
335
  option_id,
@@ -225,6 +338,21 @@ typedef struct _DHCP_OPTION_VALUE {
225
338
  )
226
339
  end
227
340
 
341
+
342
+ # Retrieves an option value for a multicast scope.
343
+ #
344
+ # @example Retrieve a multicast scope option value
345
+ #
346
+ # api.get_multicast_option_value(3, '224.0.0.0')
347
+ #
348
+ # @param option_id [Fixnum] Option id
349
+ # @param multicast_scope_name [String] Multicast scope ip address
350
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
351
+ #
352
+ # @return [Hash]
353
+ #
354
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
355
+ #
228
356
  def get_multicast_option_value(option_id, multicast_scope_name, vendor_name = nil)
229
357
  dhcp_get_option_value_v5(
230
358
  option_id,
@@ -233,6 +361,19 @@ typedef struct _DHCP_OPTION_VALUE {
233
361
  )
234
362
  end
235
363
 
364
+ # Retrieves an option value for a default scope.
365
+ #
366
+ # @example Retrieve an option value
367
+ #
368
+ # api.get_option_value(3)
369
+ #
370
+ # @param option_id [Fixnum] Option id
371
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
372
+ #
373
+ # @return [Hash]
374
+ #
375
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
376
+ #
236
377
  def get_option_value(option_id, vendor_name = nil)
237
378
  dhcp_get_option_value_v5(
238
379
  option_id,
@@ -241,6 +382,18 @@ typedef struct _DHCP_OPTION_VALUE {
241
382
  )
242
383
  end
243
384
 
385
+ # Removes an option value for a subnet.
386
+ #
387
+ # @example Remove a subnet option value
388
+ #
389
+ # api.remove_subnet_option_value(3, '192.168.42.0')
390
+ #
391
+ # @param option_id [Fixnum] Option id
392
+ # @param subnet_ip_address [String] Subnet ip address
393
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
394
+ #
395
+ # @return [void]
396
+ #
244
397
  def remove_subnet_option_value(option_id, subnet_ip_address, vendor_name = nil)
245
398
  dhcp_remove_option_value_v5(
246
399
  option_id,
@@ -249,6 +402,19 @@ typedef struct _DHCP_OPTION_VALUE {
249
402
  )
250
403
  end
251
404
 
405
+ # Removes an option value for a reservation.
406
+ #
407
+ # @example Remove a reservation option value
408
+ #
409
+ # api.remove_reserved_option_value(3, '192.168.42.100', 192.168.42.0')
410
+ #
411
+ # @param option_id [Fixnum] Option id
412
+ # @param reserved_ip_address [String] Reservation ip address
413
+ # @param subnet_ip_address [String] Subnet ip address
414
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
415
+ #
416
+ # @return [void]
417
+ #
252
418
  def remove_reserved_option_value(option_id, reserved_ip_address, subnet_ip_address, vendor_name = nil)
253
419
  dhcp_remove_option_value_v5(
254
420
  option_id,
@@ -257,6 +423,18 @@ typedef struct _DHCP_OPTION_VALUE {
257
423
  )
258
424
  end
259
425
 
426
+ # Removes an option value for a multicast scope.
427
+ #
428
+ # @example Remove a multicast scope option value
429
+ #
430
+ # api.remove_multicast_option_value(3, '224.0.0.0')
431
+ #
432
+ # @param option_id [Fixnum] Option id
433
+ # @param multicast_scope_name [String] Multicast scope ip address
434
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
435
+ #
436
+ # @return [void]
437
+ #
260
438
  def remove_multicast_option_value(option_id, multicast_scope_name, vendor_name = nil)
261
439
  dhcp_remove_option_value_v5(
262
440
  option_id,
@@ -265,6 +443,17 @@ typedef struct _DHCP_OPTION_VALUE {
265
443
  )
266
444
  end
267
445
 
446
+ # Removes a default scope option value.
447
+ #
448
+ # @example Remove a default scope option value
449
+ #
450
+ # api.remove_option_value(3)
451
+ #
452
+ # @param option_id [Fixnum] Option id
453
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
454
+ #
455
+ # @return [void]
456
+ #
268
457
  def remove_option_value(option_id, vendor_name = nil)
269
458
  dhcp_remove_option_value_v5(
270
459
  option_id,
@@ -273,6 +462,19 @@ typedef struct _DHCP_OPTION_VALUE {
273
462
  )
274
463
  end
275
464
 
465
+ # List option values for a subnet.
466
+ #
467
+ # @example Retrieve all subnet option values
468
+ #
469
+ # api.list_subnet_option_values('192.168.42.0')
470
+ #
471
+ # @param subnet_ip_address [String] Subnet ip address
472
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
473
+ #
474
+ # @return [Array<Hash>]
475
+ #
476
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
477
+ #
276
478
  def list_subnet_option_values(subnet_ip_address, vendor_name = nil)
277
479
  items, _ = retrieve_items(:dhcp_enum_option_values_v5,
278
480
  vendor_name,
@@ -281,6 +483,20 @@ typedef struct _DHCP_OPTION_VALUE {
281
483
  items
282
484
  end
283
485
 
486
+ # List option values for a reservation.
487
+ #
488
+ # @example Retrieve all option values for a reservation
489
+ #
490
+ # api.list_reserved_option_values('192.168.42.100', '192.168.42.0')
491
+ #
492
+ # @param reserved_ip_address [String] Reservation ip address
493
+ # @param subnet_ip_address [String] Subnet ip address
494
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
495
+ #
496
+ # @return [Array<Hash>]
497
+ #
498
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
499
+ #
284
500
  def list_reserved_option_values(reserved_ip_address, subnet_ip_address, vendor_name = nil)
285
501
  items, _ = retrieve_items(:dhcp_enum_option_values_v5,
286
502
  vendor_name,
@@ -289,6 +505,19 @@ typedef struct _DHCP_OPTION_VALUE {
289
505
  items
290
506
  end
291
507
 
508
+ # List option values for a multicast scope.
509
+ #
510
+ # @example Retrieve all option values for a multicast scope
511
+ #
512
+ # api.list_multicast_option_values('224.0.0.0')
513
+ #
514
+ # @param multicast_scope_name [String] Multicast scope ip address
515
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
516
+ #
517
+ # @return [Array<Hash>]
518
+ #
519
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
520
+ #
292
521
  def list_multicast_option_values(multicast_scope_name, vendor_name = nil)
293
522
  items, _ = retrieve_items(:dhcp_enum_option_values_v5,
294
523
  vendor_name,
@@ -297,6 +526,18 @@ typedef struct _DHCP_OPTION_VALUE {
297
526
  items
298
527
  end
299
528
 
529
+ # List option values for a default scope.
530
+ #
531
+ # @example Retrieve all option values for a default scope
532
+ #
533
+ # api.list_multicast_option_values
534
+ #
535
+ # @param vendor_name [String, nil] The name of the vendor class (for vendor options)
536
+ #
537
+ # @return [Array<Hash>]
538
+ #
539
+ # @see DHCP_OPTION_VALUE DHCP_OPTION_VALUE documentation for the list of available fields.
540
+ #
300
541
  def list_values(vendor_name = nil)
301
542
  items, _ = retrieve_items(:dhcp_enum_option_values_v5,
302
543
  vendor_name,
@@ -305,7 +546,7 @@ typedef struct _DHCP_OPTION_VALUE {
305
546
  items
306
547
  end
307
548
 
308
- # see DHCP_OPTION_DATA_TYPE for option_type values
549
+ private
309
550
  def dhcp_set_option_value_v5(option_id, vendor_name, scope_info, option_type, values)
310
551
  is_vendor = vendor_name.nil? ? 0 : DhcpsApi::DHCP_FLAGS_OPTION_IS_VENDOR
311
552
  option_data = DhcpsApi::DHCP_OPTION_DATA.from_array(option_type, values)
@@ -88,7 +88,7 @@ module DhcpsApi
88
88
  subnet_element.as_ruby_struct
89
89
  end
90
90
 
91
- def delete_reservation(subnet_address, reservation_ip, reservation_mac)
91
+ def delete_reservation(reservation_ip, subnet_address, reservation_mac)
92
92
  to_delete = DhcpsApi::DHCP_SUBNET_ELEMENT_DATA_V4.new
93
93
  to_delete[:element_type] = DhcpsApi::DHCP_SUBNET_ELEMENT_TYPE::DhcpReservedIps
94
94
  to_delete[:element][:reserved_ip] = (reserved_ip = DhcpsApi::DHCP_IP_RESERVATION_V4.new).pointer
@@ -105,6 +105,34 @@ module DhcpsApi
105
105
  raise DhcpsApi::Error.new("Error deleting reservation.", error) if error != 0
106
106
  end
107
107
 
108
+ # Sets dns configuration for a reservation.
109
+ #
110
+ # @example Enable dynamic dns updates when requested by DHCP client
111
+ #
112
+ # api.set_reservation_dns_config('192.168.42.100', '192.168.42.0', true, false, false, false, false)
113
+ #
114
+ # @param reservation_ip [String] Reservation ip address
115
+ # @param subnet_ip_address [String] Subnet ip address
116
+ # @param enable [Boolean] enable dynamic updates of DNS client information
117
+ # @param update [Boolean] always dynamically update DNS and PTR records
118
+ # @param lookup [Boolean] Discard A and PTR records when lease is deleted
119
+ # @param non_dyn [Boolean] Dynamically update DNS A and PTR records for DHCP clients that do not request updates
120
+ # @param disable_ddns_updates_for_ptr [Boolean] Disable dynamic updates for DNS PTR records
121
+ #
122
+ # @return [void]
123
+ #
124
+ # @see https://technet.microsoft.com/en-gb/library/bb490941.aspx, set dnsconfig section
125
+ #
126
+ def set_reservation_dns_config(reservation_ip, subnet_address, enable, update, lookup, non_dyn, disable_ddns_updates_for_ptr)
127
+ value = enable ? 1 : 0
128
+ value = value | 0x10 if update
129
+ value = value | 4 if lookup
130
+ value = value | 2 if non_dyn
131
+ value = value | 0x40 if disable_ddns_updates_for_ptr
132
+
133
+ set_reserved_option_value(81, reservation_ip, subnet_address, DhcpsApi::DHCP_OPTION_DATA_TYPE::DhcpDWordOption, [value])
134
+ end
135
+
108
136
  def dhcp_v4_enum_subnet_reservations(subnet_address, preferred_maximum, resume_handle)
109
137
  resume_handle_ptr = FFI::MemoryPointer.new(:uint32).put_uint32(0, resume_handle)
110
138
  enum_element_info_ptr_ptr = FFI::MemoryPointer.new(:pointer)
@@ -1,3 +1,3 @@
1
1
  module DhcpsApi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhcpsapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-07-26 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi