Ignore:
Timestamp:
Oct 19, 2014, 6:47:57 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Skript pro generování všech IPv6 adres u rozhraní z IPv6 podsítí a MAC adres.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/NetworkAddress.php

    r701 r705  
    9191        return($Result);
    9292  }
    93  
     93
    9494  function EncodeMAC($MAC)
    9595  {
    9696        $MAC = explode(':', $MAC);
    97         $Data = array_reverse(unpack('C*', $this->Address));
    98         print_r($Data);
    99         $Data[7] = $MAC[0];
    100         $Data[6] = $MAC[1] ^ 0x02;
    101         $Data[5] = $MAC[2];
    102         $Data[4] = 0xff;
    103         $Data[3] = 0xfe;
    104         $Data[2] = $MAC[3];
    105         $Data[1] = $MAC[4];
    106         $Data[0] = $MAC[5];
    107         print_r($Data);
    108         $this->Address = pack('C*', $Data);
     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);
    109107  }
    110108
Note: See TracChangeset for help on using the changeset viewer.