Stun Server  Compliant with the latest RFCs including 5389, 5769, and 5780
discover the local host's own external IP address
commonincludes.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2011 John Selbie
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 
18 #ifndef STUNSERVER_COMMON_COMMONINCLUDES_H
19 #define STUNSERVER_COMMON_COMMONINCLUDES_H
20 
21 // Fix for Lion (http://www.opensource.apple.com/source/xnu/xnu-1699.24.8/bsd/netinet6/in6.h)
22 #define __APPLE_USE_RFC_3542
23 
24 
25 #if __linux || __linux__ || __gnu_linux__ || linux
26 #define IS_LINUX
27 #endif
28 
29 // standard system includes
30 #include <sys/types.h>
31 #include <sys/socket.h>
32 #include <netinet/in.h>
33 #include <unistd.h>
34 #include <arpa/inet.h>
35 #include <netdb.h>
36 #include <unistd.h>
37 #include <signal.h>
38 #include <stdio.h>
39 #include <string.h>
40 #include <fcntl.h>
41 #include <errno.h>
42 #include <sys/time.h>
43 #include <stdlib.h>
44 #include <memory.h>
45 #include <ifaddrs.h>
46 #include <net/if.h>
47 #include <stdarg.h>
48 #include <math.h>
49 #include <sys/termios.h>
50 
51 #include <boost/shared_ptr.hpp>
52 #include <boost/scoped_array.hpp>
53 #include <boost/scoped_ptr.hpp>
54 
55 #include <map>
56 #include <vector>
57 #include <list>
58 #include <string>
59 
60 
61 #ifdef IS_LINUX
62 #define HAS_EPOLL
63 #include <sys/epoll.h>
64 #endif
65 
66 #include <poll.h>
67 
68 
69 #include <pthread.h>
70 
71 
72 #if !defined(DEBUG) && !defined(NDEBUG)
73 You_Didnt_Define_DEBUG_Or_NDEBUG g_compilererror[-1];
74 #endif
75 
76 
77 #if defined(DEBUG)
78 
79 #ifndef BOOST_ENABLE_ASSERT_HANDLER
80 #define BOOST_ENABLE_ASSERT_HANDLER
81 #endif
82 
83 #else
84 
85 #ifndef BOOST_DISABLE_ASSERTS
86 #define BOOST_DISABLE_ASSERTS
87 #endif
88 
89 #endif
90 #include <boost/assert.hpp>
91 
92 #ifdef ASSERT
93 #undef ASSERT
94 #endif
95 
96 #ifdef VERIFY
97 #undef VERIFY
98 #endif
99 
100 
101 #ifdef ASSERT_MSG
102 #undef ASSERT_MSG
103 #endif
104 
105 // older versions of BOOST don't have BOOST_VERIFY
106 #ifndef BOOST_VERIFY
107 #define BOOST_VERIFY(expr) ((void)(expr))
108 #endif
109 
110 #define ASSERT(expr) BOOST_ASSERT(expr)
111 #define VERIFY(expr) BOOST_VERIFY(expr)
112 #define ASSERTMSG(expr, msg) BOOST_ASSERT_MSG (expr, msg)
113 
114 #define ARRAYSIZE(arr) (sizeof(arr)/sizeof(*arr))
115 
116 inline void cta_noop(const char* psz)
117 {
118  ;
119 }
120 
121 #define COMPILE_TIME_ASSERT(x) {char name$$[(x)?1:-1]; cta_noop(name$$);}
122 
123 #ifndef UNREFERENCED_VARIABLE
124 #define UNREFERENCED_VARIABLE(unrefparam) ((void)unrefparam)
125 #endif
126 
127 // --------------------------------------------
128 
129 #include "hresult.h"
130 #include "chkmacros.h"
131 
132 
133 // ---------------------------------------------
134 // Unless there's good reason, put additional header files after hresult.h and chkmacros.h
135 #include "refcountobject.h"
136 #include "objectfactory.h"
137 
138 
139 
140 #include "logger.h"
141 
142 
143 
144 
145 #endif
You_Didnt_Define_DEBUG_Or_NDEBUG g_compilererror[-1]
void cta_noop(const char *psz)