2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief LLSocketAddress and LLAddressingPolicy inline non-template implementation
19 #include <sys/socket.h>
20 #include <netinet/in.h>
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 prefix_ senf::LLSocketAddress::LLSocketAddress()
26 : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET)
29 prefix_ senf::LLSocketAddress::LLSocketAddress(unsigned prot, std::string const & iface)
30 : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET)
36 prefix_ senf::LLSocketAddress::LLSocketAddress(std::string const &iface)
37 : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET)
42 prefix_ senf::LLSocketAddress::LLSocketAddress(MACAddress const & addr,
43 std::string const & iface)
44 : BSDSocketAddress (sizeof(sockaddr_ll), AF_PACKET)
50 prefix_ senf::LLSocketAddress::LLSocketAddress(const LLSocketAddress& other)
51 : BSDSocketAddress (other)
54 prefix_ senf::LLSocketAddress& senf::LLSocketAddress::operator=(const LLSocketAddress& other)
56 BSDSocketAddress::operator=(other);
60 prefix_ unsigned senf::LLSocketAddress::protocol()
63 return ntohs(addr_.sll_protocol);
66 prefix_ void senf::LLSocketAddress::protocol(unsigned prot)
68 addr_.sll_protocol = htons(prot);
71 prefix_ unsigned senf::LLSocketAddress::arptype()
74 return ntohs(addr_.sll_hatype);
77 prefix_ senf::LLSocketAddress::PktType senf::LLSocketAddress::pkttype()
80 return PktType(ntohs(addr_.sll_pkttype));
83 prefix_ senf::MACAddress senf::LLSocketAddress::address()
86 return MACAddress::from_data(&addr_.sll_addr[0]);
89 prefix_ void senf::LLSocketAddress::address(MACAddress const & addr)
91 std::copy(addr.begin(), addr.end(), &addr_.sll_addr[0]);
94 //-/////////////////////////////////////////////////////////////////////////////////////////////////
101 // c-file-style: "senf"
102 // indent-tabs-mode: nil
103 // ispell-local-dictionary: "american"
104 // compile-command: "scons -u test"
105 // comment-column: 40