ipaddress 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fec38076134eaf8fe0a449f7e96d9be946d37b0f
4
+ data.tar.gz: 43c5c532b9d10c030e27a490eab789107a5c2680
5
+ SHA512:
6
+ metadata.gz: ffd4cc11627aa588ef044a35767addb3a9498221746727435561439729e04e51fe1b70a660ffbc1f79ed952fdcd46fec30c5e88ef79667e9d68099eb9953a8b6
7
+ data.tar.gz: b273220fcdc8584a5841e16841a68f0b271d183d0e40c96ac1160cdc23bcd868f7460c0e6c4c1d2e590e1aa3e4ad7fc046540b5610a517637df1268818d3a262
@@ -0,0 +1,18 @@
1
+ *.a
2
+ /.bundle/
3
+ *.bundle
4
+ /coverage/
5
+ /doc/
6
+ .DS_Store
7
+ /Gemfile.lock
8
+ ipaddr.html
9
+ mkmf.log
10
+ *.o
11
+ /pkg/
12
+ rdoc
13
+ server.rb
14
+ *.so
15
+ /spec/reports/
16
+ *.sw?
17
+ /tmp/
18
+ /_yardoc/
@@ -0,0 +1,5 @@
1
+ runtime: ruby21
2
+ doc: exec rake rdoc
3
+ build: |
4
+ rock clean
5
+ {{parent}}
@@ -1,5 +1,19 @@
1
+ == ipaddress 0.8.2
2
+
3
+ CHANGED:: merged bundler branch to cleanup gemspec and Rakefiles
4
+ FIXED:: IPAddress::IPv4.split handling (Issue #40)
5
+ NEW:: Added #[]= method to IPv4/6 classes to add octet writing support. (Issue #24)
6
+ NEW:: IPV4#multicast?
7
+ NEW:: IPV4#loopback?
8
+ NEW:: IPV4#to()
9
+
10
+ == ipaddress 0.8.1
11
+
12
+ CHANGED:: ipaddress now uses minitest for testing, all tests passing
13
+
1
14
  == ipaddress 0.8.0
2
15
 
16
+ CHANGED:: ipaddress now uses this[https://gist.github.com/cpetschnig/294476] regexp to validate IPv6 addresses. Thanks to Christoph Petschnig for his regexp and to Bronislav Robenek for fixing this.
3
17
  CHANGED:: Removed extension methods and extension directory to facilitate integration with the stdlib
4
18
  CHANGED:: Reworked IPv4#<=>, now intuitively sorts objects based on the prefix
5
19
  CHANGED:: IPv4#supernet now returns "0.0.0.0/0" if supernetting with a prefix less than 1
@@ -10,6 +24,7 @@ NEW:: IPv6#broadcast_u128
10
24
  NEW:: IPv6#each
11
25
  NEW:: IPv6#<=>
12
26
  NEW:: IPv4#split
27
+ NEW:: IP#ntoa
13
28
 
14
29
  == ipaddress 0.7.5
15
30
 
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2011 Marco Ceresa
1
+ Copyright (c) 2009-2015 Marco Ceresa
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,3 +1,7 @@
1
+ == <b>IPAddress 1.0 is currently under development and will be released soon! Stay tuned!</b>
2
+
3
+ ---
4
+
1
5
  = IPAddress
2
6
 
3
7
  IPAddress is a Ruby library designed to make the use of IPv4 and IPv6
@@ -17,7 +21,7 @@ examples of typical usage.
17
21
  * Ruby >= 1.8.7 (not tested with previous versions)
18
22
  * Ruby 1.9.2 or later is strongly recommended
19
23
 
20
- IPAddress 0.8.0 has been tested on:
24
+ IPAddress 0.8.2 has been tested on:
21
25
 
22
26
  * ruby-1.8.7-p334 [ i386 ]
23
27
  * ree-1.8.7-2011.03 [ i386 ]
@@ -25,6 +29,8 @@ IPAddress 0.8.0 has been tested on:
25
29
  * jruby-1.6.1 [ linux-i386-java ]
26
30
  * ruby-1.9.1-p431 [ i386 ]
27
31
  * ruby-1.9.2-p180 [ i386 ]
32
+ * ruby-2.0.0-p353 [ x86_64-darwin14.0.0 ]
33
+ * ruby-2.1.3-p242 [ x86_64-darwin14.0.0 ]
28
34
 
29
35
  If you want to collaborate feel
30
36
  free to send a small report to my email address, or
@@ -63,14 +69,14 @@ The latest documentation can be found online at
63
69
 
64
70
  == IPv4
65
71
 
66
- Class IPAddress::IPv4 is used to handle IPv4 type addresses. IPAddress
72
+ Class `IPAddress::IPv4` is used to handle IPv4 type addresses. IPAddress
67
73
  is similar to other IP Addresses libraries, like Ruby's own
68
74
  IPAddr. However it works slightly different, as we will see.
69
75
 
70
76
  === Create a new IPv4 address
71
77
 
72
78
  The usual way to express an IP Address is using its dotted decimal
73
- form, such as 172.16.10.1, and a prefix, such as 24, separated by a
79
+ form, such as `172.16.10.1`, and a prefix, such as `24`, separated by a
74
80
  slash.
75
81
 
76
82
  172.16.10.1/24
@@ -83,11 +89,11 @@ or, in a easier way, using the IPAddress parse method
83
89
 
84
90
  ip = IPAddress.parse "172.16.10.1/24"
85
91
 
86
- which accepts and parses any kind of IP (IPv4, IPV6 and
92
+ which accepts and parses any kind of IP (uint32, IPv4, IPV6 and
87
93
  IPv4 IPv6 Mapped addresses).
88
94
 
89
95
  If you like syntactic sugar, you can use the wrapper method
90
- IPAddress(), which is built around IPAddress::parse:
96
+ `IPAddress()`, which is built around `IPAddress::parse`:
91
97
 
92
98
  ip = IPAddress "172.16.10.1/24"
93
99
 
@@ -96,13 +102,13 @@ You can specify an IPv4 address in any of two ways:
96
102
  IPAddress "172.16.10.1/24"
97
103
  IPAddress "172.16.10.1/255.255.255.0"
98
104
 
99
- In this example, prefix /24 and netmask 255.255.255.0 are the same and
105
+ In this example, prefix `/24` and netmask `255.255.255.0` are the same and
100
106
  you have the flexibility to use either one of them.
101
107
 
102
108
  If you don't explicitly specify the prefix (or the subnet mask),
103
109
  IPAddress thinks you're dealing with host addresses and not with
104
- networks. Therefore, the default prefix will be /32, or
105
- 255.255.255.255. For example:
110
+ networks. Therefore, the default prefix will be `/32`, or
111
+ `255.255.255.255`. For example:
106
112
 
107
113
  # let's declare an host address
108
114
  host = IPAddress::IPv4.new "10.1.1.1"
@@ -110,11 +116,18 @@ networks. Therefore, the default prefix will be /32, or
110
116
  puts host.to_string
111
117
  #=> "10.1.1.1/32"
112
118
 
113
- The new created object has prefix /32, which is the same
119
+ The new created object has prefix `/32`, which is the same
114
120
  as we created the following:
115
121
 
116
122
  host = IPAddress::IPv4.new "10.1.1.1/32"
117
-
123
+
124
+ You can also pass a `uint32` to obtain an `IPAddress::IPv4` object:
125
+
126
+ # Create host object
127
+ ip = IPAddress 167837953
128
+ puts ip.to_string
129
+ #=> "10.1.1.1/32"
130
+
118
131
  === Handling the IPv4 address
119
132
 
120
133
  Once created, you can obtain the attributes for an IPv4 object:
@@ -127,25 +140,25 @@ Once created, you can obtain the attributes for an IPv4 object:
127
140
  #=> 24
128
141
 
129
142
  In case you need to retrieve the netmask in IPv4 format, you can use
130
- the IPv4#netmask method:
143
+ the `IPv4#netmask` method:
131
144
 
132
145
  ip.netmask
133
146
  #=> "255.255.255.0"
134
147
 
135
- A special attribute, IPv4#octets, is available to get the four
148
+ A special attribute, `IPv4#octets`, is available to get the four
136
149
  decimal octets from the IP address:
137
150
 
138
151
  ip.octets
139
152
  #=> [172,16,10,1]
140
153
 
141
- Shortcut method IPv4#[], provides access to a given octet whithin the
154
+ Shortcut method `IPv4#[]`, provides access to a given octet whithin the
142
155
  range:
143
156
 
144
157
  ip[1]
145
158
  #=> 16
146
159
 
147
160
  If you need to print out the IPv4 address in a canonical form, you can
148
- use IPv4#to_string
161
+ use `IPv4#to_string`:
149
162
 
150
163
  ip.to_string
151
164
  #=> "172.16.10.l/24"
@@ -161,7 +174,7 @@ object. For example:
161
174
  #=> "172.16.10.l/25"
162
175
 
163
176
  If you need to use a netmask in IPv4 format, you can achive so by
164
- using the IPv4#netmask= method
177
+ using the `IPv4#netmask=` method:
165
178
 
166
179
  ip.netmask = "255.255.255.252"
167
180
 
@@ -174,7 +187,7 @@ Some very important topics in dealing with IP addresses are the
174
187
  concepts of +network+ and +broadcast+, as well as the addresses
175
188
  included in a range.
176
189
 
177
- When you specify an IPv4 address such as "172.16.10.1/24", you are
190
+ When you specify an IPv4 address such as `172.16.10.1/24`, you are
178
191
  actually handling two different information:
179
192
 
180
193
  * The IP address itself, "172.16.10.1"
@@ -183,11 +196,11 @@ actually handling two different information:
183
196
  The network number is the IP which has all zeroes in the host
184
197
  portion. In our example, because the prefix is 24, we identify our
185
198
  network number to have the last 8 (32-24) bits all zeroes. Thus, IP
186
- address "172.16.10.1/24" belongs to network "172.16.10.0/24".
199
+ address `172.16.10.1/24` belongs to network `172.16.10.0/24`.
187
200
 
188
- This is very important because, for instance, IP "172.16.10.1/16" is
201
+ This is very important because, for instance, IP `172.16.10.1/16` is
189
202
  very different to the previous one, belonging to the very different
190
- network "172.16.0.0/16".
203
+ network `172.16.0.0/16`.
191
204
 
192
205
  ==== Networks
193
206
 
@@ -208,7 +221,7 @@ number, calculated after the original object. We want to outline here
208
221
  that the network address is a perfect legitimate IPv4 address, which
209
222
  just happen to have all zeroes in the host portion.
210
223
 
211
- You can use method IPv4#network? to check whether an IP address is a
224
+ You can use method `IPv4#network?` to check whether an IP address is a
212
225
  network or not:
213
226
 
214
227
  ip1 = IPAddress "172.16.10.1/24"
@@ -223,11 +236,11 @@ network or not:
223
236
 
224
237
  The broadcast address is the contrary than the network number: where
225
238
  the network number has all zeroes in the host portion, the broadcast
226
- address has all one's. For example, ip "172.16.10.1/24" has broadcast
227
- "172.16.10.255/24", where ip "172.16.10.1/16" has broadcast
228
- "172.16.255.255/16".
239
+ address has all one's. For example, ip `172.16.10.1/24` has broadcast
240
+ `172.16.10.255/24`, where ip `172.16.10.1/16` has broadcast
241
+ `172.16.255.255/16`.
229
242
 
230
- Method IPv4#broadcast has the same behavior as is #network
243
+ Method `IPv4#broadcast` has the same behavior as is `#network`
231
244
  counterpart: it creates a new IPv4 object to handle the broadcast
232
245
  address:
233
246
 
@@ -245,7 +258,7 @@ address:
245
258
  So we see that the netmask essentially specifies a range for IP
246
259
  addresses that are included in a network: all the addresses between
247
260
  the network number and the broadcast. IPAddress has many methods to
248
- iterate between those addresses. Let's start with IPv4#each, which
261
+ iterate between those addresses. Let's start with `IPv4#each`, which
249
262
  iterates over all addresses in a range
250
263
 
251
264
  ip = IPAddress "172.16.10.1/24"
@@ -258,7 +271,7 @@ It is important to note that it doesn't matter if the original IP is a
258
271
  host IP or a network number (or a broadcast address): the #each method
259
272
  only considers the range that the original IP specifies.
260
273
 
261
- If you only want to iterate over hosts IP, use the IPv4#each_host
274
+ If you only want to iterate over hosts IP, use the `IPv4#each_host`
262
275
  method:
263
276
 
264
277
  ip = IPAddress "172.16.10.1/24"
@@ -267,7 +280,7 @@ method:
267
280
  puts host
268
281
  end
269
282
 
270
- Methods IPv4#first and IPv4#last return a new object containing
283
+ Methods `IPv4#first` and `IPv4#last` return a new object containing
271
284
  respectively the first and the last host address in the range
272
285
 
273
286
  ip = IPAddress "172.16.10.100/24"
@@ -278,6 +291,28 @@ respectively the first and the last host address in the range
278
291
  ip.last.to_string
279
292
  #=> "172.16.10.254/24"
280
293
 
294
+ Checking if an address is loopback is easy with the `IPv4#loopback?`
295
+ method:
296
+
297
+ ip = IPAddress "127.0.0.1"
298
+
299
+ ip.loopback?
300
+ #=> true
301
+
302
+ Checking if an address is in the multicast range can be done using the `IPv4#multicast?`
303
+ method:
304
+
305
+ ip = IPAddress "224.0.0.1/32"
306
+
307
+ ip.multicast?
308
+ #=> true
309
+
310
+ The ability to generate a range also exists by using the `IPv4#to()` method. This allows you to create a subnet agnostic range based off a fixed amount.
311
+
312
+ ip = IPAddress "172.16.10.100/24"
313
+ ip.to('172.16.10.110')
314
+ #=> ["172.16.10.100", ..., "172.16.10.110"]
315
+
281
316
  === IP special formats
282
317
 
283
318
  The IPAddress library provides a complete set of methods to access an
@@ -295,38 +330,43 @@ The first thing to highlight here is that all these conversion methods
295
330
  only take into consideration the address portion of an IPv4 object and
296
331
  not the prefix (netmask).
297
332
 
298
- So, to express the address in binary format, use the IPv4#bits method:
333
+ So, to express the address in binary format, use the `IPv4#bits` method:
299
334
 
300
335
  ip.bits
301
336
  #=> "10101100000100000000101000000001"
302
337
 
303
338
  To calculate the 32 bits unsigned int format of the ip address, use
304
- the IPv4#to_u32 method
339
+ the `IPv4#to_u32` method
305
340
 
306
341
  ip.to_u32
307
342
  #=> 2886732289
308
343
 
309
- This method is the equivalent of the Unix call pton(), expressing an
344
+ This method is the equivalent of the Unix call `pton()`, expressing an
310
345
  IP address in the so called +network byte order+ notation. However, if
311
346
  you want to transmit your IP over a network socket, you might need to
312
- transform it in data format using the IPv4#data method:
347
+ transform it in data format using the `IPv4#data` method:
313
348
 
314
349
  ip.data
315
350
  #=> "\254\020\n\001"
316
351
 
317
- Finally, you can transform an IPv4 address into a format which is
352
+ Also, you can transform an IPv4 address into a format which is
318
353
  suitable to use in IPv4-IPv6 mapped addresses:
319
354
 
320
355
  ip.to_ipv6
321
356
  #=> "ac10:0a01"
322
357
 
358
+ Finally, much like `IPv4#to_ipv6` you can use to `IPv4#to_h` method to return a non-semicolon delineated string (useful with pcap/byte level usage):
359
+
360
+ ip.to_h
361
+ #=> "ac100a01"
362
+
323
363
  === Classful networks
324
364
 
325
365
  IPAddress allows you to create and manipulate objects using the old
326
366
  and deprecated (but apparently still popular) classful networks concept.
327
367
 
328
368
  Classful networks and addresses don't have a prefix: their subnet mask
329
- is univocally identified by their address, and therefore diveded in classes.
369
+ is univocally identified by their address, and therefore divided in classes.
330
370
  As per RFC 791, these classes are:
331
371
 
332
372
  * Class A, from 0.0.0.0 to 127.255.255.255
@@ -388,7 +428,7 @@ Subnetting is easy with IPAddress. You actually have two options:
388
428
  * IPv4#subnet: specify a new prefix
389
429
  * IPv4#split: tell IPAddress how many subnets you want to create.
390
430
 
391
- Let's examine IPv4#subnet first. Say you have network "172.16.10.0/24"
431
+ Let's examine `IPv4#subnet` first. Say you have network "172.16.10.0/24"
392
432
  and you want to subnet it into /26 networks. With IPAddress it's very
393
433
  easy:
394
434
 
@@ -408,7 +448,7 @@ representing the new subnets.
408
448
  Another way to create subnets is to tell IPAddress how many subnets you'd
409
449
  like to have, and letting the library calculate the new prefix for you.
410
450
 
411
- Let's see how it works, using IPv4#split method. Say you want 4 new subnets:
451
+ Let's see how it works, using `IPv4#split` method. Say you want 4 new subnets:
412
452
 
413
453
  network = IPAddress("172.16.10.0/24")
414
454
 
@@ -421,15 +461,15 @@ Let's see how it works, using IPv4#split method. Say you want 4 new subnets:
421
461
  "172.16.10.192/26"]
422
462
 
423
463
  Hey, that's the same result as before! This actually makes sense, as the
424
- two operations are complementary. When you use IPv4#subnet with the new
464
+ two operations are complementary. When you use `IPv4#subnet` with the new
425
465
  prefix, IPAddress will always create a number of subnets that is a power
426
466
  of two. This is equivalent to use IPv4#split with a power of 2.
427
467
 
428
- Where IPv4#split really shines is with the so called "uneven subnetting".
468
+ Where `IPv4#split` really shines is with the so called "uneven subnetting".
429
469
  You are not limited to split a network into a power-of-two numbers of
430
470
  subnets: IPAddress lets you create any number of subnets, and it will
431
471
  try to organize the new created network in the best possible way, making
432
- an efficent allocation of the space.
472
+ an efficient allocation of the space.
433
473
 
434
474
  An example here is worth a thousand words. Let's use the same network
435
475
  as the previous examples:
@@ -447,8 +487,8 @@ How do we split this network into 3 subnets? Very easy:
447
487
 
448
488
  As you can see, IPAddress tried to perform a good allocation by filling up
449
489
  all the address space from the original network. There is no point in splitting
450
- a network into 3 subnets like "172.16.10.0/26", "172.16.10.64/26" and
451
- "172.16.10.128/26", as you would end up having "172.16.10.192/26" wasted (plus,
490
+ a network into 3 subnets like `172.16.10.0/26`, `172.16.10.64/26` and
491
+ `172.16.10.128/26`, as you would end up having `172.16.10.192/26` wasted (plus,
452
492
  I suppose I wouldn't need a Ruby library to perform un-efficient IP
453
493
  allocation, as I do that myself very well ;) ).
454
494
 
@@ -460,8 +500,8 @@ We can go even further and split into 11 subnets:
460
500
  "172.16.10.96/28", "172.16.10.112/28", "172.16.10.128/27",
461
501
  "172.16.10.160/27", "172.16.10.192/26"]
462
502
 
463
- As you can see, most of the networks are /28, with a few /27 and one
464
- /26 to fill up the remaining space.
503
+ As you can see, most of the networks are `/28`, with a few `/27` and one
504
+ `/26` to fill up the remaining space.
465
505
 
466
506
  ==== Summarization
467
507
 
@@ -489,10 +529,10 @@ instance the following two networks:
489
529
  These two networks can be expressed using only one IP address
490
530
  network if we change the prefix. Let Ruby do the work:
491
531
 
492
- IPAddress::IPv4::summarize(ip1,ip2).to_string
532
+ IPAddress::IPv4::summarize(ip1,ip2).map(&:to_string)
493
533
  #=> "172.16.10.0/23"
494
534
 
495
- We note how the network "172.16.10.0/23" includes all the
535
+ We note how the network `172.16.10.0/23` includes all the
496
536
  addresses specified in the above networks, and (more important) includes
497
537
  ONLY those addresses.
498
538
 
@@ -509,7 +549,7 @@ is not an aggregate network for +ip1+ and +ip2+.
509
549
  If it's not possible to compute a single aggregated network for
510
550
  all the original networks, the method returns an array with all the
511
551
  aggregate networks found. For example, the following four networks can be
512
- aggregated in a single /22:
552
+ aggregated in a single `/22`:
513
553
 
514
554
  ip1 = IPAddress("10.0.0.1/24")
515
555
  ip2 = IPAddress("10.0.1.1/24")
@@ -531,7 +571,7 @@ network:
531
571
  #=> ["10.0.1.0/24","10.0.2.0/23","10.0.4.0/24"]
532
572
 
533
573
  In this case, the two summarizables networks have been aggregated into
534
- a single /23, while the other two networks have been left untouched.
574
+ a single `/23`, while the other two networks have been left untouched.
535
575
 
536
576
  ==== Supernetting
537
577
 
@@ -550,13 +590,13 @@ you can supernet it with a new /23 prefix
550
590
  ip.supernet(23).to_string
551
591
  #=> "172.16.10.0/23"
552
592
 
553
- However if you supernet it with a /22 prefix, the network address will
593
+ However if you supernet it with a `/22` prefix, the network address will
554
594
  change:
555
595
 
556
596
  ip.supernet(22).to_string
557
597
  #=> "172.16.8.0/22"
558
598
 
559
- This is because "172.16.10.0/22" is not a network anymore, but an host
599
+ This is because `172.16.10.0/22` is not a network anymore, but an host
560
600
  address.
561
601
 
562
602
  == IPv6
@@ -638,7 +678,7 @@ methods:
638
678
  #=> 64
639
679
 
640
680
  A compressed version of the IPv6 address can be obtained with the
641
- IPv6#compressed method:
681
+ `IPv6#compressed` method:
642
682
 
643
683
  ip6 = IPAddress "2001:0db8:0000:0000:0008:200c:417a:00ab/64"
644
684
 
@@ -648,7 +688,7 @@ IPv6#compressed method:
648
688
  === Handling the IPv6 address
649
689
 
650
690
  Accessing the groups that form an IPv6 address is very easy with the
651
- IPv6#groups method:
691
+ `IPv6#groups` method:
652
692
 
653
693
  ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
654
694
 
@@ -656,7 +696,7 @@ IPv6#groups method:
656
696
  #=> [8193, 3512, 0, 0, 8, 2048, 8204, 16762]
657
697
 
658
698
  As with IPv4 addresses, each individual group can be accessed using
659
- the IPv6#[] shortcut method:
699
+ the `IPv6#[]` shortcut method:
660
700
 
661
701
  ip6[0]
662
702
  #=> 8193
@@ -668,14 +708,14 @@ the IPv6#[] shortcut method:
668
708
  #=> 0
669
709
 
670
710
  Note that each 16 bits group is expressed in its decimal form. You can
671
- also obtain the groups into hexadecimal format using the IPv6#hexs
711
+ also obtain the groups into hexadecimal format using the `IPv6#hexs`
672
712
  method:
673
713
 
674
714
  ip6.hexs
675
715
  #=> => ["2001", "0db8", "0000", "0000", "0008", "0800", "200c", "417a"]
676
716
 
677
717
  A few other methods are available to transform an IPv6 address into
678
- decimal representation, with IPv6.to_i
718
+ decimal representation, with `IPv6.to_i`
679
719
 
680
720
  ip6.to_i
681
721
  #=> 42540766411282592856906245548098208122
@@ -685,8 +725,8 @@ or to hexadecimal representation
685
725
  ip6.to_hex
686
726
  #=> "20010db80000000000080800200c417a"
687
727
 
688
- To print out an IPv6 address in human readable form, use the IPv6#to_s, IPv6#to_string
689
- and IPv6#to_string_uncompressed methods
728
+ To print out an IPv6 address in human readable form, use the `IPv6#to_s`, `IPv6#to_string`
729
+ and `IPv6#to_string_uncompressed` methods
690
730
 
691
731
  ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
692
732
 
@@ -696,8 +736,8 @@ and IPv6#to_string_uncompressed methods
696
736
  ip6.to_string_uncompressed
697
737
  #=> "2001:0db8:0000:0000:0008:0800:200c:417a/96"
698
738
 
699
- As you can see, IPv6.to_string prints out the compressed form, while
700
- IPv6.to_string_uncompressed uses the expanded version.
739
+ As you can see, `IPv6.to_string` prints out the compressed form, while
740
+ `IPv6.to_string_uncompressed` uses the expanded version.
701
741
 
702
742
  ==== Compressing and uncompressing
703
743
 
@@ -731,7 +771,7 @@ actually created internally).
731
771
  You can create a new IPv6 address from different formats than just a
732
772
  string representing the colon-hex groups.
733
773
 
734
- For instance, if you have a data stream, you can use IPv6::parse_data,
774
+ For instance, if you have a data stream, you can use `IPv6::parse_data`,
735
775
  like in the following example:
736
776
 
737
777
  data = " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
@@ -772,7 +812,7 @@ support for unspecified, loopback and mapped IPv6 addresses.
772
812
  ==== Unspecified address
773
813
 
774
814
  The address with all zero bits is called the +unspecified+ address
775
- (corresponding to 0.0.0.0 in IPv4). It should be something like this:
815
+ (corresponding to `0.0.0.0` in IPv4). It should be something like this:
776
816
 
777
817
  0000:0000:0000:0000:0000:0000:0000:0000
778
818
 
@@ -814,7 +854,7 @@ packets with the unspecified address.
814
854
 
815
855
  ==== Loopback address
816
856
 
817
- The loopback address is a unicast localhost address. If an
857
+ The loopback address is a unicast localhost address. If an
818
858
  application in a host sends packets to this address, the IPv6 stack
819
859
  will loop these packets back on the same virtual interface.
820
860
 
@@ -841,13 +881,13 @@ or by using the wrapper:
841
881
  ip.to_string
842
882
  #=> "::1/128"
843
883
 
844
- Checking if an address is loopback is easy with the IPv6#loopback?
884
+ Checking if an address is loopback is easy with the `IPv6#loopback?`
845
885
  method:
846
886
 
847
887
  ip.loopback?
848
888
  #=> true
849
889
 
850
- The IPv6 loopback address corresponds to 127.0.0.1 in IPv4.
890
+ The IPv6 loopback address corresponds to `127.0.0.1` in IPv4.
851
891
 
852
892
  ==== Mapped address
853
893
 
@@ -857,7 +897,7 @@ structure of the address is
857
897
 
858
898
  ::ffff:w.y.x.z
859
899
 
860
- where w.x.y.z is a normal IPv4 address. For example, the following is
900
+ where `w.x.y.z` is a normal IPv4 address. For example, the following is
861
901
  a mapped IPv6 address:
862
902
 
863
903
  ::ffff:192.168.100.1
@@ -881,7 +921,7 @@ Let's check it's really a mapped address:
881
921
  ip6.to_string
882
922
  #=> "::ffff:172.16.10.1/128"
883
923
 
884
- Now with the +ipv4+ attribute, we can easily access the IPv4 portion
924
+ Now with the `#ipv4` attribute, we can easily access the IPv4 portion
885
925
  of the mapped IPv6 address:
886
926
 
887
927
  ip6.ipv4.address
@@ -902,7 +942,7 @@ following format:
902
942
 
903
943
  ip6 = IPAddress "::172.16.10.1"
904
944
 
905
- That is, two colons and the IPv4 address. However, as by RFC, the ffff
945
+ That is, two colons and the IPv4 address. However, as by RFC, the `ffff`
906
946
  group will be automatically added at the beginning
907
947
 
908
948
  ip6.to_string
@@ -955,7 +995,4 @@ feedback and bug reports.
955
995
 
956
996
  == Copyright
957
997
 
958
- Copyright (c) 2009-2011 Marco Ceresa. See LICENSE for details.
959
-
960
-
961
-
998
+ Copyright (c) 2009-2015 Marco Ceresa and Mike Mackintosh. See LICENSE for details.