OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Network2Address.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2013-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 
17 #ifndef INC_C4Network2Address
18 #define INC_C4Network2Address
19 
20 #include "network/C4Network2IO.h"
21 
23 {
24 public:
26  : eProtocol(P_NONE)
27  { }
28 
30  : addr(addr.AsIPv4()), eProtocol(eProtocol)
31  { }
32 
34  : addr(addr.getAddr()), eProtocol(addr.getProtocol())
35  { }
36 
38  { SetAddr(addr.getAddr()); SetProtocol(addr.getProtocol()); }
39 
40  bool operator == (const C4Network2Address &addr) const;
41 
42 protected:
45 
46 public:
47  const C4NetIO::addr_t &getAddr() const { return addr; }
48  C4NetIO::addr_t &getAddr() { return addr; }
49  //in_addr getIPAddr() const { return addr.sin_addr; }
50  bool isIPNull() const { return addr.IsNull(); }
51  uint16_t getPort() const { return addr.GetPort(); }
53 
54  StdStrBuf toString() const;
55 
56  void SetAddr(C4NetIO::addr_t naddr) { addr = naddr.AsIPv4(); }
57  //void SetIP(in_addr ip) { addr.SetAddress(ip); }
58  void SetIP(C4NetIO::addr_t ip) { addr.SetAddress(ip.AsIPv4()); }
59  void SetPort(uint16_t iPort) { addr.SetPort(iPort); }
60  void SetProtocol(C4Network2IOProtocol enProtocol) { eProtocol = enProtocol; }
61 
62  void CompileFunc(StdCompiler *pComp);
63 };
64 
65 #endif
bool operator==(const C4Network2Address &addr) const
C4Network2IOProtocol eProtocol
C4Network2Address(const C4Network2Address &addr)
C4Network2IOProtocol
Definition: C4Network2IO.h:29
C4Network2Address(C4NetIO::addr_t addr, C4Network2IOProtocol eProtocol)
C4NetIO::addr_t & getAddr()
uint16_t getPort() const
void SetAddress(const sockaddr *addr)
Definition: C4NetIO.cpp:370
bool isIPNull() const
void SetPort(uint16_t iPort)
void SetPort(uint16_t port)
Definition: C4NetIO.cpp:532
void operator=(const C4Network2Address &addr)
void SetProtocol(C4Network2IOProtocol enProtocol)
C4Network2IOProtocol getProtocol() const
void SetAddr(C4NetIO::addr_t naddr)
StdStrBuf toString() const
void SetIP(C4NetIO::addr_t ip)
bool IsNull() const
Definition: C4NetIO.cpp:509
EndpointAddress AsIPv4() const
Definition: C4NetIO.cpp:347
uint16_t GetPort() const
Definition: C4NetIO.cpp:548
const C4NetIO::addr_t & getAddr() const
C4NetIO::addr_t addr
void CompileFunc(StdCompiler *pComp)