Comments for "Net_MAC"

» Submit Your Comment
Comments are only accepted during the "Proposal" phase. This proposal is currently in the "Finished" phase.
» Comments
  • itrebal  [2006-10-25 23:58 UTC]

    ($uppercase) ? $macaddr = strtoupper($macaddr) : $macaddr = strtolower($macaddr);
    Either switch that to an if-else statement, or do:
    $macaddr = ($uppercase)?strtoupper($macaddr):strtolower($macaddr);
    Much cleaner and easier to read.

    Note: Ternaries are generally avoided.
  • Justin Patrin  [2006-10-26 04:41 UTC]

    As Graham mentioned,
    ($uppercase) ? $macaddr = strtoupper($macaddr) : $macaddr = strtolower($macaddr);
    should be
    $macaddr = ($uppercase) ? strtoupper($macaddr) : strtolower($macaddr);

    I'd rather you used ' and . for your strings instead of " to keep consistency (and for readability).

    Why replace any non-ok chars at the beginning? Shouldn't any string that has these chars fail as it's not an ok MAC?
  • Arnaud Limbourg  [2006-10-26 07:46 UTC]

    Hi,

    Wouldn't it make more sense to add that to the Validate_* family. Having a package for one method seems a bit overkill.

    I believe it would fit perfectly in validate as it is a validation feature.

    Thanks for the work !
  • Stefan Neufeind  [2006-10-29 00:06 UTC]

    I agree with Arnaud that a pure check-function might be good to have in Validate. However I don't see how a format-function could fit there.

    Maybe a more general package Net_MAC might make sense that provides several things? What I could imagine (though sure still more exists) would be:
    - checking of mac in common formats (true/false)
    - formating of mac in any format to another (01-23-45-67-89-ab, 01:23:45:67:89:ab, 0123.4567.89ab) - though I'm still unsure how to call/classify these formatings
    - maybe something like isGlobalUnique(), isUnicast() etc.? (see Wikipedia-URL)
    - converting from MAC-48 to EUI-64 and back
    - getManufacturer() might be useful to get the manuf.-name - but e.g. the list from Wireshark is about 530kb large :-( maybe allow pointing that function to a separately downloadable datafile?

    Note that we're maybe talking about Ethernet MAC-addresses so far (MAC-48 or EUI-48) - but also EUI-64 exists (e.g. for Firewire or in IPv6-addresses).

    see:
    http://en.wikipedia.org/wiki/MAC_address
    http://anonsvn.wireshark.org/wireshark/trunk/manuf