summaryrefslogtreecommitdiff
path: root/pjsip/include/pjsip/sip_types.h
blob: 8cd98ae0bbda492d120a32d8854b8490d1e3159e (plain)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/* $Id: sip_types.h 3553 2011-05-05 06:14:19Z nanang $ */
/* 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */
#ifndef __PJSIP_SIP_TYPES_H__
#define __PJSIP_SIP_TYPES_H__


/*
 * My note: Doxygen PJSIP and PJSIP_CORE group is declared in
 *          sip_config.h
 */

/**
 * @file sip_types.h
 * @brief Basic PJSIP types.
 */

#include <pjsip/sip_config.h>
#include <pj/types.h>

/**
 * @addtogroup PJSIP_BASE
 */

/* @defgroup PJSIP_TYPES Basic Data Types
 * @ingroup PJSIP_BASE
 * @brief Basic data types.
 * @{
 */



/**
 * Forward declaration for SIP transport.
 */
typedef struct pjsip_transport pjsip_transport;

/**
 * Forward declaration for transport manager.
 */
typedef struct pjsip_tpmgr pjsip_tpmgr;

/**
 * Transport types.
 */
typedef enum pjsip_transport_type_e
{
    /** Unspecified. */
    PJSIP_TRANSPORT_UNSPECIFIED,

    /** UDP. */
    PJSIP_TRANSPORT_UDP,

    /** TCP. */
    PJSIP_TRANSPORT_TCP,

    /** TLS. */
    PJSIP_TRANSPORT_TLS,

    /** SCTP. */
    PJSIP_TRANSPORT_SCTP,

    /** Loopback (stream, reliable) */
    PJSIP_TRANSPORT_LOOP,

    /** Loopback (datagram, unreliable) */
    PJSIP_TRANSPORT_LOOP_DGRAM,

    /** Start of user defined transport */
    PJSIP_TRANSPORT_START_OTHER,

    /** Start of IPv6 transports */
    PJSIP_TRANSPORT_IPV6    = 128,

    /** UDP over IPv6 */
    PJSIP_TRANSPORT_UDP6 = PJSIP_TRANSPORT_UDP + PJSIP_TRANSPORT_IPV6,

    /** TCP over IPv6 */
    PJSIP_TRANSPORT_TCP6 = PJSIP_TRANSPORT_TCP + PJSIP_TRANSPORT_IPV6

} pjsip_transport_type_e;


/**
 * Forward declaration for endpoint (sip_endpoint.h).
 */
typedef struct pjsip_endpoint pjsip_endpoint;

/**
 * Forward declaration for transactions (sip_transaction.h).
 */
typedef struct pjsip_transaction pjsip_transaction;

/**
 * Forward declaration for events (sip_event.h).
 */
typedef struct pjsip_event pjsip_event;

/**
 * Forward declaration for transmit data/buffer (sip_transport.h).
 */
typedef struct pjsip_tx_data pjsip_tx_data;

/**
 * Forward declaration for receive data/buffer (sip_transport.h).
 */
typedef struct pjsip_rx_data pjsip_rx_data;

/**
 * Forward declaration for message (sip_msg.h).
 */
typedef struct pjsip_msg pjsip_msg;

/**
 * Forward declaration for message body (sip_msg.h).
 */
typedef struct pjsip_msg_body pjsip_msg_body;

/**
 * Forward declaration for header field (sip_msg.h).
 */
typedef struct pjsip_hdr pjsip_hdr;

/**
 * Forward declaration for URI (sip_uri.h).
 */
typedef struct pjsip_uri pjsip_uri;

/**
 * Forward declaration for SIP method (sip_msg.h)
 */
typedef struct pjsip_method pjsip_method;

/**
 * Opaque data type for the resolver engine (sip_resolve.h).
 */
typedef struct pjsip_resolver_t pjsip_resolver_t;

/**
 * Forward declaration for credential.
 */
typedef struct pjsip_cred_info pjsip_cred_info;


/**
 * Forward declaration for module (sip_module.h).
 */
typedef struct pjsip_module pjsip_module;


/** 
 * Forward declaration for user agent type (sip_ua_layer.h). 
 */
typedef pjsip_module pjsip_user_agent;

/**
 * Forward declaration for dialog (sip_dialog.h).
 */
typedef struct pjsip_dialog pjsip_dialog;

/**
 * Transaction role.
 */
typedef enum pjsip_role_e
{
    PJSIP_ROLE_UAC,	/**< Role is UAC. */
    PJSIP_ROLE_UAS,	/**< Role is UAS. */

    /* Alias: */

    PJSIP_UAC_ROLE = PJSIP_ROLE_UAC,	/**< Role is UAC. */
    PJSIP_UAS_ROLE = PJSIP_ROLE_UAS	/**< Role is UAS. */

} pjsip_role_e;


/**
 * General purpose buffer.
 */
typedef struct pjsip_buffer
{
    /** The start of the buffer. */
    char *start;

    /** Pointer to current end of the buffer, which also indicates the position
        of subsequent buffer write.
     */
    char *cur;

    /** The absolute end of the buffer. */
    char *end;

} pjsip_buffer;


/**
 * General host:port pair, used for example as Via sent-by.
 */
typedef struct pjsip_host_port
{
    pj_str_t host;	/**< Host part or IP address. */
    int	     port;	/**< Port number. */
} pjsip_host_port;

/**
 * Host information.
 */
typedef struct pjsip_host_info
{
    unsigned		    flag;   /**< Flags of pjsip_transport_flags_e. */
    pjsip_transport_type_e  type;   /**< Transport type. */
    pjsip_host_port	    addr;   /**< Address information. */
} pjsip_host_info;


/**
 * Convert exception ID into pj_status_t status.
 *
 * @param exception_id  Exception Id.
 *
 * @return              Error code for the specified exception Id.
 */
PJ_DECL(pj_status_t) pjsip_exception_to_status(int exception_id);

/**
 * Return standard pj_status_t status from current exception.
 */
#define PJSIP_RETURN_EXCEPTION() pjsip_exception_to_status(PJ_GET_EXCEPTION())

/**
 * Attributes to inform that the function may throw exceptions.
 */
#define PJSIP_THROW_SPEC(list)


/**
 * @}
 */

#endif	/* __PJSIP_SIP_TYPES_H__ */