File: cpr_types.h

package info (click to toggle)
icedove 1:52.3.0-4~deb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,705,608 kB
  • sloc: cpp: 5,079,451; ansic: 2,051,639; python: 458,782; java: 241,615; xml: 192,378; asm: 178,649; sh: 81,867; makefile: 24,692; perl: 16,874; objc: 4,389; yacc: 1,816; ada: 1,697; lex: 1,257; pascal: 1,251; cs: 879; exp: 499; php: 436; lisp: 258; awk: 152; sed: 51; ruby: 47; csh: 27
file content (126 lines) | stat: -rw-r--r-- 2,205 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef _CPR_TYPES_H_
#define _CPR_TYPES_H_

#if defined SIP_OS_LINUX || defined(SIP_OS_HURD)
#include "cpr_linux_types.h"
#elif defined SIP_OS_WINDOWS
#include "cpr_win_types.h"
#elif defined SIP_OS_OSX
#include "cpr_darwin_types.h"
#else
//lol
//#error "Unsupported platform"
#endif

#ifdef __cplusplus
extern "C" {
#endif

/*
 * CPR Return Codes
 */
typedef enum
{
    CPR_SUCCESS,
    CPR_FAILURE
} cpr_status_e;
typedef cpr_status_e cprRC_t;

/*
 * IPv4 address structure
 */
typedef uint32_t cpr_in_addr_t;

struct in_addr_s
{
#ifdef s_addr
    /* can occur with Windows winsock.h */
    union {
        struct {
            unsigned char s_b1, s_b2, sb_b3, s_b4;
        } S_un_b;
        cpr_in_addr_t S_addr;
    } S_un;
#else
    cpr_in_addr_t s_addr;
#endif
};

/*
 * IPv6 address structure
 */
typedef struct
{
    union
    {
        uint8_t  base8[16];
        uint16_t base16[8];
        uint32_t base32[4];
    } addr;
} cpr_in6_addr_t;

#ifndef s6_addr
#define s6_addr   addr.base8
#endif
#ifndef s6_addr16
#define s6_addr16 addr.base16
#endif
#ifndef s6_addr32
#define s6_addr32 addr.base32
#endif

typedef enum
{
     CPR_IP_ADDR_INVALID=0,
     CPR_IP_ADDR_IPV4,
     CPR_IP_ADDR_IPV6
} cpr_ip_type;

typedef enum
{
     CPR_IP_MODE_IPV4 = 0,
     CPR_IP_MODE_IPV6,
     CPR_IP_MODE_DUAL
}
cpr_ip_mode_e;
/*
 * IP address structure
 */
typedef struct
{
    cpr_ip_type type;
    union
    {
        cpr_in_addr_t  ip4;
        cpr_in6_addr_t ip6;
    } u;
} cpr_ip_addr_t;

extern const cpr_ip_addr_t ip_addr_invalid;

#define MAX_IPADDR_STR_LEN 48


#define CPR_IP_ADDR_INIT(a) a.type = CPR_IP_ADDR_INVALID;

/*
 * !!! NOTE !!!
 *
 * The strings of type string_t are actually very special blocks
 * of memory that have a "hidden" header block immediately preceding
 * the pointer. You MUST use the functions in string_lib.c to
 * create, manipulate, destroy, copy, or otherwise work with these
 * strings.
 */

typedef const char *string_t;

#ifdef __cplusplus
}
#endif

#endif