jrtplib  3.6.0
rtpipv6address.h
Go to the documentation of this file.
1 /*
2 
3  This file is a part of JRTPLIB
4  Copyright (c) 1999-2006 Jori Liesenborgs
5 
6  Contact: jori.liesenborgs@gmail.com
7 
8  This library was developed at the "Expertisecentrum Digitale Media"
9  (http://www.edm.uhasselt.be), a research center of the Hasselt University
10  (http://www.uhasselt.be). The library is based upon work done for
11  my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
12 
13  Permission is hereby granted, free of charge, to any person obtaining a
14  copy of this software and associated documentation files (the "Software"),
15  to deal in the Software without restriction, including without limitation
16  the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  and/or sell copies of the Software, and to permit persons to whom the
18  Software is furnished to do so, subject to the following conditions:
19 
20  The above copyright notice and this permission notice shall be included
21  in all copies or substantial portions of the Software.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29  IN THE SOFTWARE.
30 
31 */
32 
37 #ifndef RTPIPV6ADDRESS_H
38 
39 #define RTPIPV6ADDRESS_H
40 
41 #include "rtpconfig.h"
42 
43 #ifdef RTP_SUPPORT_IPV6
44 
45 #include "rtpaddress.h"
46 #include "rtptypes.h"
47 #if ! (defined(WIN32) || defined(_WIN32_WCE))
48  #include <netinet/in.h>
49 #endif // WIN32
50 
58 class RTPIPv6Address : public RTPAddress
59 {
60 public:
62  RTPIPv6Address():RTPAddress(IPv6Address) { for (int i = 0 ; i < 16 ; i++) ip.s6_addr[i] = 0; port = 0; }
63 
66  RTPIPv6Address(const uint8_t ip[16],uint16_t port = 0):RTPAddress(IPv6Address) { SetIP(ip); RTPIPv6Address::port = port; }
67 
70  RTPIPv6Address(in6_addr ip,uint16_t port = 0):RTPAddress(IPv6Address) { RTPIPv6Address::ip = ip; RTPIPv6Address::port = port; }
71  ~RTPIPv6Address() { }
72 
74  void SetIP(in6_addr ip) { RTPIPv6Address::ip = ip; }
75 
77  void SetIP(const uint8_t ip[16]) { for (int i = 0 ; i < 16 ; i++) RTPIPv6Address::ip.s6_addr[i] = ip[i]; }
78 
80  void SetPort(uint16_t port) { RTPIPv6Address::port = port; }
81 
83  void GetIP(uint8_t ip[16]) const { for (int i = 0 ; i < 16 ; i++) ip[i] = RTPIPv6Address::ip.s6_addr[i]; }
84 
86  in6_addr GetIP() const { return ip; }
87 
89  uint16_t GetPort() const { return port; }
90 
91  RTPAddress *CreateCopy(RTPMemoryManager *mgr) const;
92  bool IsSameAddress(const RTPAddress *addr) const;
93  bool IsFromSameHost(const RTPAddress *addr) const;
94 #ifdef RTPDEBUG
95  std::string GetAddressString() const;
96 #endif // RTPDEBUG
97 private:
98  in6_addr ip;
99  uint16_t port;
100 };
101 
102 #endif // RTP_SUPPORT_IPV6
103 
104 #endif // RTPIPV6ADDRESS_H
105 
void GetIP(uint8_t ip[16]) const
Copies the IP address of this instance in ip.
Definition: rtpipv6address.h:83
A memory manager.
Definition: rtpmemorymanager.h:144
Used by the UDP over IPv6 transmitter.
Definition: rtpaddress.h:54
void SetPort(uint16_t port)
Sets the port number for this instance to port, which is interpreted in host byte order...
Definition: rtpipv6address.h:80
void SetIP(in6_addr ip)
Sets the IP address for this instance to ip.
Definition: rtpipv6address.h:74
uint16_t GetPort() const
Returns the port number contained in this instance in host byte order.
Definition: rtpipv6address.h:89
RTPIPv6Address()
Creates an instance with IP address and port number set to zero.
Definition: rtpipv6address.h:62
This class is an abstract class which is used to specify destinations, multicast groups etc...
Definition: rtpaddress.h:47
RTPIPv6Address(const uint8_t ip[16], uint16_t port=0)
Creates an instance with IP address ip and port number port (the port number is assumed to be in host...
Definition: rtpipv6address.h:66
RTPIPv6Address(in6_addr ip, uint16_t port=0)
Creates an instance with IP address ip and port number port (the port number is assumed to be in host...
Definition: rtpipv6address.h:70
in6_addr GetIP() const
Returns the IP address of this instance.
Definition: rtpipv6address.h:86
void SetIP(const uint8_t ip[16])
Sets the IP address for this instance to ip.
Definition: rtpipv6address.h:77
Represents an IPv6 IP address and port.
Definition: rtpipv6address.h:58