Changeset 69 for trunk/Packages/Common/NetworkAddress.php
- Timestamp:
- Feb 28, 2016, 10:54:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/NetworkAddress.php
r55 r69 60 60 class NetworkAddressIPv6 61 61 { 62 63 62 var $Address; 63 var $Prefix; 64 64 65 66 67 68 69 65 function __construct() 66 { 67 $this->Address = 0; 68 $this->Prefix = 0; 69 } 70 70 71 71 function AddressToString() 72 72 { 73 73 return(inet_ntop($this->Address)); 74 74 } 75 75 76 76 function AddressFromString($Value) 77 77 { 78 78 $this->Address = inet_pton($Value); 79 79 } 80 80 81 81 function GetOctets() 82 82 { 83 84 85 86 83 $Result = array(); 84 $Data = array_reverse(unpack('C*', $this->Address)); 85 foreach($Data as $Item) 86 { 87 87 88 89 90 91 88 $Result[] = dechex($Item & 15); 89 $Result[] = dechex(($Item >> 4) & 15); 90 } 91 return($Result); 92 92 } 93 93 94 94 function EncodeMAC($MAC) 95 95 { 96 97 98 99 100 101 102 103 104 105 106 96 $MAC = explode(':', $MAC); 97 $Data = unpack('C*', $this->Address); 98 $Data[9] = hexdec($MAC[0]) ^ 0x02; 99 $Data[10] = hexdec($MAC[1]); 100 $Data[11] = hexdec($MAC[2]); 101 $Data[12] = 0xff; 102 $Data[13] = 0xfe; 103 $Data[14] = hexdec($MAC[3]); 104 $Data[15] = hexdec($MAC[4]); 105 $Data[16] = hexdec($MAC[5]); 106 $this->Address = pack_array('C*', $Data); 107 107 } 108 108
Note:
See TracChangeset
for help on using the changeset viewer.