1

I'm working on a Accounting Tool in PHP which connects to a CISCO Switch and insert a MAC Address on a specified port. I use Symfony as my underlying php framework.

If I try to insert a Multicast MAC address as a FastEthernet secure address the CISCO Switch reject the address. So I try to build a validator which determine if the given MAC address is a multicast address or not.

Is there someone out there who can help me with a snippet or tip?

j0k
  • 22,600
  • 28
  • 79
  • 90
hanspeter
  • 11
  • 1

1 Answers1

0

Try this snippet:

function isPhysicalAddress($address){
    if (strlen($address) > 17) return 0;

    if ($address == "") return 0;

    if (!eregi("^[0-9A-Z]+(\-[0-9A-Z]+)+(\-[0-9A-Z]+)+(\-[0-9A-Z]+)+(\-[0-9A-Z]+)+(\-[0-9A-Z]+)$", $address)) return 0;

    $arr=explode("-",$address);

    if (strlen($arr[0]) != 2) return 0;
    if (strlen($arr[1]) != 2) return 0;
    if (strlen($arr[2]) != 2) return 0;
    if (strlen($arr[3]) != 2) return 0;
    if (strlen($arr[4]) != 2) return 0;
    if (strlen($arr[5]) != 2) return 0;

    return 1;
}

Found here.

Darmen Amanbay
  • 4,869
  • 3
  • 29
  • 50
  • Sorry darmen, but this is not an answer to my question. I know how to validate a mac-address but I don't know to find out if this address is a "multicast" mac-address. This is much more complicate as just have a simple regex call. – hanspeter Jan 22 '11 at 01:00