X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FRaw%2FMACAddress.cci;h=a2ec2747e5f631a9b44d9b451e4d68aecde4e251;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=d80d0e6e0e2c7d34489ca5b61a794f836271b43e;hpb=6bb3fa3caaa41dab4d5b451ca27e70f9e55e49d6;p=senf.git diff --git a/Socket/Protocols/Raw/MACAddress.cci b/Socket/Protocols/Raw/MACAddress.cci index d80d0e6..a2ec274 100644 --- a/Socket/Protocols/Raw/MACAddress.cci +++ b/Socket/Protocols/Raw/MACAddress.cci @@ -1,6 +1,8 @@ -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// $Id$ +// +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -36,16 +38,26 @@ prefix_ senf::MACAddress::MACAddress() std::fill(begin(),end(),0u); } -prefix_ senf::MACAddress::MACAddress(NoInit_t) +prefix_ senf::MACAddress::MACAddress(senf::NoInit_t) {} +prefix_ senf::MACAddress::MACAddress(boost::uint64_t v) +{ + (*this)[0] = boost::uint8_t( v>>40 ); + (*this)[1] = boost::uint8_t( v>>32 ); + (*this)[2] = boost::uint8_t( v>>24 ); + (*this)[3] = boost::uint8_t( v>>16 ); + (*this)[4] = boost::uint8_t( v>> 8 ); + (*this)[5] = boost::uint8_t( v ); +} + prefix_ bool senf::MACAddress::local() const { return (*this)[0] & 0x02; } -prefix_ bool senf::MACAddress::group() +prefix_ bool senf::MACAddress::multicast() const { return (*this)[0] & 0x01; @@ -96,6 +108,18 @@ prefix_ boost::uint64_t senf::MACAddress::eui64() (boost::uint64_t( (*this)[5] ) ); } +prefix_ boost::uint64_t senf::MACAddress::uint64() + const +{ + return + (boost::uint64_t( (*this)[0] ) << 40) | + (boost::uint64_t( (*this)[1] ) << 32) | + (boost::uint64_t( (*this)[2] ) << 24) | + (boost::uint64_t( (*this)[3] ) << 16) | + (boost::uint64_t( (*this)[4] ) << 8) | + (boost::uint64_t( (*this)[5] ) ); +} + ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_