stun_udp.h

Go to the documentation of this file.
00001 #ifndef udp_h
00002 #define udp_h
00003 
00004 
00005 #if defined __MACH__ && not defined __APPLE__
00006 typedef int socklen_t;
00007 #endif
00008 
00009 #include <errno.h>
00010 
00011 #ifdef WIN32
00012 
00013 #include <winsock2.h>
00014 #include <io.h>
00015 
00016 typedef int socklen_t;
00017 typedef SOCKET Socket;
00018 
00019 #define EWOULDBLOCK             WSAEWOULDBLOCK
00020 #define EINPROGRESS             WSAEINPROGRESS
00021 #define EALREADY                WSAEALREADY
00022 #define ENOTSOCK                WSAENOTSOCK
00023 #define EDESTADDRREQ            WSAEDESTADDRREQ
00024 #define EMSGSIZE                WSAEMSGSIZE
00025 #define EPROTOTYPE              WSAEPROTOTYPE
00026 #define ENOPROTOOPT             WSAENOPROTOOPT
00027 #define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
00028 #define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
00029 #define EOPNOTSUPP              WSAEOPNOTSUPP
00030 #define EPFNOSUPPORT            WSAEPFNOSUPPORT
00031 #define EAFNOSUPPORT            WSAEAFNOSUPPORT
00032 #define EADDRINUSE              WSAEADDRINUSE
00033 #define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
00034 #define ENETDOWN                WSAENETDOWN
00035 #define ENETUNREACH             WSAENETUNREACH
00036 #define ENETRESET               WSAENETRESET
00037 #define ECONNABORTED            WSAECONNABORTED
00038 #define ECONNRESET              WSAECONNRESET
00039 #define ENOBUFS                 WSAENOBUFS
00040 #define EISCONN                 WSAEISCONN
00041 #define ENOTCONN                WSAENOTCONN
00042 #define ESHUTDOWN               WSAESHUTDOWN
00043 #define ETOOMANYREFS            WSAETOOMANYREFS
00044 #define ETIMEDOUT               WSAETIMEDOUT
00045 #define ECONNREFUSED            WSAECONNREFUSED
00046 #define ELOOP                   WSAELOOP
00047 #define EHOSTDOWN               WSAEHOSTDOWN
00048 #define EHOSTUNREACH            WSAEHOSTUNREACH
00049 #define EPROCLIM                WSAEPROCLIM
00050 #define EUSERS                  WSAEUSERS
00051 #define EDQUOT                  WSAEDQUOT
00052 #define ESTALE                  WSAESTALE
00053 #define EREMOTE                 WSAEREMOTE
00054 
00055 typedef LONGLONG Int64;
00056 inline int getErrno() { return WSAGetLastError(); }
00057 static const Socket STUN_INVALID_SOCKET = -1;
00058 static const int STUN_SOCKET_ERROR = -1;
00059 inline int stunclosesocket( Socket fd ) { return closesocket(fd); };
00060 
00061 #else
00062 
00063 typedef int Socket;
00064 static const Socket STUN_INVALID_SOCKET = -1;
00065 static const int STUN_SOCKET_ERROR = -1;
00066 
00067 inline int stunclosesocket( Socket fd ) { return close(fd); };
00068 
00069 inline int getErrno() { return errno; }
00070 
00071 #define WSANOTINITIALISED  EPROTONOSUPPORT
00072 
00073 #endif
00074 
00078 Socket
00079 openPort( unsigned short port, unsigned int interfaceIp,
00080           bool verbose);
00081 
00082 
00084 bool
00085 getMessage( Socket fd, char* buf, int* len,
00086             unsigned int* srcIp, unsigned short* srcPort,
00087             bool verbose);
00088 
00089 
00091 bool
00092 sendMessage( Socket fd, char* msg, int len,
00093              unsigned int dstIp, unsigned short dstPort,
00094              bool verbose);
00095 
00096 
00098 void
00099 initNetwork();
00100 
00101 
00102 /* ====================================================================
00103  * The Vovida Software License, Version 1.0
00104  *
00105  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00106  *
00107  * Redistribution and use in source and binary forms, with or without
00108  * modification, are permitted provided that the following conditions
00109  * are met:
00110  *
00111  * 1. Redistributions of source code must retain the above copyright
00112  *    notice, this list of conditions and the following disclaimer.
00113  *
00114  * 2. Redistributions in binary form must reproduce the above copyright
00115  *    notice, this list of conditions and the following disclaimer in
00116  *    the documentation and/or other materials provided with the
00117  *    distribution.
00118  *
00119  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00120  *    and "Vovida Open Communication Application Library (VOCAL)" must
00121  *    not be used to endorse or promote products derived from this
00122  *    software without prior written permission. For written
00123  *    permission, please contact vocal@vovida.org.
00124  *
00125  * 4. Products derived from this software may not be called "VOCAL", nor
00126  *    may "VOCAL" appear in their name, without prior written
00127  *    permission of Vovida Networks, Inc.
00128  *
00129  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00130  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00131  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00132  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00133  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00134  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00135  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00136  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00137  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00138  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00139  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00140  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00141  * DAMAGE.
00142  *
00143  * ====================================================================
00144  *
00145  * This software consists of voluntary contributions made by Vovida
00146  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00147  * Inc.  For more information on Vovida Networks, Inc., please see
00148  * <http://www.vovida.org/>.
00149  *
00150  */
00151 
00152 // Local Variables:
00153 // mode:c++
00154 // c-file-style:"ellemtel"
00155 // c-file-offsets:((case-label . +))
00156 // indent-tabs-mode:nil
00157 // End:
00158 
00159 #endif
Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3