00001 /* 00002 * udpsock.h 00003 * 00004 * User Datagram Protocol socket I/O channel class. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-1998 Equivalence Pty. Ltd. 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 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 00025 * All Rights Reserved. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Log: udpsock.h,v $ 00030 * Revision 1.28 2005/11/30 12:47:38 csoutheren 00031 * Removed tabs, reformatted some code, and changed tags for Doxygen 00032 * 00033 * Revision 1.27 2005/11/25 03:43:47 csoutheren 00034 * Fixed function argument comments to be compatible with Doxygen 00035 * 00036 * Revision 1.26 2005/11/21 11:49:36 shorne 00037 * Changed disableQos to disableGQoS to better reflect what it does 00038 * 00039 * Revision 1.25 2005/07/13 12:08:09 csoutheren 00040 * Fixed QoS patches to be more consistent with PWLib style and to allow Unix compatibility 00041 * 00042 * Revision 1.24 2005/07/13 11:48:53 csoutheren 00043 * Backported QOS changes from isvo branch 00044 * 00045 * Revision 1.23.10.1 2005/04/25 13:39:28 shorne 00046 * Extended QoS support for per-call negotiation 00047 * 00048 * Revision 1.23 2003/10/27 04:06:13 csoutheren 00049 * Added code to allow compilation of new QoS code on Unix 00050 * 00051 * Revision 1.22 2003/10/27 03:22:44 csoutheren 00052 * Added handling for QoS 00053 * Thanks to Henry Harrison of AliceStreet 00054 * 00055 * Revision 1.21 2003/09/17 05:41:59 csoutheren 00056 * Removed recursive includes 00057 * 00058 * Revision 1.20 2003/09/17 01:18:02 csoutheren 00059 * Removed recursive include file system and removed all references 00060 * to deprecated coooperative threading support 00061 * 00062 * Revision 1.19 2002/10/08 12:41:51 robertj 00063 * Changed for IPv6 support, thanks Sébastien Josset. 00064 * 00065 * Revision 1.18 2002/09/16 01:08:59 robertj 00066 * Added #define so can select if #pragma interface/implementation is used on 00067 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00068 * 00069 * Revision 1.17 2001/05/22 12:49:32 robertj 00070 * Did some seriously wierd rewrite of platform headers to eliminate the 00071 * stupid GNU compiler warning about braces not matching. 00072 * 00073 * Revision 1.16 1999/08/27 08:18:52 robertj 00074 * Added ability to get the host/port of the the last packet read/written to UDP socket. 00075 * 00076 * Revision 1.15 1999/03/09 02:59:51 robertj 00077 * Changed comments to doc++ compatible documentation. 00078 * 00079 * Revision 1.14 1999/02/16 08:11:17 robertj 00080 * MSVC 6.0 compatibility changes. 00081 * 00082 * Revision 1.13 1998/09/23 06:21:47 robertj 00083 * Added open source copyright license. 00084 * 00085 * Revision 1.12 1997/06/06 10:54:11 craigs 00086 * Added overrides and new functions for connectionless Writes 00087 * 00088 * Revision 1.11 1996/09/14 13:09:43 robertj 00089 * Major upgrade: 00090 * rearranged sockets to help support IPX. 00091 * added indirect channel class and moved all protocols to descend from it, 00092 * separating the protocol from the low level byte transport. 00093 * 00094 * Revision 1.10 1996/05/15 10:19:15 robertj 00095 * Added ICMP protocol socket, getting common ancestor to UDP. 00096 * 00097 * Revision 1.9 1996/03/03 07:38:00 robertj 00098 * Added Reusability clause to the Listen() function on sockets. 00099 * 00100 * Revision 1.8 1995/12/10 11:44:45 robertj 00101 * Numerous fixes for sockets. 00102 * 00103 * Revision 1.7 1995/06/17 11:13:41 robertj 00104 * Documentation update. 00105 * 00106 * Revision 1.6 1995/06/17 00:48:01 robertj 00107 * Implementation. 00108 * 00109 * Revision 1.5 1995/01/03 09:36:24 robertj 00110 * Documentation. 00111 * 00112 * Revision 1.4 1994/08/23 11:32:52 robertj 00113 * Oops 00114 * 00115 * Revision 1.3 1994/08/22 00:46:48 robertj 00116 * Added pragma fro GNU C++ compiler. 00117 * 00118 * Revision 1.2 1994/07/25 03:36:03 robertj 00119 * Added sockets to common, normalising to same comment standard. 00120 * 00121 */ 00122 00123 #ifndef _PUDPSOCKET 00124 #define _PUDPSOCKET 00125 00126 #ifdef P_USE_PRAGMA 00127 #pragma interface 00128 #endif 00129 00130 #include <ptlib/qos.h> 00131 00135 class PUDPSocket : public PIPDatagramSocket 00136 { 00137 PCLASSINFO(PUDPSocket, PIPDatagramSocket); 00138 00139 public: 00145 PUDPSocket( 00146 WORD port = 0 00147 ); 00148 PUDPSocket( 00149 PQoS * qos, 00150 WORD port = 0 00151 ); 00152 PUDPSocket( 00153 const PString & service, 00154 PQoS * qos = NULL 00155 ); 00156 PUDPSocket( 00157 const PString & address, 00158 WORD port 00159 ); 00160 PUDPSocket( 00161 const PString & address, 00162 const PString & service 00163 ); 00165 00170 BOOL Read( 00171 void * buf, 00172 PINDEX len 00173 ); 00174 00177 BOOL Write( 00178 const void * buf, 00179 PINDEX len 00180 ); 00181 00184 BOOL Connect( 00185 const PString & address 00186 ); 00188 00193 void SetSendAddress( 00194 const Address & address, 00195 WORD port 00196 ); 00197 00200 void GetSendAddress( 00201 Address & address, 00202 WORD & port 00203 ); 00204 00205 00208 virtual BOOL ModifyQoSSpec( 00209 PQoS * qos 00210 ); 00211 00212 #if P_HAS_QOS 00213 00215 virtual PQoS & GetQoSSpec(); 00216 #endif 00217 00221 void GetLastReceiveAddress( 00222 Address & address, 00223 WORD & port 00224 ); 00225 00228 static BOOL SupportQoS(const PIPSocket::Address & address); 00229 00232 static void EnableGQoS(); 00234 00235 protected: 00236 // Open an IPv4 socket (for backward compatibility) 00237 virtual BOOL OpenSocket(); 00238 00239 // Open an IPv4 or IPv6 socket 00240 virtual BOOL OpenSocket( 00241 int ipAdressFamily 00242 ); 00243 00244 // Create a QOS-enabled socket 00245 virtual int OpenSocketGQOS(int af, int type, int proto); 00246 00247 // Modify the QOS settings 00248 virtual BOOL ApplyQoS(); 00249 00250 virtual const char * GetProtocolName() const; 00251 00252 Address sendAddress; 00253 WORD sendPort; 00254 00255 Address lastReceiveAddress; 00256 WORD lastReceivePort; 00257 00258 PQoS qosSpec; 00259 00260 // Include platform dependent part of class 00261 #ifdef _WIN32 00262 #include "msos/ptlib/udpsock.h" 00263 #else 00264 #include "unix/ptlib/udpsock.h" 00265 #endif 00266 }; 00267 00268 #if P_HAS_QOS 00269 00270 #ifdef _WIN32 00271 #include <winbase.h> 00272 #include <winreg.h> 00273 00274 #ifndef _WIN32_WCE 00275 00276 class PWinQoS : public PObject 00277 { 00278 PCLASSINFO(PWinQoS,PObject); 00279 00280 public: 00281 PWinQoS(PQoS & pqos, struct sockaddr * to, char * inBuf, DWORD & bufLen); 00282 ~PWinQoS(); 00283 00284 //QOS qos; 00285 //QOS_DESTADDR qosdestaddr; 00286 protected: 00287 sockaddr * sa; 00288 }; 00289 00290 #endif // _WIN32_WCE 00291 #endif // _WIN32 00292 #endif // P_HAS_QOS 00293 00294 00295 #endif 00296 00297 00298 // End Of File ///////////////////////////////////////////////////////////////