1
|
|
|
<?php /** @noinspection PhpUndefinedFieldInspection */
|
2
|
|
|
|
3
|
|
|
/**
|
4
|
|
|
* RFC 3513 - Internet Protocol Version 6 (IPv6) Addressing Architecture
|
5
|
|
|
*
|
6
|
|
|
* Obsoleted by RFC 4291
|
7
|
|
|
* Obsoletes RFC 2373
|
8
|
|
|
*
|
9
|
|
|
* @see https://tools.ietf.org/html/rfc4408
|
10
|
|
|
* @package Vanderlee\Comprehend\Library
|
11
|
|
|
*/
|
12
|
|
|
|
13
|
|
|
namespace Vanderlee\Comprehend\Library;
|
14
|
|
|
|
15
|
|
|
use Vanderlee\Comprehend\Builder\AbstractRuleset;
|
16
|
|
|
use Vanderlee\Comprehend\Parser\Parser;
|
17
|
|
|
use Vanderlee\Comprehend\Parser\Terminal\Integer;
|
18
|
|
|
|
19
|
|
|
require_once 'functions.php';
|
20
|
|
|
|
21
|
|
|
/**
|
22
|
|
|
* IPv6 address
|
23
|
|
|
* Supports formats:
|
24
|
|
|
* 1234:0:0:0:0:0:200C:417A
|
25
|
|
|
* 1234::200C:417A,
|
26
|
|
|
* 1234:0:0:0:0:0:12.34.56.78
|
27
|
|
|
* 1234::12.34.56.78
|
28
|
|
|
*
|
29
|
|
|
* @property-read Parser ipv6 IPv6 address with CIDR range
|
30
|
|
|
* @property-read Parser ipv6_address IPv6 address without CIDR range
|
31
|
|
|
*
|
32
|
|
|
* @package Vanderlee\Comprehend\Library
|
33
|
|
|
*/
|
34
|
|
|
class Rfc3513 extends AbstractRuleset
|
35
|
|
|
{
|
36
|
|
|
protected static $name = 'Rfc4408';
|
37
|
|
|
|
38
|
2 |
|
public function __construct($overwrites = [])
|
39
|
|
|
{
|
40
|
|
|
/*
|
41
|
|
|
* We'll use RFC3986 for the IPv6 definition for convenience sake.
|
42
|
|
|
* This may not be 100% accurate, but RFC 3513's definition is sloppy at best.
|
43
|
|
|
*/
|
44
|
2 |
|
$rfc3986 = new Rfc3986;
|
45
|
|
|
|
46
|
|
|
/*
|
47
|
|
|
* Normal rules
|
48
|
|
|
*/
|
49
|
|
|
$rules = [
|
50
|
|
|
// 2.3 Text Representation of Address Prefixes
|
51
|
2 |
|
'ipv6' => [$this->ipv6_address, '/', $this->prefix_length],
|
|
|
|
|
52
|
2 |
|
'ipv6_address' => $rfc3986->IPv6address,
|
53
|
2 |
|
'prefix_length' => new Integer(0, 128),
|
54
|
|
|
|
55
|
2 |
|
self::ROOT => $this->ipv6,
|
56
|
|
|
];
|
57
|
|
|
|
58
|
2 |
|
parent::__construct(array_merge($rules, $overwrites));
|
59
|
|
|
}
|
60
|
|
|
} |