INet6Address addr;
addr[0] = 0xfe;
addr[1] = 0x80;
- addr[8] = mac[0];
+ addr[8] = mac[0] ^ 0x2; // invert the "u" (universal/local) bit; see RFC 4291 Appx. A
addr[9] = mac[1];
addr[10] = mac[2];
addr[11] = 0xff;
INet6Address addr;
addr[0] = 0xfe;
addr[1] = 0x80;
- std::copy(eui.begin(), eui.end(), addr.begin()+8);
+ addr[8] = eui[0] ^ 0x2; // invert the "u" (universal/local) bit; see RFC 4291 Appx. A
+ std::copy(eui.begin()+1, eui.end(), addr.begin()+9);
return addr;
}
BOOST_CHECK_EQUAL( INet6Address::from_string("1.2.3.4", INet6Address::ResolveINet4),
INet6Address::from_string("::ffff:1.2.3.4") );
}
-
{
INet6Address addr (INet6Address::from_string("2001:dead:beef::1002:3004"));
BOOST_CHECK_EQUAL( addr.network(), senf::INet6Network(
BOOST_CHECK( INet6Address::Loopback );
BOOST_CHECK( ! INet6Address::None );
}
-
{
std::stringstream str;
INet6Address addr;
BOOST_CHECK( ! str.fail());
BOOST_CHECK_EQUAL(addr, INet6Address::from_string("2001:dead:beef::1002:3004"));
}
-
{
INet6Address addr;
addr.network(0x2000010203040506ull);
addr.id(1u);
BOOST_CHECK_EQUAL( addr, INet6Address(0x2000u,0x0102u,0x0304u,0x0506u,0u,0u,0u,1u) );
}
+ {
+ using senf::MACAddress;
+ BOOST_CHECK_EQUAL(
+ INet6Address::from_mac( MACAddress::from_string("00-0C-29-C2-52-FF")),
+ INet6Address::from_string("fe80::20c:29ff:fec2:52ff") );
+ BOOST_CHECK_EQUAL(
+ INet6Address::from_eui64( senf::EUI64::from_mac( MACAddress::from_string("a4:ba:db:fd:b8:76"))),
+ INet6Address::from_string("fe80::a6ba:dbff:fefd:b876") );
+ }
}
SENF_AUTO_UNIT_TEST(inet6Network)