[Subversion] / PEAK / src / peak / util / nodeid48.py |
No default branch
Bookmark a link to HEAD:
(view)
(download)
(as text)
Use uuidgen() system call where available
Fix generation of random multicast MAC address, a'la FreeBSD's src/sys/kern/kern_uuid.c rev 1.7: """In case no real/physical IEEE 802 address is available, both the expired "draft-leach-uuids-guids-01" (section "4. Node IDs when no IEEE 802 network card is available") and RFC 2518 (section "6.4.1 Node Field Generation Without the IEEE 802 Address") recommend (quoted from RFC 2518): "The ideal solution is to obtain a 47 bit cryptographic quality random number, and use it as the low 47 bits of the node ID, with the _most_ significant bit of the first octet of the node ID set to 1. This bit is the unicast/multicast bit, which will never be set in IEEE 802 addresses obtained from network cards; hence, there can never be a conflict between UUIDs generated by machines with and without network cards." Unfortunately, this incorrectly explains how to implement this and the FreeBSD UUID generator code inherited this generation bug from the broken reference code in the standards draft. They should instead specify the "_least_ significant bit of the first octet of the node ID" as the multicast bit in a memory and hexadecimal string representation of a 48-bit IEEE 802 MAC address. This standards bug arised from a false interpretation, as the multicast bit is actually the _most_ significant bit in IEEE 802.3 (Ethernet) _transmission order_ of an IEEE 802 MAC address. The standards authors forgot that the bitwise order of an _octet_ from a MAC address _memory_ and hexadecimal string representation is still always from left (MSB, bit 7) to right (LSB, bit 0). Fortunately, this UUID generation bug could have occurred on systems without any Ethernet NICs only.""" nodeid48 suffered the same bug, for the same reasons, with the same impact.
Removed unused imports, found by Martijn Faassen's clever 'importchecker' script. (http://www.zope.org/Members/faassen/importchecker)
Normalized whitespace.
At least some linuxes seem to have "dummy0" with "ethernet" address of 00:00:00:00:00:00, which from_ifconfig happily finds and uses. Added a hack to skip these.
Misc. docstring fixes for better summaries in generated API docs.
Added win32 support; also, changed to only try to get nodeid if it's needed, to avoid the process spawn, etc. overhead if the nodeid is never needed.
Update to use peak.util.random
Obtain or generate a unique 48 bit identifier for the machine, suitable for use in UUID generation. XXX should work on win32 but doesn't take advantage of win32 api.
cvs-admin@eby-sarna.com Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |