zrtp_config.h 6.5 KB

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