PPI: Add missing TargetDgramWriter doku
[senf.git] / Socket / Protocols / Raw / LLAddressing.cci
index 93deeb3..374840b 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.de>
 //
 // 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
 #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<struct sockaddr *>(&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<struct sockaddr const *>(&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///////////////////////////////////////