4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.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.
23 #ifndef HH_INetAddressing_
24 #define HH_INetAddressing_ 1
29 #include <netinet/in.h>
30 #include "SocketPolicy.hh"
31 #include "ClientSocketHandle.hh"
32 #include "CommunicationPolicy.hh"
33 #include "GenericAddressingPolicy.hh"
35 //#include "INetAddressing.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
41 // TODO: Implement real INet4Address datatype and
42 // rename this one to INet4SockAddress ...
48 INet4Address(char const * address);
49 INet4Address(std::string address);
50 INet4Address(std::string host, unsigned port);
52 bool operator==(INet4Address const & other) const;
54 std::string str() const;
55 std::string host() const;
56 unsigned port() const;
62 struct sockaddr * sockaddr_p();
63 struct sockaddr const * sockaddr_p() const;
64 unsigned sockaddr_len() const;
67 void assignString(std::string addr);
69 struct ::sockaddr_in addr_;
72 std::ostream & operator<<(std::ostream & os, INet4Address const & addr);
79 struct INet4AddressingPolicy
80 : public AddressingPolicyBase,
81 private GenericAddressingPolicy<INet4Address>
83 typedef INet4Address Address;
85 using GenericAddressingPolicy<INet4Address>::peer;
86 using GenericAddressingPolicy<INet4Address>::local;
87 using GenericAddressingPolicy<INet4Address>::connect;
88 using GenericAddressingPolicy<INet4Address>::bind;
91 struct INet6AddressingPolicy : public AddressingPolicyBase
93 typedef INet6Address Address;
98 struct InvalidINetAddressException : public std::exception
99 { char const * what() const throw() { return "invalid inet address"; } };
103 ///////////////////////////////hh.e////////////////////////////////////////
104 #include "INetAddressing.cci"
105 //#include "INetAddressing.ct"
106 //#include "INetAddressing.cti"
107 //#include "INetAddressing.mpp"
113 // c-file-style: "satcom"