include/ortp/stun_udp.h

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

Generated on Thu Apr 5 18:59:20 2007 for oRTP by  doxygen 1.5.1