Beispiel #1
0
 /**
  * {@inheritdoc}
  *
  * @see AddressInterface::getRangeType()
  */
 public function getRangeType()
 {
     if ($this->rangeType === null) {
         switch (true) {
             // ::/128 - rfc4291
             case $this->longAddress === '0000:0000:0000:0000:0000:0000:0000:0000':
                 $this->rangeType = RangeType::T_UNSPECIFIED;
                 break;
                 // ::1/128 - rfc4291
             // ::1/128 - rfc4291
             case $this->longAddress === '0000:0000:0000:0000:0000:0000:0000:0001':
                 $this->rangeType = RangeType::T_LOOPBACK;
                 break;
                 // 100::/64 - rfc4291
             // 100::/64 - rfc4291
             case strpos($this->longAddress, '0100:0000:0000:0000') === 0:
                 $this->rangeType = RangeType::T_DISCARDONLY;
                 break;
                 // 100::/8 - rfc4291
             // 100::/8 - rfc4291
             case strpos($this->longAddress, '01') === 0:
                 $this->rangeType = RangeType::T_DISCARD;
                 break;
                 // 2002::/16 - rfc4291
             // 2002::/16 - rfc4291
             case strpos($this->longAddress, '2002') === 0:
                 $this->rangeType = $this->toIPv4()->getRangeType();
                 break;
                 // 2000::/3 - rfc4291
             // 2000::/3 - rfc4291
             case $this->matches(Subnet::fromString('2000::/3')):
                 $this->rangeType = RangeType::T_PUBLIC;
                 // Unicast global addresses
                 break;
                 // fc00::/7 - rfc4193
             // fc00::/7 - rfc4193
             case $this->matches(Subnet::fromString('fc00::/7')):
                 $this->rangeType = RangeType::T_PRIVATENETWORK;
                 break;
                 // fe80::/10 - rfc4291
             // fe80::/10 - rfc4291
             case $this->matches(Subnet::fromString('fe80::/10')):
                 $this->rangeType = RangeType::T_LINKLOCAL_UNICAST;
                 break;
                 // ff00::/8 - rfc4291
             // ff00::/8 - rfc4291
             case strpos($this->longAddress, 'ff') === 0:
                 $this->rangeType = RangeType::T_MULTICAST;
                 break;
                 // ::/8 - rfc4291
                 // 200::/7 - rfc4048
                 // 400::/6 - rfc4291
                 // 800::/5 - rfc4291
                 // 1000::/4 - rfc4291
                 // 4000::/3 - rfc4291
                 // 6000::/3 - rfc4291
                 // 8000::/3 - rfc4291
                 // a000::/3 - rfc4291
                 // c000::/3 - rfc4291
                 // e000::/4 - rfc4291
                 // f000::/5 - rfc4291
                 // f800::/6 - rfc4291
                 // fe00::/9 - rfc4291
                 // fec0::/10 - rfc3879
             // ::/8 - rfc4291
             // 200::/7 - rfc4048
             // 400::/6 - rfc4291
             // 800::/5 - rfc4291
             // 1000::/4 - rfc4291
             // 4000::/3 - rfc4291
             // 6000::/3 - rfc4291
             // 8000::/3 - rfc4291
             // a000::/3 - rfc4291
             // c000::/3 - rfc4291
             // e000::/4 - rfc4291
             // f000::/5 - rfc4291
             // f800::/6 - rfc4291
             // fe00::/9 - rfc4291
             // fec0::/10 - rfc3879
             default:
                 $this->rangeType = RangeType::T_RESERVED;
                 break;
         }
     }
     return $this->rangeType;
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  *
  * @see AddressInterface::getRangeType()
  */
 public function getRangeType()
 {
     if ($this->rangeType === null) {
         // RFC 5735
         switch (true) {
             // 0.0.0.0/32
             case $this->address === '0.0.0.0':
                 $this->rangeType = RangeType::T_UNSPECIFIED;
                 break;
                 // 0.0.0.0/8 - Source hosts on "this" network
             // 0.0.0.0/8 - Source hosts on "this" network
             case strpos($this->address, '0.') === 0:
                 $this->rangeType = RangeType::T_THISNETWORK;
                 break;
                 // 10.0.0.0/8
             // 10.0.0.0/8
             case strpos($this->address, '10.') === 0:
                 $this->rangeType = RangeType::T_PRIVATENETWORK;
                 break;
                 // 127.0.0.0/8 - Ordinarily implemented using only 127.0.0.1/32
             // 127.0.0.0/8 - Ordinarily implemented using only 127.0.0.1/32
             case strpos($this->address, '127.') === 0:
                 $this->rangeType = RangeType::T_LOOPBACK;
                 break;
                 // 169.254.0.0/16
             // 169.254.0.0/16
             case strpos($this->address, '169.254.') === 0:
                 $this->rangeType = RangeType::T_LINKLOCAL;
                 break;
                 // 172.16.0.0/12
             // 172.16.0.0/12
             case $this->matches(Subnet::fromString('172.16.0.0/12')):
                 $this->rangeType = RangeType::T_PRIVATENETWORK;
                 break;
                 // 192.0.0.0/24 - Reserved for IETF protocol assignments
             // 192.0.0.0/24 - Reserved for IETF protocol assignments
             case strpos($this->address, '192.0.0.') === 0:
                 $this->rangeType = RangeType::T_RESERVED;
                 break;
                 // 192.0.2.0/24 - Assigned as "TEST-NET-1" for use in documentation and example code
             // 192.0.2.0/24 - Assigned as "TEST-NET-1" for use in documentation and example code
             case strpos($this->address, '192.0.2.') === 0:
                 $this->rangeType = RangeType::T_RESERVED;
                 break;
                 // 192.88.99.0/24 - 6to4 relay anycast addresses
             // 192.88.99.0/24 - 6to4 relay anycast addresses
             case strpos($this->address, '192.88.99.') === 0:
                 $this->rangeType = RangeType::T_ANYCASTRELAY;
                 break;
                 // 192.168.0.0/16
             // 192.168.0.0/16
             case strpos($this->address, '192.168.') === 0:
                 $this->rangeType = RangeType::T_PRIVATENETWORK;
                 break;
                 // 198.18.0.0/15 - For use in benchmark tests of network interconnect devices
             // 198.18.0.0/15 - For use in benchmark tests of network interconnect devices
             case $this->matches(Subnet::fromString('198.18.0.0/15')):
                 $this->rangeType = RangeType::T_RESERVED;
                 break;
                 // 198.51.100.0/24 - Assigned as "TEST-NET-2" for use in documentation and example code
             // 198.51.100.0/24 - Assigned as "TEST-NET-2" for use in documentation and example code
             case strpos($this->address, '198.51.100.') === 0:
                 $this->rangeType = RangeType::T_RESERVED;
                 break;
                 // 203.0.113.0/24 - Assigned as "TEST-NET-3" for use in documentation and example code.
             // 203.0.113.0/24 - Assigned as "TEST-NET-3" for use in documentation and example code.
             case strpos($this->address, '203.0.113.') === 0:
                 $this->rangeType = RangeType::T_RESERVED;
                 break;
                 // 255.255.255.255/32
             // 255.255.255.255/32
             case $this->address === '255.255.255.255':
                 $this->rangeType = RangeType::T_LIMITEDBROADCAST;
                 break;
                 // 224.0.0.0/4 - Multicast address assignments
             // 224.0.0.0/4 - Multicast address assignments
             case $this->matches(Subnet::fromString('224.0.0.0/4')):
                 $this->rangeType = RangeType::T_MULTICAST;
                 break;
                 // 240.0.0.0/4 - Reserved for future use
             // 240.0.0.0/4 - Reserved for future use
             case $this->matches(Subnet::fromString('240.0.0.0/4')):
                 $this->rangeType = RangeType::T_RESERVED;
                 break;
             default:
                 $this->rangeType = RangeType::T_PUBLIC;
                 break;
         }
     }
     return $this->rangeType;
 }