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:
25  C4Network2Address() = default;
26 
28  : addr(addr.AsIPv4()), eProtocol(eProtocol)
29  { }
30 
32  : addr(addr.getAddr()), eProtocol(addr.getProtocol())
33  { }
34 
36  { SetAddr(addr.getAddr()); SetProtocol(addr.getProtocol()); }
37 
38  bool operator == (const C4Network2Address &addr) const;
39 
40 protected:
43 
44 public:
45  const C4NetIO::addr_t &getAddr() const { return addr; }
46  C4NetIO::addr_t &getAddr() { return addr; }
47  //in_addr getIPAddr() const { return addr.sin_addr; }
48  bool isIPNull() const { return addr.IsNull(); }
49  uint16_t getPort() const { return addr.GetPort(); }
51 
52  StdStrBuf toString() const;
53 
54  void SetAddr(C4NetIO::addr_t naddr) { addr = naddr.AsIPv4(); }
55  //void SetIP(in_addr ip) { addr.SetAddress(ip); }
56  void SetIP(C4NetIO::addr_t ip) { addr.SetAddress(ip.AsIPv4()); }
57  void SetPort(uint16_t iPort) { addr.SetPort(iPort); }
58  void SetProtocol(C4Network2IOProtocol enProtocol) { eProtocol = enProtocol; }
59 
60  void CompileFunc(StdCompiler *pComp);
61 };
62 
63 #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:364
C4Network2Address()=default
bool isIPNull() const
void SetPort(uint16_t iPort)
void SetPort(uint16_t port)
Definition: C4NetIO.cpp:526
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:503
EndpointAddress AsIPv4() const
Definition: C4NetIO.cpp:341
uint16_t GetPort() const
Definition: C4NetIO.cpp:542
const C4NetIO::addr_t & getAddr() const
C4NetIO::addr_t addr
void CompileFunc(StdCompiler *pComp)