pnat.h

Go to the documentation of this file.
00001 /*
00002  * pnat.h
00003  *
00004  * NAT Strategy support for Portable Windows Library.
00005  *
00006  * Virteos is a Trade Mark of ISVO (Asia) Pte Ltd.
00007  *
00008  * Copyright (c) 2004 ISVO (Asia) Pte Ltd. All Rights Reserved.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  *
00021  * The Original Code is derived from and used in conjunction with the 
00022  * OpenH323 Project (www.openh323.org/)
00023  *
00024  * The Initial Developer of the Original Code is ISVO (Asia) Pte Ltd.
00025  *
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: pnat.h,v $
00030  * Revision 1.3.2.1  2006/01/27 03:43:24  csoutheren
00031  * Backported changes to CVS head into Phobos
00032  *
00033  * Revision 1.4  2006/01/26 03:23:41  shorne
00034  * Fix compile error when merging code
00035  *
00036  * Revision 1.3  2005/11/30 12:47:37  csoutheren
00037  * Removed tabs, reformatted some code, and changed tags for Doxygen
00038  *
00039  * Revision 1.2  2005/07/13 11:15:14  csoutheren
00040  * Backported NAT abstraction files from isvo branch
00041  *
00042  * Revision 1.1.2.1  2005/04/25 13:23:19  shorne
00043  * Initial version
00044  *
00045  *
00046 */
00047 
00048 #include <ptlib.h>
00049 #include <ptlib/sockets.h>
00050 
00051 #ifndef P_NATMETHOD
00052 #define P_NATMETHOD
00053 
00061 class PNatMethod  : public PObject
00062 {
00063   PCLASSINFO(PNatMethod,PObject);
00064 
00065 public:
00066 
00071   PNatMethod();
00072 
00075   ~PNatMethod();
00077 
00080 
00084    virtual BOOL GetExternalAddress(
00085       PIPSocket::Address & externalAddress, 
00086       const PTimeInterval & maxAge = 1000   
00087    ) =0;
00088 
00092    virtual BOOL CreateSocketPair(
00093       PUDPSocket * & socket1,
00094       PUDPSocket * & socket2
00095    ) =0;
00096 
00104    virtual BOOL IsAvailable() { return FALSE; };
00105 
00116    virtual void SetPortRanges(
00117       WORD portBase,          
00118       WORD portMax = 0,       
00119       WORD portPairBase = 0,  
00120       WORD portPairMax = 0    
00121    );
00123 
00124 protected:
00125   struct PortInfo {
00126       PMutex mutex;
00127       WORD   basePort;
00128       WORD   maxPort;
00129       WORD   currentPort;
00130     } singlePortInfo, pairedPortInfo;
00131 
00132 };
00133 
00135 
00136 PLIST(PNatList, PNatMethod);
00137 
00139 
00145 class PNatStrategy : public PObject
00146 {
00147   PCLASSINFO(PNatStrategy,PObject);
00148 
00149 public :
00150 
00155   PNatStrategy();
00156 
00159   ~PNatStrategy();
00161 
00169   void AddMethod(PNatMethod * method);
00170 
00176   PNatMethod * GetMethod();
00177 
00188     void SetPortRanges(
00189       WORD portBase,          
00190       WORD portMax = 0,       
00191       WORD portPairBase = 0,  
00192       WORD portPairMax = 0    
00193     );
00195 
00196 private:
00197   PNatList natlist;
00198 };
00199 
00200 #endif

Generated on Fri Sep 21 14:40:11 2007 for PWLib by  doxygen 1.5.3