no bug - Correct some typos in the comments. a=typo-fix
[gecko.git] / third_party / sipcc / cpr_types.h
blobf048e72be1cffb8050a4b8302c4b7c891e1fe047
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef _CPR_TYPES_H_
6 #define _CPR_TYPES_H_
8 #include <inttypes.h>
10 #if defined SIP_OS_LINUX
11 #include "cpr_linux_types.h"
12 #elif defined SIP_OS_WINDOWS
13 #include "cpr_win_types.h"
14 #elif defined SIP_OS_OSX
15 #include "cpr_darwin_types.h"
16 #else
17 //lol
18 //#error "Unsupported platform"
19 #endif
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
26 * CPR Return Codes
28 typedef enum
30 CPR_SUCCESS,
31 CPR_FAILURE
32 } cpr_status_e;
33 typedef cpr_status_e cprRC_t;
36 * IPv4 address structure
38 typedef uint32_t cpr_in_addr_t;
40 struct in_addr_s
42 #ifdef s_addr
43 /* can occur with Windows winsock.h */
44 union {
45 struct {
46 unsigned char s_b1, s_b2, sb_b3, s_b4;
47 } S_un_b;
48 cpr_in_addr_t S_addr;
49 } S_un;
50 #else
51 cpr_in_addr_t s_addr;
52 #endif
56 * IPv6 address structure
58 typedef struct
60 union
62 uint8_t base8[16];
63 uint16_t base16[8];
64 uint32_t base32[4];
65 } addr;
66 } cpr_in6_addr_t;
68 #ifndef s6_addr
69 #define s6_addr addr.base8
70 #endif
71 #ifndef s6_addr16
72 #define s6_addr16 addr.base16
73 #endif
74 #ifndef s6_addr32
75 #define s6_addr32 addr.base32
76 #endif
78 typedef enum
80 CPR_IP_ADDR_INVALID=0,
81 CPR_IP_ADDR_IPV4,
82 CPR_IP_ADDR_IPV6
83 } cpr_ip_type;
85 typedef enum
87 CPR_IP_MODE_IPV4 = 0,
88 CPR_IP_MODE_IPV6,
89 CPR_IP_MODE_DUAL
91 cpr_ip_mode_e;
93 * IP address structure
95 typedef struct
97 cpr_ip_type type;
98 union
100 cpr_in_addr_t ip4;
101 cpr_in6_addr_t ip6;
102 } u;
103 } cpr_ip_addr_t;
105 extern const cpr_ip_addr_t ip_addr_invalid;
107 #define MAX_IPADDR_STR_LEN 48
110 #define CPR_IP_ADDR_INIT(a) a.type = CPR_IP_ADDR_INVALID;
113 * !!! NOTE !!!
115 * The strings of type string_t are actually very special blocks
116 * of memory that have a "hidden" header block immediately preceding
117 * the pointer. You MUST use the functions in string_lib.c to
118 * create, manipulate, destroy, copy, or otherwise work with these
119 * strings.
122 typedef const char *string_t;
124 #ifdef __cplusplus
126 #endif
128 #endif