OpenClonk
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 
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); }
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
C4Network2IOProtocol
Definition: C4Network2IO.h:30
@ P_NONE
Definition: C4Network2IO.h:31
void CompileFunc(StdCompiler *pComp)
bool operator==(const C4Network2Address &addr) const
C4Network2IOProtocol eProtocol
C4Network2Address(C4NetIO::addr_t addr, C4Network2IOProtocol eProtocol)
const C4NetIO::addr_t & getAddr() const
C4NetIO::addr_t addr
void operator=(const C4Network2Address &addr)
void SetProtocol(C4Network2IOProtocol enProtocol)
StdStrBuf toString() const
C4Network2Address(const C4Network2Address &addr)
C4NetIO::addr_t & getAddr()
void SetIP(C4NetIO::addr_t ip)
void SetPort(uint16_t iPort)
void SetAddr(C4NetIO::addr_t naddr)
uint16_t getPort() const
C4Network2IOProtocol getProtocol() const
bool isIPNull() const
C4Network2Address()=default
uint16_t GetPort() const
Definition: C4NetIO.cpp:547
void SetAddress(const sockaddr *addr)
Definition: C4NetIO.cpp:364
void SetPort(uint16_t port)
Definition: C4NetIO.cpp:531
EndpointAddress AsIPv4() const
Definition: C4NetIO.cpp:341