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  *  * 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 #define EWOULDBLOCK             WSAEWOULDBLOCK
00057 #define EINPROGRESS             WSAEINPROGRESS
00058 #define EALREADY                WSAEALREADY
00059 #define ENOTSOCK                WSAENOTSOCK
00060 #define EDESTADDRREQ            WSAEDESTADDRREQ
00061 #define EMSGSIZE                WSAEMSGSIZE
00062 #define EPROTOTYPE              WSAEPROTOTYPE
00063 #define ENOPROTOOPT             WSAENOPROTOOPT
00064 #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
00065 #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
00066 #define EOPNOTSUPP              WSAEOPNOTSUPP
00067 #define EPFNOSUPPORT            WSAEPFNOSUPPORT
00068 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
00069 #define EADDRINUSE              WSAEADDRINUSE
00070 #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
00071 #define ENETDOWN                WSAENETDOWN
00072 #define ENETUNREACH             WSAENETUNREACH
00073 #define ENETRESET               WSAENETRESET
00074 #define ECONNABORTED            WSAECONNABORTED
00075 #define ECONNRESET              WSAECONNRESET
00076 #define ENOBUFS                 WSAENOBUFS
00077 #define EISCONN                 WSAEISCONN
00078 #define ENOTCONN                WSAENOTCONN
00079 #define ESHUTDOWN               WSAESHUTDOWN
00080 #define ETOOMANYREFS            WSAETOOMANYREFS
00081 #define ETIMEDOUT               WSAETIMEDOUT
00082 #define ECONNREFUSED            WSAECONNREFUSED
00083 #define ELOOP                   WSAELOOP
00084 #define EHOSTDOWN               WSAEHOSTDOWN
00085 #define EHOSTUNREACH            WSAEHOSTUNREACH
00086 #define EPROCLIM                WSAEPROCLIM
00087 #define EUSERS                  WSAEUSERS
00088 #define EDQUOT                  WSAEDQUOT
00089 #define ESTALE                  WSAESTALE
00090 #define EREMOTE                 WSAEREMOTE
00091 
00092 typedef LONGLONG Int64; 
00093 
00094 #else
00095 
00096 typedef int Socket;
00097 #define INVALID_SOCKET -1
00098 #define SOCKET_ERROR -1
00099 
00100 #define closesocket(fd) close(fd)
00101 
00102 #define WSANOTINITIALISED  EPROTONOSUPPORT
00103 
00104 #endif
00105 
00106 #ifdef __cplusplus
00107 extern "C"{
00108 #endif
00109 
00110 int getErrno(void);
00111 
00112 /* Open a UDP socket to receive on the given port - if port is 0, pick a a
00113    port, if interfaceIp!=0 then use ONLY the interface specified instead of
00114    all of them  */
00115 Socket
00116 openPort( unsigned short port, unsigned int interfaceIp,
00117           bool_t verbose);
00118 
00119 
00120 /* recive a UDP message */
00121 bool_t 
00122 getMessage( Socket fd, char* buf, int* len,
00123             unsigned int* srcIp, unsigned short* srcPort,
00124             bool_t verbose);
00125 
00126 
00127 /* send a UDP message */
00128 bool_t 
00129 sendMessage( Socket fd, char* msg, int len, 
00130              unsigned int dstIp, unsigned short dstPort,
00131              bool_t verbose);
00132 
00133 
00134 /* set up network - does nothing in unix but needed for windows */
00135 void
00136 initNetwork(void);
00137 
00138 #ifdef __cplusplus
00139 }
00140 #endif
00141 
00142 #endif

Generated on Tue Feb 5 21:35:36 2008 for oRTP by  doxygen 1.5.4