1 /* 2 * libZRTP SDK library, implements the ZRTP secure VoIP protocol. 3 * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. 4 * Contact: http://philzimmermann.com 5 * For licensing and other legal details, see the file zrtp_legal.c. 6 * 7 * Viktor Krykun <v.krikun at zfoneproject.com> 8 */ 9 10 #ifndef __ZRTP_CONFIG_H__ 11 #define __ZRTP_CONFIG_H__ 12 13 #include "zrtp_config_user.h" 14 15 /* 16 * ZRTP PLATFORM DETECTION 17 * If platworm is not specified manually in zrtp_config_user.h - try to detect it aytomatically 18 */ 19 #if !defined(ZRTP_PLATFORM) 20 # if defined(ANDROID_NDK) 21 # define ZRTP_PLATFORM ZP_ANDROID 22 # elif defined(__FreeBSD__) || defined(__DragonFly__) 23 # define ZRTP_PLATFORM ZP_BSD 24 # elif defined(linux) || defined(__linux__) || defined(__linux) 25 # include <linux/version.h> 26 # define ZRTP_PLATFORM ZP_LINUX 27 # elif defined(__MACOSX__) || defined (__APPLE__) || defined (__MACH__) 28 # define ZRTP_PLATFORM ZP_DARWIN 29 # elif defined(_WIN32_WCE) || defined(UNDER_CE) 30 # include <windef.h> 31 # define ZRTP_PLATFORM ZP_WINCE 32 # elif defined(__SYMBIAN32__) 33 # define ZRTP_PLATFORM ZP_SYMBIAN 34 # elif defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(WIN32) || defined(__TOS_WIN__) 35 # if defined(__BUILDMACHINE__) && (__BUILDMACHINE__ == WinDDK) 36 # define ZRTP_PLATFORM ZP_WIN32_KERNEL 37 # elif defined(_WIN64) 38 # define ZRTP_PLATFORM ZP_WIN32 39 # else 40 # define ZRTP_PLATFORM ZP_WIN32 41 # endif 42 # endif 43 #endif 44 45 #if ZRTP_PLATFORM == ZP_ANDROID 46 # include "zrtp_config_android.h" 47 #elif (ZRTP_PLATFORM == ZP_LINUX) || (ZRTP_PLATFORM == ZP_DARWIN) || (ZRTP_PLATFORM == ZP_BSD) || defined(ZRTP_AUTOMAKE) 48 # include "zrtp_config_unix.h" 49 #elif (ZRTP_PLATFORM == ZP_WIN32) || (ZRTP_PLATFORM == ZP_WIN32_KERNEL) || (ZRTP_PLATFORM == ZP_WINCE) 50 # include "zrtp_config_win.h" 51 #elif (ZRTP_PLATFORM == ZP_SYMBIAN) 52 # include "zrtp_config_symbian.h" 53 #endif 54 55 #if !defined(ZRTP_PLATFORM) 56 # error "Libzrtp can't detect software platform: use manual setup in zrtp_config_user.h" 57 #endif 58 59 #if ZRTP_HAVE_LINUX_VERSION_H == 1 60 #include <linux/version.h> 61 #endif 62 #if ZRTP_HAVE_ASM_TYPES_H == 1 63 #include <asm/types.h> 64 #endif 65 66 /* 67 * ZRTP BYTEORDER DETECTION 68 * If the byte order is not specified manually in zrtp_config_user.h - try to detect it automatically 69 */ 70 #if !defined(ZRTP_BYTE_ORDER) 71 72 #if defined(_i386_) || defined(i_386_) || defined(_X86_) || defined(x86) || defined(__i386__) || \ 73 defined(__i386) || defined(_M_IX86) || defined(__I86__) 74 /* 75 * Generic i386 processor family, little-endian 76 */ 77 #define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN 78 79 #elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_AMD64_) 80 /* 81 * AMD 64bit processor, little endian 82 */ 83 #define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN 84 85 #elif defined( __sparc__) || defined(__sparc) 86 /* 87 * Sun Sparc, big endian 88 */ 89 #define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN 90 91 #elif defined(__AARCH64EB__) 92 /* 93 * aarch64, big endian 94 */ 95 #define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN 96 97 #elif defined(ARM) || defined(_ARM_) || defined(ARMV4) || defined(__arm__) || defined(__AARCH64EL__) 98 /* 99 * ARM, default to little endian 100 */ 101 #define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN 102 103 #elif defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || defined(__ppc__) || \ 104 defined(_M_PPC) || defined(_ARCH_PPC) 105 /* 106 * PowerPC, big endian 107 */ 108 #define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN 109 110 #elif defined(__MIPSEB__) 111 /* 112 * mips, big endian 113 */ 114 #define ZRTP_BYTE_ORDER ZBO_BIG_ENDIAN 115 116 #elif defined(__MIPSEL__) 117 /* 118 * mips, little endian 119 */ 120 #define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN 121 122 #elif defined(__e2k__) 123 /* 124 * Elbrus, little endian 125 */ 126 #define ZRTP_BYTE_ORDER ZBO_LITTLE_ENDIAN 127 128 #endif /* Automatic byte order detection */ 129 130 #endif 131 132 #if !defined(ZRTP_BYTE_ORDER) 133 # error "Libzrtp can't detect byte order: use manual setup in zrtp_config_user.h" 134 #endif 135 136 137 /* 138 * Define Unaligned structure for target platform 139 */ 140 #if (ZRTP_PLATFORM == ZP_WINCE) 141 # define ZRTP_UNALIGNED(type) UNALIGNED type 142 #else 143 # define ZRTP_UNALIGNED(type) type 144 #endif 145 146 147 /* 148 * Define basic literal types for libzrtp 149 * We use this definitions in SRTP, AES and Hash implementation 150 */ 151 #if (ZRTP_PLATFORM != ZP_WIN32_KERNEL) 152 # if ZRTP_HAVE_STDLIB_H == 1 153 # include <stdlib.h> 154 # endif 155 # if ZRTP_HAVE_STDINT_H == 1 156 # include <stdint.h> 157 # endif 158 # if ZRTP_HAVE_INTTYPES_H == 1 159 # include <inttypes.h> 160 # endif 161 # if ZRTP_HAVE_SYS_TYPES_H == 1 162 # include <sys/types.h> 163 # endif 164 # if ZRTP_HAVE_SYS_INT_TYPES_H == 1 165 # include <sys/int_types.h> 166 # endif 167 # if ZRTP_HAVE_MACHINE_TYPES_H == 1 168 # include <machine/types.h> 169 # endif 170 #endif 171 172 #if (ZRTP_PLATFORM == ZP_WINCE) || (ZRTP_PLATFORM == ZP_SYMBIAN) || (ZRTP_PLATFORM == ZP_ANDROID) 173 # define ALIGNMENT_32BIT_REQUIRED 174 #endif 175 176 #ifdef ZRTP_HAVE_UINT64_T 177 # if ZRTP_HAVE_UINT64_T == 0 178 # if defined(WIN32) || defined(WIN64) 179 # if defined(_MSC_VER) && (_MSC_VER < 1310) 180 typedef __int64 uint64_t; 181 # else 182 typedef unsigned long long uint64_t; 183 # endif 184 # else 185 # if SIZEOF_UNSIGNED_LONG == 8 186 typedef unsigned long uint64_t; 187 # elif SIZEOF_UNSIGNED_LONG_LONG == 8 188 typedef unsigned long long uint64_t; 189 # else 190 # define ZRTP_NO_64BIT_MATH 1 191 # endif 192 # endif /* WIN32 */ 193 # endif 194 #endif 195 196 #ifdef ZRTP_HAVE_INT64_T 197 # if ZRTP_HAVE_INT64_T == 0 198 # if defined(WIN32) || defined(WIN64) 199 # if defined(_MSC_VER) && (_MSC_VER < 1310) 200 typedef __int64 int64_t; 201 # else 202 typedef long long int64_t; 203 # endif 204 # else 205 # if SIZEOF_UNSIGNED_LONG == 8 206 typedef long int64_t; 207 # elif SIZEOF_UNSIGNED_LONG_LONG == 8 208 typedef long long int64_t; 209 # else 210 # define ZRTP_NO_64BIT_MATH 1 211 # endif 212 # endif /* WIN32 */ 213 # endif 214 #endif 215 216 #define SIZEOF_UNSIGNED_LONG_LONG 8 217 218 #if defined(WIN32) || defined(WIN64) 219 # if defined(_MSC_VER) && (_MSC_VER < 1310) 220 # define li_64(h) 0x##h##ui64 221 # else 222 # define li_64(h) 0x##h##ull 223 # endif 224 #else 225 # if SIZEOF_UNSIGNED_LONG == 8 226 # define li_64(h) 0x##h##ul 227 # elif SIZEOF_UNSIGNED_LONG_LONG == 8 228 # define li_64(h) 0x##h##ull 229 # else 230 # define ZRTP_NO_64BIT_MATH 1 231 # endif 232 #endif /* WIN32 */ 233 234 235 #ifdef ZRTP_HAVE_UINT8_T 236 # if ZRTP_HAVE_UINT8_T == 0 237 typedef unsigned char uint8_t; 238 # endif 239 #endif 240 241 #ifdef ZRTP_HAVE_UINT16_T 242 # if ZRTP_HAVE_UINT16_T == 0 243 typedef unsigned short int uint16_t; 244 # endif 245 #endif 246 247 #ifdef ZRTP_HAVE_UINT32_T 248 # if ZRTP_HAVE_UINT32_T == 0 249 typedef unsigned int uint32_t; 250 # endif 251 #endif 252 253 #ifdef ZRTP_HAVE_INT8_T 254 # if ZRTP_HAVE_INT8_T == 0 255 typedef char int8_t; 256 # endif 257 #endif 258 259 #ifdef ZRTP_HAVE_INT16_T 260 # if ZRTP_HAVE_INT16_T == 0 261 typedef short int int16_t; 262 # endif 263 #endif 264 265 #ifdef ZRTP_HAVE_INT32_T 266 # if ZRTP_HAVE_INT32_T == 0 267 typedef int int32_t; 268 # endif 269 #endif 270 271 #endif /*__ZRTP_CONFIG_H__ */ 272