4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief INet[46]Address and INet[46]AddressingPolicy inline non-template implementation
28 #include <arpa/inet.h>
30 #define prefix_ inline
31 ///////////////////////////////cci.p///////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////////
36 prefix_ senf::INet4SocketAddress::INet4SocketAddress()
37 : BSDSocketAddress (sizeof(sockaddr_in), AF_INET)
40 prefix_ senf::INet4SocketAddress::INet4SocketAddress(const INet4SocketAddress& other)
41 : BSDSocketAddress(other)
44 prefix_ senf::INet4SocketAddress&
45 senf::INet4SocketAddress::operator=(const INet4SocketAddress& other)
47 BSDSocketAddress::operator=(other);
51 prefix_ senf::INet4Address senf::INet4SocketAddress::address()
54 return INet4Address::from_inaddr(addr_.sin_addr.s_addr);
57 prefix_ unsigned senf::INet4SocketAddress::port()
60 return ntohs(addr_.sin_port);
63 prefix_ void senf::INet4SocketAddress::address(INet4Address const & addr)
65 addr_.sin_addr.s_addr = addr.inaddr();
68 prefix_ void senf::INet4SocketAddress::port(unsigned p)
70 addr_.sin_port = htons(p);
73 ///////////////////////////////////////////////////////////////////////////
74 // senf::INet6SocketAddress
76 prefix_ senf::INet6SocketAddress::INet6SocketAddress()
77 : BSDSocketAddress (sizeof(sockaddr_in6), AF_INET6)
80 prefix_ senf::INet6SocketAddress::INet6SocketAddress(INet6Address const & addr, unsigned port)
81 : BSDSocketAddress (sizeof(sockaddr_in6), AF_INET6)
83 std::copy(addr.begin(), addr.end(), &sockaddr_.sin6_addr.s6_addr[0]);
84 sockaddr_.sin6_port = htons(port);
87 prefix_ senf::INet6SocketAddress::INet6SocketAddress(INet6Address const & addr, unsigned port,
88 std::string const & iface)
89 : BSDSocketAddress (sizeof(sockaddr_in6), AF_INET6)
91 std::copy(addr.begin(), addr.end(), &sockaddr_.sin6_addr.s6_addr[0]);
92 sockaddr_.sin6_port = htons(port);
96 prefix_ senf::INet6SocketAddress::INet6SocketAddress(unsigned port)
97 : BSDSocketAddress (sizeof(sockaddr_in6), AF_INET6)
99 sockaddr_.sin6_port = htons(port);
102 prefix_ senf::INet6SocketAddress::INet6SocketAddress(const INet6SocketAddress& other)
103 : BSDSocketAddress (other)
106 prefix_ senf::INet6SocketAddress&
107 senf::INet6SocketAddress::operator=(const INet6SocketAddress& other)
109 BSDSocketAddress::operator=(other);
113 prefix_ senf::INet6Address senf::INet6SocketAddress::address()
116 return INet6Address::from_data(&sockaddr_.sin6_addr.s6_addr[0]);
119 prefix_ void senf::INet6SocketAddress::address(INet6Address const & addr)
121 std::copy(addr.begin(), addr.end(), &sockaddr_.sin6_addr.s6_addr[0]);
124 prefix_ unsigned senf::INet6SocketAddress::port()
127 return ntohs(sockaddr_.sin6_port);
130 prefix_ void senf::INet6SocketAddress::port(unsigned port)
132 sockaddr_.sin6_port = htons(port);
135 prefix_ void senf::INet6SocketAddress::iface(std::string const & iface)
140 ///////////////////////////////cci.e///////////////////////////////////////
147 // c-file-style: "senf"
148 // indent-tabs-mode: nil
149 // ispell-local-dictionary: "american"
150 // compile-command: "scons -u test"
151 // comment-column: 40