String and EtherAddress
Eddie Kohler
kohler at icir.org
Tue Mar 25 19:13:45 EST 2003
Xiaophong,
Your String contains the ASCII representation of an Ethernet address. This
is very different from the address itself
"00:70:..." == characters 48, 48, 58, 55, 48, 58, ....
== hex chars 30, 30, 3A, 37, 30, 3A, ....
== Ethernet address 30:30:3A:37:30:3A
Use cp_ether_address() to go from ASCII representation -> Ethernet address,
and EtherAddress::s() to go the other way
Don't use Strings to pack Ethernet addresses togehter, use a
Vector<EtherAddress>
Don't use ".data()" when printing a String, use ".c_str()"; ".data()" might
leave off the terminating \0 character, causing a memory error
Eddie
More information about the click
mailing list