netaddr 1.5.0 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +9 -0
- data/changelog +18 -17
- data/lib/cidr.rb +17 -192
- data/lib/cidr_shortcuts.rb +1 -40
- data/lib/eui.rb +3 -64
- data/lib/ip_math.rb +0 -32
- data/lib/methods.rb +1 -67
- data/lib/netaddr.rb +6 -12
- data/lib/tree.rb +2 -107
- data/lib/validation_shortcuts.rb +0 -18
- data/license +13 -0
- data/{tests → test}/cidr_test.rb +2 -1
- data/{tests → test}/eui_test.rb +1 -1
- data/{tests → test}/methods_test.rb +4 -1
- data/{tests → test}/tree_test.rb +1 -1
- metadata +36 -42
- data/README +0 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fd69b081c04694ed2db113b810b07e19ba7f8c9ebe446bca31af3b9f73955777
|
4
|
+
data.tar.gz: 4510ea5730575cbc8f606de4edd21ef054ba661fb9b1b2aacbdfa6f872055ad5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 12f90e81555cb39d0b51cd10c108b185da1cc4fb48d684858b60e5ada9d3584bb74ec54904335e962a9f14bd194e5c27cee4ab0d017a00ee0a03c223a79d3894
|
7
|
+
data.tar.gz: 78efa87669e4f37defda27d375e57d2dde8cd356b9a9ceac19e0ade7ce080733ee48e766ca100d11c411e7cb87e0d2230c711a24a1db90d73292fff3b69cea18
|
data/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# netaddr
|
2
|
+
I originally created this package back in 2007 out of the need for a tool
|
3
|
+
which I could use to track an inventory of constantly changing IP subnets.
|
4
|
+
At the time, I was in the process of migrating away from Perl and towards Ruby
|
5
|
+
as my primary scripting language. I have since migrated away from using Ruby so
|
6
|
+
I have not made any major modifications to this code base since 2008 (aside from a
|
7
|
+
handful of bug fixes that others have pointed out).
|
8
|
+
|
9
|
+
Dustin Spinhirne
|
data/changelog
CHANGED
@@ -1,24 +1,27 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Version 1.5.2
|
2
|
+
Changes:
|
3
|
+
* bug fixes from: https://github.com/KirillSmirnov, https://github.com/rwhitworth, https://github.com/y13i
|
3
4
|
|
4
|
-
|
5
|
+
Version 1.5.1
|
6
|
+
Changes:
|
7
|
+
* fixed bug with NetAddr#merge (credit to Daniel Boughton)
|
8
|
+
|
9
|
+
|
10
|
+
Version 1.5.0
|
11
|
+
Changes:
|
5
12
|
* fixed bug with EUI48#to_eui64 (credit to Erik Kline)
|
6
13
|
* fixed bug with u/l bit toggle on EUI#link_local (credit to Erik Kline)
|
7
14
|
* added EUI#to_ipv6
|
8
15
|
* added NetAddr#supernets
|
9
16
|
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
===Changes
|
18
|
+
Version 1.4.0
|
19
|
+
Changes:
|
15
20
|
* Added additional options to NetAddr#sort
|
16
21
|
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
===New Features
|
23
|
+
Version 1.3.0
|
24
|
+
New Features:
|
22
25
|
* added CIDR#[]
|
23
26
|
* added CIDR#succ (CIDR objects may now be used as args for the standard Ruby Range class)
|
24
27
|
* added CIDR#allocate_rfc3531
|
@@ -28,14 +31,12 @@
|
|
28
31
|
* added EUI#to_i
|
29
32
|
* added EUI#to_s
|
30
33
|
|
31
|
-
|
34
|
+
Changes:
|
32
35
|
* deprecated 'packed' methods
|
33
36
|
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
===Changes
|
38
|
+
Version 1.2.0
|
39
|
+
Changes:
|
39
40
|
* CIDRv4#new and CIDRv6#new methods have been changed for the sake of speed improvements.
|
40
41
|
Please use the CIDR#create method instead.
|
41
42
|
* changes to CIDR#wildcard_mask
|
@@ -44,7 +45,7 @@
|
|
44
45
|
* bug fix and *vast* simplification of NetAddr.merge
|
45
46
|
|
46
47
|
|
47
|
-
|
48
|
+
New Features:
|
48
49
|
* speed improvements
|
49
50
|
* added CIDR#set_wildcard_mask
|
50
51
|
* added <=>, >, <, == methods to CIDR
|
data/lib/cidr.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
=begin rdoc
|
2
|
-
Copyleft (c) 2006 Dustin Spinhirne
|
3
|
-
|
4
|
-
Licensed under the same terms as Ruby, No Warranty is provided.
|
5
|
-
=end
|
6
|
-
|
7
1
|
module NetAddr
|
8
2
|
|
9
3
|
#=CIDR - Classless Inter-Domain Routing
|
@@ -41,9 +35,6 @@ class CIDR
|
|
41
35
|
|
42
36
|
private_class_method :new
|
43
37
|
|
44
|
-
#==============================================================================#
|
45
|
-
# attr_reader/attr_writer
|
46
|
-
#==============================================================================#
|
47
38
|
|
48
39
|
# IP version 4 or 6.
|
49
40
|
attr_reader :version
|
@@ -70,10 +61,6 @@ private_class_method :new
|
|
70
61
|
@tag = new_tag
|
71
62
|
end
|
72
63
|
|
73
|
-
#==============================================================================#
|
74
|
-
# create()
|
75
|
-
#==============================================================================#
|
76
|
-
|
77
64
|
#===Synopsis
|
78
65
|
#Create a new CIDRv4 or CIDRv6 object.
|
79
66
|
#CIDR formatted netmasks take precedence over extended formatted ones.
|
@@ -81,21 +68,15 @@ private_class_method :new
|
|
81
68
|
#:Mask takes precedence over netmask given within CIDR addresses.
|
82
69
|
#Version will be auto-detected if not specified.
|
83
70
|
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
# NetAddr::CIDR.create('192.168.5.0',
|
94
|
-
# :WildcardMask => ['255.248.255.0'])
|
95
|
-
# NetAddr::CIDR.create('fec0::/64')
|
96
|
-
# NetAddr::CIDR.create('fec0::/64',
|
97
|
-
# :Tag => {'interface' => 'g0/1'})
|
98
|
-
# NetAddr::CIDR.create('::ffff:192.168.1.1/96')
|
71
|
+
# NetAddr::CIDR.create('192.168.1.1/24')
|
72
|
+
# NetAddr::CIDR.create('192.168.1.1 255.255.255.0')
|
73
|
+
# NetAddr::CIDR.create(0x0a010001,:Mask => 0xffffff00:Version => 4)
|
74
|
+
# NetAddr::CIDR.create('192.168.1.1',:WildcardMask => ['0.7.0.255', true])
|
75
|
+
# NetAddr::CIDR.create('192.168.1.1',:WildcardMask => [0x000007ff, true]
|
76
|
+
# NetAddr::CIDR.create('192.168.5.0',:WildcardMask => ['255.248.255.0'])
|
77
|
+
# NetAddr::CIDR.create('fec0::/64')
|
78
|
+
# NetAddr::CIDR.create('fec0::/64',:Tag => {'interface' => 'g0/1'})
|
79
|
+
# NetAddr::CIDR.create('::ffff:192.168.1.1/96')
|
99
80
|
#
|
100
81
|
#===Arguments:
|
101
82
|
#* addr = CIDR address as a String, or an IP address as an Integer
|
@@ -221,10 +202,6 @@ private_class_method :new
|
|
221
202
|
return( NetAddr.cidr_build(version, ip, netmask, tag, wildcard_mask, wildcard_mask_bit_flipped) )
|
222
203
|
end
|
223
204
|
|
224
|
-
#==============================================================================#
|
225
|
-
# initialize()
|
226
|
-
#==============================================================================#
|
227
|
-
|
228
205
|
# This method performs absolutely no error checking, and is meant to be used only by
|
229
206
|
# other internal methods for the sake of the speedier creation of CIDR objects.
|
230
207
|
# Please consider using #create unless you know what you are doing with 100% certainty.
|
@@ -267,10 +244,6 @@ private_class_method :new
|
|
267
244
|
|
268
245
|
end
|
269
246
|
|
270
|
-
#==============================================================================#
|
271
|
-
# <()
|
272
|
-
#==============================================================================#
|
273
|
-
|
274
247
|
#===Synopsis
|
275
248
|
#Compare the sort order of the current CIDR with a provided CIDR and return true
|
276
249
|
#if current CIDR is less than provided CIDR.
|
@@ -307,10 +280,6 @@ private_class_method :new
|
|
307
280
|
return(lt)
|
308
281
|
end
|
309
282
|
|
310
|
-
#==============================================================================#
|
311
|
-
# <=>()
|
312
|
-
#==============================================================================#
|
313
|
-
|
314
283
|
#===Synopsis
|
315
284
|
#Compare the sort order of the current CIDR with a provided CIDR and return:
|
316
285
|
#* 1 if the current CIDR is greater than the provided CIDR
|
@@ -350,10 +319,6 @@ private_class_method :new
|
|
350
319
|
return(comparasin)
|
351
320
|
end
|
352
321
|
|
353
|
-
#==============================================================================#
|
354
|
-
# ==()
|
355
|
-
#==============================================================================#
|
356
|
-
|
357
322
|
#===Synopsis
|
358
323
|
#Compare the sort order of the current CIDR with a provided CIDR and return true
|
359
324
|
#if current CIDR is equal to the provided CIDR.
|
@@ -391,10 +356,6 @@ private_class_method :new
|
|
391
356
|
end
|
392
357
|
alias :eql? :==
|
393
358
|
|
394
|
-
#==============================================================================#
|
395
|
-
# >()
|
396
|
-
#==============================================================================#
|
397
|
-
|
398
359
|
#===Synopsis
|
399
360
|
#Compare the sort order of the current CIDR with a provided CIDR and return true
|
400
361
|
#if current CIDR is greater than provided CIDR.
|
@@ -431,10 +392,6 @@ private_class_method :new
|
|
431
392
|
return(gt)
|
432
393
|
end
|
433
394
|
|
434
|
-
#==============================================================================#
|
435
|
-
# []
|
436
|
-
#==============================================================================#
|
437
|
-
|
438
395
|
#===Synopsis
|
439
396
|
#Provide the IP at the given index of the CIDR.
|
440
397
|
#
|
@@ -463,10 +420,6 @@ private_class_method :new
|
|
463
420
|
return(addr)
|
464
421
|
end
|
465
422
|
|
466
|
-
#==============================================================================#
|
467
|
-
# allocate_rfc3531()
|
468
|
-
#==============================================================================#
|
469
|
-
|
470
423
|
#===Synopsis
|
471
424
|
#RFC 3531 describes a flexible method for IP subnet allocation from
|
472
425
|
#a larger parent network. Given the new netmask for subnet allocations from this CIDR,
|
@@ -564,10 +517,6 @@ private_class_method :new
|
|
564
517
|
return(cidr_list)
|
565
518
|
end
|
566
519
|
|
567
|
-
#==============================================================================#
|
568
|
-
# arpa()
|
569
|
-
#==============================================================================#
|
570
|
-
|
571
520
|
#===Synopsis
|
572
521
|
#Depending on the IP version of the current CIDR,
|
573
522
|
#return either an in-addr.arpa. or ip6.arpa. string. The netmask will be used
|
@@ -624,10 +573,6 @@ private_class_method :new
|
|
624
573
|
return(arpa)
|
625
574
|
end
|
626
575
|
|
627
|
-
#==============================================================================#
|
628
|
-
# bits()
|
629
|
-
#==============================================================================#
|
630
|
-
|
631
576
|
#===Synopsis
|
632
577
|
#Provide number of bits in Netmask.
|
633
578
|
# Example:
|
@@ -644,10 +589,6 @@ private_class_method :new
|
|
644
589
|
return(NetAddr.mask_to_bits(@netmask))
|
645
590
|
end
|
646
591
|
|
647
|
-
#==============================================================================#
|
648
|
-
# cmp()
|
649
|
-
#==============================================================================#
|
650
|
-
|
651
592
|
#===Synopsis
|
652
593
|
#Compare the current CIDR with a provided CIDR and return:
|
653
594
|
#* 1 if the current CIDR contains (is supernet of) the provided CIDR
|
@@ -689,10 +630,6 @@ private_class_method :new
|
|
689
630
|
return(comparasin)
|
690
631
|
end
|
691
632
|
|
692
|
-
#==============================================================================#
|
693
|
-
# contains?()
|
694
|
-
#==============================================================================#
|
695
|
-
|
696
633
|
#===Synopsis
|
697
634
|
#Determines if this CIDR contains (is supernet of)
|
698
635
|
#the provided CIDR address or NetAddr::CIDR object.
|
@@ -732,10 +669,6 @@ end
|
|
732
669
|
return(contains)
|
733
670
|
end
|
734
671
|
|
735
|
-
#==============================================================================#
|
736
|
-
# desc()
|
737
|
-
#==============================================================================#
|
738
|
-
|
739
672
|
#===Synopsis
|
740
673
|
#See to_s
|
741
674
|
#
|
@@ -743,10 +676,6 @@ end
|
|
743
676
|
to_s(options)
|
744
677
|
end
|
745
678
|
|
746
|
-
#==============================================================================#
|
747
|
-
# enumerate()
|
748
|
-
#==============================================================================#
|
749
|
-
|
750
679
|
#===Synopsis
|
751
680
|
#Provide all IP addresses contained within the IP space of this CIDR.
|
752
681
|
#
|
@@ -811,7 +740,7 @@ end
|
|
811
740
|
my_ip = my_ip + bitstep
|
812
741
|
change_mask = @hostmask | my_ip
|
813
742
|
if (limit)
|
814
|
-
limit = limit -1
|
743
|
+
limit = limit - 1
|
815
744
|
break if (limit == 0)
|
816
745
|
end
|
817
746
|
end
|
@@ -819,10 +748,6 @@ end
|
|
819
748
|
return(list)
|
820
749
|
end
|
821
750
|
|
822
|
-
#==============================================================================#
|
823
|
-
# fill_in()
|
824
|
-
#==============================================================================#
|
825
|
-
|
826
751
|
#===Synopsis
|
827
752
|
#Given a list of subnets of the current CIDR, return a new list with any
|
828
753
|
#holes (missing subnets) filled in.
|
@@ -898,10 +823,6 @@ end
|
|
898
823
|
end
|
899
824
|
end
|
900
825
|
|
901
|
-
#==============================================================================#
|
902
|
-
# ip()
|
903
|
-
#==============================================================================#
|
904
|
-
|
905
826
|
#===Synopsis
|
906
827
|
#Provide original IP address passed during initialization.
|
907
828
|
#
|
@@ -924,7 +845,7 @@ end
|
|
924
845
|
|
925
846
|
if (options)
|
926
847
|
if (!options.kind_of?(Hash))
|
927
|
-
raise
|
848
|
+
raise ArgumentError, "Expected Hash, but " +
|
928
849
|
"#{options.class} provided."
|
929
850
|
end
|
930
851
|
NetAddr.validate_args(options.keys,known_args)
|
@@ -949,10 +870,6 @@ end
|
|
949
870
|
return(ip)
|
950
871
|
end
|
951
872
|
|
952
|
-
#==============================================================================#
|
953
|
-
# is_contained?()
|
954
|
-
#==============================================================================#
|
955
|
-
|
956
873
|
#===Synopsis
|
957
874
|
#Determines if this CIDR is contained within (is subnet of)
|
958
875
|
#the provided CIDR address or NetAddr::CIDR object.
|
@@ -993,10 +910,6 @@ end
|
|
993
910
|
return(is_contained)
|
994
911
|
end
|
995
912
|
|
996
|
-
#==============================================================================#
|
997
|
-
# last()
|
998
|
-
#==============================================================================#
|
999
|
-
|
1000
913
|
#===Synopsis
|
1001
914
|
#Provide last IP address in this CIDR object.
|
1002
915
|
#
|
@@ -1019,7 +932,7 @@ end
|
|
1019
932
|
|
1020
933
|
if (options)
|
1021
934
|
if (!options.kind_of?(Hash))
|
1022
|
-
raise
|
935
|
+
raise ArgumentError, "Expected Hash, but " +
|
1023
936
|
"#{options.class} provided."
|
1024
937
|
end
|
1025
938
|
NetAddr.validate_args(options.keys,known_args)
|
@@ -1045,10 +958,6 @@ end
|
|
1045
958
|
return(ip)
|
1046
959
|
end
|
1047
960
|
|
1048
|
-
#==============================================================================#
|
1049
|
-
# matches?()
|
1050
|
-
#==============================================================================#
|
1051
|
-
|
1052
961
|
#===Synopsis
|
1053
962
|
#Given an IP address (or if a NetAddr::CIDR object, then the original IP of that object), determine
|
1054
963
|
#if it falls within the range of addresses resulting from the combination of the
|
@@ -1084,10 +993,6 @@ end
|
|
1084
993
|
return(false)
|
1085
994
|
end
|
1086
995
|
|
1087
|
-
#==============================================================================#
|
1088
|
-
# multicast_mac()
|
1089
|
-
#==============================================================================#
|
1090
|
-
|
1091
996
|
#===Synopsis
|
1092
997
|
#Assuming this CIDR is a valid multicast address (224.0.0.0/4 for IPv4
|
1093
998
|
#and ff00::/8 for IPv6), return its ethernet MAC address (EUI-48) mapping.
|
@@ -1143,10 +1048,6 @@ end
|
|
1143
1048
|
return(eui)
|
1144
1049
|
end
|
1145
1050
|
|
1146
|
-
#==============================================================================#
|
1147
|
-
# netmask()
|
1148
|
-
#==============================================================================#
|
1149
|
-
|
1150
1051
|
#===Synopsis
|
1151
1052
|
#Provide netmask in CIDR format (/yy).
|
1152
1053
|
#
|
@@ -1165,10 +1066,6 @@ end
|
|
1165
1066
|
return("/#{bits}")
|
1166
1067
|
end
|
1167
1068
|
|
1168
|
-
#==============================================================================#
|
1169
|
-
# network()
|
1170
|
-
#==============================================================================#
|
1171
|
-
|
1172
1069
|
#===Synopsis
|
1173
1070
|
#Provide base network address.
|
1174
1071
|
#
|
@@ -1191,7 +1088,7 @@ end
|
|
1191
1088
|
|
1192
1089
|
if (options)
|
1193
1090
|
if (!options.kind_of?(Hash))
|
1194
|
-
raise
|
1091
|
+
raise ArgumentError, "Expected Hash, but " +
|
1195
1092
|
"#{options.class} provided."
|
1196
1093
|
end
|
1197
1094
|
NetAddr.validate_args(options.keys,known_args)
|
@@ -1219,10 +1116,6 @@ end
|
|
1219
1116
|
alias :base :network
|
1220
1117
|
alias :first :network
|
1221
1118
|
|
1222
|
-
#==============================================================================#
|
1223
|
-
# next_ip()
|
1224
|
-
#==============================================================================#
|
1225
|
-
|
1226
1119
|
#===Synopsis
|
1227
1120
|
#Provide the next IP following the last available IP within this CIDR object.
|
1228
1121
|
#
|
@@ -1249,7 +1142,7 @@ end
|
|
1249
1142
|
|
1250
1143
|
if (options)
|
1251
1144
|
if (!options.kind_of?(Hash))
|
1252
|
-
raise
|
1145
|
+
raise ArgumentError, "Expected Hash, but " +
|
1253
1146
|
"#{options.class} provided."
|
1254
1147
|
end
|
1255
1148
|
NetAddr.validate_args(options.keys,known_args)
|
@@ -1284,10 +1177,6 @@ end
|
|
1284
1177
|
return(next_ip)
|
1285
1178
|
end
|
1286
1179
|
|
1287
|
-
#==============================================================================#
|
1288
|
-
# next_subnet()
|
1289
|
-
#==============================================================================#
|
1290
|
-
|
1291
1180
|
#===Synopsis
|
1292
1181
|
#Provide the next subnet following this CIDR object. The next subnet will
|
1293
1182
|
#be of the same size as the current CIDR object.
|
@@ -1315,7 +1204,7 @@ end
|
|
1315
1204
|
|
1316
1205
|
if (options)
|
1317
1206
|
if (!options.kind_of?(Hash))
|
1318
|
-
raise
|
1207
|
+
raise ArgumentError, "Expected Hash, but " +
|
1319
1208
|
"#{options.class} provided."
|
1320
1209
|
end
|
1321
1210
|
NetAddr.validate_args(options.keys,known_args)
|
@@ -1351,10 +1240,6 @@ end
|
|
1351
1240
|
return(next_sub)
|
1352
1241
|
end
|
1353
1242
|
|
1354
|
-
#==============================================================================#
|
1355
|
-
# nth()
|
1356
|
-
#==============================================================================#
|
1357
|
-
|
1358
1243
|
#===Synopsis
|
1359
1244
|
#Provide the nth IP within this object.
|
1360
1245
|
#
|
@@ -1413,10 +1298,6 @@ end
|
|
1413
1298
|
return(my_ip)
|
1414
1299
|
end
|
1415
1300
|
|
1416
|
-
#==============================================================================#
|
1417
|
-
# range()
|
1418
|
-
#==============================================================================#
|
1419
|
-
|
1420
1301
|
#===Synopsis
|
1421
1302
|
#Given a set of index numbers for this CIDR, return all IP addresses within the
|
1422
1303
|
#CIDR that are between them (inclusive). If an upper bound is not provided, then
|
@@ -1510,10 +1391,6 @@ end
|
|
1510
1391
|
return(list)
|
1511
1392
|
end
|
1512
1393
|
|
1513
|
-
#==============================================================================#
|
1514
|
-
# remainder()
|
1515
|
-
#==============================================================================#
|
1516
|
-
|
1517
1394
|
#===Synopsis
|
1518
1395
|
#Given a single subnet of the current CIDR, provide the remainder of
|
1519
1396
|
#the subnets. For example if the original CIDR is 192.168.0.0/24 and you
|
@@ -1608,10 +1485,6 @@ end
|
|
1608
1485
|
return(new_subnets)
|
1609
1486
|
end
|
1610
1487
|
|
1611
|
-
#==============================================================================#
|
1612
|
-
# resize()
|
1613
|
-
#==============================================================================#
|
1614
|
-
|
1615
1488
|
#===Synopsis
|
1616
1489
|
#Resize the CIDR by changing the size of the Netmask.
|
1617
1490
|
#Return the resulting CIDR as a new object.
|
@@ -1627,7 +1500,7 @@ end
|
|
1627
1500
|
#* NetAddr::CIDR object
|
1628
1501
|
#
|
1629
1502
|
def resize(bits)
|
1630
|
-
raise
|
1503
|
+
raise ArgumentError, "Integer or Hash expected, but " +
|
1631
1504
|
"#{bits.class} provided." if (!bits.kind_of?(Integer))
|
1632
1505
|
|
1633
1506
|
NetAddr.validate_ip_netmask(bits, :Version => @version)
|
@@ -1637,10 +1510,6 @@ end
|
|
1637
1510
|
return( NetAddr.cidr_build(@version, network, netmask) )
|
1638
1511
|
end
|
1639
1512
|
|
1640
|
-
#==============================================================================#
|
1641
|
-
# resize!()
|
1642
|
-
#==============================================================================#
|
1643
|
-
|
1644
1513
|
#===Synopsis
|
1645
1514
|
#Resize the current CIDR by changing the size of the Netmask. The original IP
|
1646
1515
|
#passed during initialization will be set to the base network address if
|
@@ -1657,7 +1526,7 @@ end
|
|
1657
1526
|
#* True
|
1658
1527
|
#
|
1659
1528
|
def resize!(bits)
|
1660
|
-
raise
|
1529
|
+
raise ArgumentError, "Integer or Hash expected, but " +
|
1661
1530
|
"#{bits.class} provided." if (!bits.kind_of?(Integer))
|
1662
1531
|
|
1663
1532
|
NetAddr.validate_ip_netmask(bits, :Version => @version)
|
@@ -1675,10 +1544,6 @@ end
|
|
1675
1544
|
return(true)
|
1676
1545
|
end
|
1677
1546
|
|
1678
|
-
#==============================================================================#
|
1679
|
-
# set_wildcard_mask()
|
1680
|
-
#==============================================================================#
|
1681
|
-
|
1682
1547
|
#===Synopsis
|
1683
1548
|
#Set the wildcard mask. Wildcard masks are typically used for matching
|
1684
1549
|
#entries in an access-list.
|
@@ -1714,10 +1579,6 @@ end
|
|
1714
1579
|
return(nil)
|
1715
1580
|
end
|
1716
1581
|
|
1717
|
-
#==============================================================================#
|
1718
|
-
# size()
|
1719
|
-
#==============================================================================#
|
1720
|
-
|
1721
1582
|
#===Synopsis
|
1722
1583
|
#Provide number of IP addresses within this CIDR.
|
1723
1584
|
#
|
@@ -1735,10 +1596,6 @@ end
|
|
1735
1596
|
return(@hostmask + 1)
|
1736
1597
|
end
|
1737
1598
|
|
1738
|
-
#==============================================================================#
|
1739
|
-
# subnet()
|
1740
|
-
#==============================================================================#
|
1741
|
-
|
1742
1599
|
#===Synopsis
|
1743
1600
|
#Create subnets for this CIDR. There are 2 ways to create subnets:
|
1744
1601
|
# * By providing the netmask (in bits) of the new subnets with :Bits.
|
@@ -1886,10 +1743,6 @@ end
|
|
1886
1743
|
return(new_subnets)
|
1887
1744
|
end
|
1888
1745
|
|
1889
|
-
#==============================================================================#
|
1890
|
-
# succ()
|
1891
|
-
#==============================================================================#
|
1892
|
-
|
1893
1746
|
#===Synopsis
|
1894
1747
|
#Provide the next subnet following this CIDR object. The next subnet will
|
1895
1748
|
#be of the same size as the current CIDR object.
|
@@ -1917,10 +1770,6 @@ end
|
|
1917
1770
|
return(next_sub)
|
1918
1771
|
end
|
1919
1772
|
|
1920
|
-
#==============================================================================#
|
1921
|
-
# to_i()
|
1922
|
-
#==============================================================================#
|
1923
|
-
|
1924
1773
|
#===Synopsis
|
1925
1774
|
#Convert the requested attribute of the CIDR to an Integer.
|
1926
1775
|
# Example:
|
@@ -1953,10 +1802,6 @@ end
|
|
1953
1802
|
end
|
1954
1803
|
end
|
1955
1804
|
|
1956
|
-
#==============================================================================#
|
1957
|
-
# to_s()
|
1958
|
-
#==============================================================================#
|
1959
|
-
|
1960
1805
|
#===Synopsis
|
1961
1806
|
#Returns network/netmask in CIDR format.
|
1962
1807
|
#
|
@@ -2006,10 +1851,6 @@ end
|
|
2006
1851
|
return("#{ip}/#{mask}")
|
2007
1852
|
end
|
2008
1853
|
|
2009
|
-
#==============================================================================#
|
2010
|
-
# wildcard_mask()
|
2011
|
-
#==============================================================================#
|
2012
|
-
|
2013
1854
|
#===Synopsis
|
2014
1855
|
#Return the wildcard mask.
|
2015
1856
|
#
|
@@ -2047,17 +1888,9 @@ class CIDRv4 < CIDR
|
|
2047
1888
|
|
2048
1889
|
public_class_method :new
|
2049
1890
|
|
2050
|
-
#==============================================================================#
|
2051
|
-
# broadcast()
|
2052
|
-
#==============================================================================#
|
2053
|
-
|
2054
1891
|
# Alias for last
|
2055
1892
|
alias :broadcast :last
|
2056
1893
|
|
2057
|
-
#==============================================================================#
|
2058
|
-
# hostmask_ext()
|
2059
|
-
#==============================================================================#
|
2060
|
-
|
2061
1894
|
#===Synopsis
|
2062
1895
|
#Provide IPv4 Hostmask in extended format (y.y.y.y).
|
2063
1896
|
#
|
@@ -2075,10 +1908,6 @@ class CIDRv4 < CIDR
|
|
2075
1908
|
return(NetAddr.ip_int_to_str(@hostmask, @version))
|
2076
1909
|
end
|
2077
1910
|
|
2078
|
-
#==============================================================================#
|
2079
|
-
# netmask_ext()
|
2080
|
-
#==============================================================================#
|
2081
|
-
|
2082
1911
|
#===Synopsis
|
2083
1912
|
#Provide IPv4 netmask in extended format (y.y.y.y).
|
2084
1913
|
#
|
@@ -2110,10 +1939,6 @@ end # end class CIDRv4
|
|
2110
1939
|
class CIDRv6 < CIDR
|
2111
1940
|
public_class_method :new
|
2112
1941
|
|
2113
|
-
#==============================================================================#
|
2114
|
-
# unique_local()
|
2115
|
-
#==============================================================================#
|
2116
|
-
|
2117
1942
|
#===Synopsis
|
2118
1943
|
#Generate an IPv6 Unique Local CIDR address based on the algorithm described
|
2119
1944
|
#in RFC 4193.
|