oRTP
0.20.0
|
00001 /* 00002 The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack. 00003 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 /* ==================================================================== 00021 * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. 00022 * 00023 */ 00024 00025 #ifndef __STUN_UDP_H__ 00026 #define __STUN_UDP_H__ 00027 00028 #ifndef __cplusplus 00029 //#define bool int 00030 //#define false 0 00031 //#define true 1 00032 #endif 00033 00034 #ifdef __MACH__ 00035 #include <sys/socket.h> 00036 #ifndef _SOCKLEN_T 00037 typedef int socklen_t; 00038 #endif 00039 #endif 00040 00041 #include <ortp/port.h> 00042 00043 #if !defined(_WIN32_WCE) 00044 #include <errno.h> 00045 #endif 00046 00047 #if defined(WIN32) || defined(_WIN32_WCE) 00048 #define snprintf _snprintf 00049 00050 #include <winsock2.h> 00051 /* #include <io.h> */ 00052 00053 typedef int socklen_t; 00054 typedef SOCKET Socket; 00055 00056 #ifndef EWOULDBLOCK 00057 #define EWOULDBLOCK WSAEWOULDBLOCK 00058 #endif 00059 #ifndef EINPROGRESS 00060 #define EINPROGRESS WSAEINPROGRESS 00061 #endif 00062 #ifndef EALREADY 00063 #define EALREADY WSAEALREADY 00064 #endif 00065 #ifndef ENOTSOCK 00066 #define ENOTSOCK WSAENOTSOCK 00067 #endif 00068 #ifndef EDESTADDRREQ 00069 #define EDESTADDRREQ WSAEDESTADDRREQ 00070 #endif 00071 #ifndef EMSGSIZE 00072 #define EMSGSIZE WSAEMSGSIZE 00073 #endif 00074 #ifndef EPROTOTYPE 00075 #define EPROTOTYPE WSAEPROTOTYPE 00076 #endif 00077 #ifndef ENOPROTOOPT 00078 #define ENOPROTOOPT WSAENOPROTOOPT 00079 #endif 00080 #ifndef EPROTONOSUPPORT 00081 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT 00082 #endif 00083 #ifndef ESOCKTNOSUPPORT 00084 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT 00085 #endif 00086 #ifndef EOPNOTSUPP 00087 #define EOPNOTSUPP WSAEOPNOTSUPP 00088 #endif 00089 #ifndef EPFNOSUPPORT 00090 #define EPFNOSUPPORT WSAEPFNOSUPPORT 00091 #endif 00092 #ifndef EAFNOSUPPORT 00093 #define EAFNOSUPPORT WSAEAFNOSUPPORT 00094 #endif 00095 #ifndef EADDRINUSE 00096 #define EADDRINUSE WSAEADDRINUSE 00097 #endif 00098 #ifndef EADDRNOTAVAIL 00099 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL 00100 #endif 00101 #ifndef ENETDOWN 00102 #define ENETDOWN WSAENETDOWN 00103 #endif 00104 #ifndef ENETUNREACH 00105 #define ENETUNREACH WSAENETUNREACH 00106 #endif 00107 #ifndef ENETRESET 00108 #define ENETRESET WSAENETRESET 00109 #endif 00110 #ifndef ECONNABORTED 00111 #define ECONNABORTED WSAECONNABORTED 00112 #endif 00113 #ifndef ECONNRESET 00114 #define ECONNRESET WSAECONNRESET 00115 #endif 00116 #ifndef ENOBUFS 00117 #define ENOBUFS WSAENOBUFS 00118 #endif 00119 #ifndef EISCONN 00120 #define EISCONN WSAEISCONN 00121 #endif 00122 #ifndef ENOTCONN 00123 #define ENOTCONN WSAENOTCONN 00124 #endif 00125 #ifndef ESHUTDOWN 00126 #define ESHUTDOWN WSAESHUTDOWN 00127 #endif 00128 #ifndef ETOOMANYREFS 00129 #define ETOOMANYREFS WSAETOOMANYREFS 00130 #endif 00131 #ifndef ETIMEDOUT 00132 #define ETIMEDOUT WSAETIMEDOUT 00133 #endif 00134 #ifndef ECONNREFUSED 00135 #define ECONNREFUSED WSAECONNREFUSED 00136 #endif 00137 #ifndef ELOOP 00138 #define ELOOP WSAELOOP 00139 #endif 00140 #ifndef EHOSTDOWN 00141 #define EHOSTDOWN WSAEHOSTDOWN 00142 #endif 00143 #ifndef EHOSTUNREACH 00144 #define EHOSTUNREACH WSAEHOSTUNREACH 00145 #endif 00146 #ifndef EPROCLIM 00147 #define EPROCLIM WSAEPROCLIM 00148 #endif 00149 #ifndef EUSERS 00150 #define EUSERS WSAEUSERS 00151 #endif 00152 #ifndef EDQUOT 00153 #define EDQUOT WSAEDQUOT 00154 #endif 00155 #ifndef ESTALE 00156 #define ESTALE WSAESTALE 00157 #endif 00158 #ifndef EREMOTE 00159 #define EREMOTE WSAEREMOTE 00160 #endif 00161 typedef LONGLONG Int64; 00162 00163 #else 00164 00165 typedef int Socket; 00166 #ifndef INVALID_SOCKET 00167 #define INVALID_SOCKET -1 00168 #endif 00169 #ifndef SOCKET_ERROR 00170 #define SOCKET_ERROR -1 00171 #endif 00172 00173 #define closesocket(fd) close(fd) 00174 00175 #define WSANOTINITIALISED EPROTONOSUPPORT 00176 00177 #endif 00178 00179 #ifdef __cplusplus 00180 extern "C"{ 00181 #endif 00182 00183 int getErrno(void); 00184 00185 /* Open a UDP socket to receive on the given port - if port is 0, pick a a 00186 port, if interfaceIp!=0 then use ONLY the interface specified instead of 00187 all of them */ 00188 Socket 00189 openPort( unsigned short port, unsigned int interfaceIp); 00190 00191 00192 /* recive a UDP message */ 00193 bool_t 00194 getMessage( Socket fd, char* buf, int* len, 00195 unsigned int* srcIp, unsigned short* srcPort); 00196 00197 00198 /* send a UDP message */ 00199 bool_t 00200 sendMessage( Socket fd, char* msg, int len, 00201 unsigned int dstIp, unsigned short dstPort); 00202 00203 00204 /* set up network - does nothing in unix but needed for windows */ 00205 void 00206 initNetwork(void); 00207 00208 #ifdef __cplusplus 00209 } 00210 #endif 00211 00212 #endif