X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FProtocols%2FRaw%2FLLAddressing.cci;h=374840bbf3af7d0338c1214352afd7dd9d9ceefa;hb=81f84badf27b66dbadec9890646ca1193e998505;hp=93deeb35191822f6b2c6d43cc58cf3774b564b41;hpb=6bb3fa3caaa41dab4d5b451ca27e70f9e55e49d6;p=senf.git diff --git a/Socket/Protocols/Raw/LLAddressing.cci b/Socket/Protocols/Raw/LLAddressing.cci index 93deeb3..374840b 100644 --- a/Socket/Protocols/Raw/LLAddressing.cci +++ b/Socket/Protocols/Raw/LLAddressing.cci @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 // it under the terms of the GNU General Public License as published by @@ -31,78 +31,73 @@ #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ senf::LLSocketAddress::LLSocketAddress() +prefix_ void senf::LLSocketAddress::address(MACAddress const & addr) { - clear(); + std::copy(addr.begin(), addr.end(),&addr_.sll_addr[0]); } -prefix_ senf::LLSocketAddress::LLSocketAddress(unsigned protocol, std::string interface) -{ - clear(); - this->protocol(protocol); - this->interface(interface); -} +prefix_ senf::LLSocketAddress::LLSocketAddress() + : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET) +{} -prefix_ senf::LLSocketAddress::LLSocketAddress(std::string interface) +prefix_ void senf::LLSocketAddress::protocol(unsigned prot) { - clear(); - this->interface(interface); + addr_.sll_protocol = htons(prot); } -prefix_ void senf::LLSocketAddress::clear() +prefix_ senf::LLSocketAddress::LLSocketAddress(unsigned prot, std::string const & iface) + : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET) { - ::memset(&addr_,0,sizeof(addr_)); - addr_.sll_family = AF_PACKET; + protocol(prot); + interface(iface); } -prefix_ unsigned senf::LLSocketAddress::protocol() - const +prefix_ senf::LLSocketAddress::LLSocketAddress(std::string const &iface) + : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET) { - return ntohs(addr_.sll_protocol); + interface(iface); } -prefix_ unsigned senf::LLSocketAddress::arptype() - const +prefix_ senf::LLSocketAddress::LLSocketAddress(MACAddress const & addr, + std::string const & iface) + : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET) { - /** \todo make sure, that the value really is in network byte - order */ - return ntohs(addr_.sll_hatype); + address(addr); + interface(iface); } -prefix_ unsigned senf::LLSocketAddress::pkttype() - const -{ - /** \todo make sure, that the value really is in network byte - order */ - return ntohs(addr_.sll_pkttype); -} +prefix_ senf::LLSocketAddress::LLSocketAddress(const LLSocketAddress& other) + : BSDSocketAddress (other) +{} -prefix_ senf::LLSocketAddress::LLAddress senf::LLSocketAddress::address() - const +prefix_ senf::LLSocketAddress& senf::LLSocketAddress::operator=(const LLSocketAddress& other) { - return LLAddress(&addr_.sll_addr[0], &addr_.sll_addr[addr_.sll_halen]); + BSDSocketAddress::operator=(other); + return *this; } -prefix_ void senf::LLSocketAddress::protocol(unsigned protocol) +prefix_ unsigned senf::LLSocketAddress::protocol() + const { - addr_.sll_protocol = htons(protocol); + return ntohs(addr_.sll_protocol); } -prefix_ struct sockaddr * senf::LLSocketAddress::sockaddr_p() +prefix_ unsigned senf::LLSocketAddress::arptype() + const { - return reinterpret_cast(&addr_); + return ntohs(addr_.sll_hatype); } -prefix_ struct sockaddr const * senf::LLSocketAddress::sockaddr_p() +prefix_ senf::LLSocketAddress::PktType senf::LLSocketAddress::pkttype() const { - return reinterpret_cast(&addr_); + return PktType(ntohs(addr_.sll_pkttype)); } -prefix_ unsigned senf::LLSocketAddress::sockaddr_len() +prefix_ senf::MACAddress senf::LLSocketAddress::address() const { - return sizeof(addr_); + return MACAddress::from_data(&addr_.sll_addr[0]); } ///////////////////////////////cci.e///////////////////////////////////////