rtpipv4address.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 RTPIPV4ADDRESS_H
00038 
00039 #define RTPIPV4ADDRESS_H
00040 
00041 #include "rtpconfig.h"
00042 #include "rtpaddress.h"
00043 #include "rtptypes.h"
00044 
00045 class RTPMemoryManager;
00046 
00053 class RTPIPv4Address : public RTPAddress
00054 {
00055 public:
00057         RTPIPv4Address(uint32_t ip = 0, uint16_t port = 0):RTPAddress(IPv4Address)                                              { RTPIPv4Address::ip = ip; RTPIPv4Address::port = port; }
00058         
00060         RTPIPv4Address(const uint8_t ip[4],uint16_t port = 0):RTPAddress(IPv4Address)                                   { RTPIPv4Address::ip = (uint32_t)ip[3]; RTPIPv4Address::ip |= (((uint32_t)ip[2])<<8); RTPIPv4Address::ip |= (((uint32_t)ip[1])<<16); RTPIPv4Address::ip |= (((uint32_t)ip[0])<<24); RTPIPv4Address::port = port; }
00061         ~RTPIPv4Address()                                                                                                                                                               { }
00062 
00064         void SetIP(uint32_t ip)                                                                                                                                                 { RTPIPv4Address::ip = ip; }
00065 
00067         void SetIP(const uint8_t ip[4])                                                                                                                                 { RTPIPv4Address::ip = (uint32_t)ip[3]; RTPIPv4Address::ip |= (((uint32_t)ip[2])<<8); RTPIPv4Address::ip |= (((uint32_t)ip[1])<<16); RTPIPv4Address::ip |= (((uint32_t)ip[0])<<24); }
00068 
00070         void SetPort(uint16_t port)                                                                                                                                             { RTPIPv4Address::port = port; }
00071 
00073         uint32_t GetIP() const                                                                                                                                                  { return ip; }
00074 
00076         uint16_t GetPort() const                                                                                                                                                { return port; }
00077 
00078         RTPAddress *CreateCopy(RTPMemoryManager *mgr) const;
00079         bool IsSameAddress(const RTPAddress *addr) const;
00080         bool IsFromSameHost(const RTPAddress *addr) const;
00081 #ifdef RTPDEBUG
00082         std::string GetAddressString() const;
00083 #endif // RTPDEBUG
00084 private:
00085         uint32_t ip;
00086         uint16_t port;
00087 };
00088 
00089 #endif // RTPIPV4ADDRESS_H
00090 

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