rtpipv6address.h

Go to the documentation of this file.
00001 /*
00002 
00003   This file is a part of JRTPLIB
00004   Copyright (c) 1999-2007 Jori Liesenborgs
00005 
00006   Contact: jori.liesenborgs@gmail.com
00007 
00008   This library was developed at the "Expertisecentrum Digitale Media"
00009   (http://www.edm.uhasselt.be), a research center of the Hasselt University
00010   (http://www.uhasselt.be). The library is based upon work done for 
00011   my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
00012 
00013   Permission is hereby granted, free of charge, to any person obtaining a
00014   copy of this software and associated documentation files (the "Software"),
00015   to deal in the Software without restriction, including without limitation
00016   the rights to use, copy, modify, merge, publish, distribute, sublicense,
00017   and/or sell copies of the Software, and to permit persons to whom the
00018   Software is furnished to do so, subject to the following conditions:
00019 
00020   The above copyright notice and this permission notice shall be included
00021   in all copies or substantial portions of the Software.
00022 
00023   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00024   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00025   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00026   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00027   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00028   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00029   IN THE SOFTWARE.
00030 
00031 */
00032 
00037 #ifndef RTPIPV6ADDRESS_H
00038 
00039 #define RTPIPV6ADDRESS_H
00040 
00041 #include "rtpconfig.h"
00042 
00043 #ifdef RTP_SUPPORT_IPV6
00044 
00045 #include "rtpaddress.h"
00046 #include "rtptypes.h"
00047 #if ! (defined(WIN32) || defined(_WIN32_WCE))
00048         #include <netinet/in.h>
00049 #endif // WIN32
00050 
00058 class RTPIPv6Address : public RTPAddress
00059 {
00060 public:
00062         RTPIPv6Address():RTPAddress(IPv6Address)                                                                                                                                { for (int i = 0 ; i < 16 ; i++) ip.s6_addr[i] = 0; port = 0; }
00063 
00066         RTPIPv6Address(const uint8_t ip[16],uint16_t port = 0):RTPAddress(IPv6Address)                                                  { SetIP(ip); RTPIPv6Address::port = port; }
00067 
00070         RTPIPv6Address(in6_addr ip,uint16_t port = 0):RTPAddress(IPv6Address)                                                                   { RTPIPv6Address::ip = ip; RTPIPv6Address::port = port; }
00071         ~RTPIPv6Address()                                                                                                                                                                               { }
00072 
00074         void SetIP(in6_addr ip)                                                                                                                                                                 { RTPIPv6Address::ip = ip; }
00075 
00077         void SetIP(const uint8_t ip[16])                                                                                                                                                { for (int i = 0 ; i < 16 ; i++) RTPIPv6Address::ip.s6_addr[i] = ip[i]; }
00078 
00080         void SetPort(uint16_t port)                                                                                                                                                             { RTPIPv6Address::port = port; }
00081 
00083         void GetIP(uint8_t ip[16]) const                                                                                                                                                { for (int i = 0 ; i < 16 ; i++) ip[i] = RTPIPv6Address::ip.s6_addr[i]; }
00084 
00086         in6_addr GetIP() const                                                                                                                                                                  { return ip; }
00087 
00089         uint16_t GetPort() const                                                                                                                                                                { return port; }
00090 
00091         RTPAddress *CreateCopy(RTPMemoryManager *mgr) const;
00092         bool IsSameAddress(const RTPAddress *addr) const;
00093         bool IsFromSameHost(const RTPAddress *addr) const;
00094 #ifdef RTPDEBUG
00095         std::string GetAddressString() const;
00096 #endif // RTPDEBUG
00097 private:
00098         in6_addr ip;
00099         uint16_t port;
00100 };
00101 
00102 #endif // RTP_SUPPORT_IPV6
00103 
00104 #endif // RTPIPV6ADDRESS_H
00105 

Generated on Thu Feb 8 16:22:05 2007 for jrtplib by  doxygen 1.5.1