Changeset 43
- Timestamp:
- Nov 11, 2005 7:01:31 PM (19 years ago)
- Location:
- pjproject/main
- Files:
-
- 1 added
- 2 deleted
- 70 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/main/RELNOTES.txt
r1 r43 1 Version 0.3 2 PJLIB 3 - Correct error reporting in the whole library. No more vague -1 errors! 4 - New super portable socket abstraction. 5 - Other headers were made super portable too. 6 - Ioqueue supports multiple pending operations in a single socket! 7 - No more floating point. 8 - Ported to new platforms: 9 - i386/linux kernel (!) 10 - Sparc/Solaris 11 - Alpha/Linux 12 PJSIP 13 - Correct error reporting in the whole library. No more -1 errors! 14 - Rewrote event, now much more readable. 15 - Per object tracing. 16 17 1 18 Version 0.2.9 - 2005/06/19 2 19 Core: -
pjproject/main/pjlib-util/include/pjlib-util/scanner.h
r29 r43 1 1 /* $Id$ 2 * 3 */ 4 5 #ifndef __PJ_PARSER_H__ 6 #define __PJ_PARSER_H__ 2 */ 3 #ifndef __PJ_SCANNER_H__ 4 #define __PJ_SCANNER_H__ 7 5 8 6 /** … … 20 18 * @brief 21 19 * Text scanning utility. 22 */ 23 24 /** 25 * @defgroup PJ_CHARSPEC Character Filter Specification 26 * @ingroup PJ_SCAN 27 * @brief 28 * The type pj_char_spec is a specification of character set used in 29 * scanner. Application can define multiple character specs, such as to 30 * scan alpha numerics, numbers, tokens, etc. 20 * 31 21 * @{ 32 22 */ … … 34 24 /** 35 25 * This describes the type of individual character specification in 36 * #pj_char_spec. 37 */ 38 typedef pj_uint8_t pj_char_spec_element_t; 39 40 /** 41 * The character specification is implemented as array of boolean flags. Each 42 * flag indicates the membership of the character in the spec. If the flag 43 * at one position is non-zero, then the character at that position belongs 44 * to the specification, and vice versa. 45 */ 46 typedef pj_char_spec_element_t pj_char_spec[256]; 47 // Note: it's got to be 256 (not 128) to cater for extended character in input. 48 49 /** 50 * Initialize character spec. 51 * @param cs the scanner character specification. 52 */ 53 PJ_DECL(void) pj_cs_init( pj_char_spec cs); 54 55 /** 56 * Set the membership of the specified character to TRUE. 57 * @param cs the scanner character specification. 58 * @param c the character. 59 */ 60 PJ_DECL(void) pj_cs_set( pj_char_spec cs, int c); 26 * #pj_cis_buf_t. Basicly the number of bits here 27 */ 28 #ifndef PJ_CIS_ELEM_TYPE 29 # define PJ_CIS_ELEM_TYPE pj_uint32_t 30 #endif 31 32 /** 33 * This describes the type of individual character specification in 34 * #pj_cis_buf_t. 35 */ 36 typedef PJ_CIS_ELEM_TYPE pj_cis_elem_t; 37 38 /** 39 * Maximum number of input specification in a buffer. 40 * Effectively this means the number of bits in pj_cis_elem_t. 41 */ 42 #define PJ_CIS_MAX_INDEX (sizeof(pj_cis_elem_t) << 3) 43 44 /** 45 * The scanner input specification buffer. 46 */ 47 typedef struct pj_cis_buf_t 48 { 49 pj_cis_elem_t cis_buf[256]; /**< Must be 256 (not 128)! */ 50 pj_cis_elem_t use_mask; /**< To keep used indexes. */ 51 } pj_cis_buf_t; 52 53 /** 54 * Character input specification. 55 */ 56 typedef struct pj_cis_t 57 { 58 pj_cis_elem_t *cis_buf; /**< Pointer to buffer. */ 59 int cis_id; /**< Id. */ 60 } pj_cis_t; 61 62 /** 63 * Initialize scanner input specification buffer. 64 * 65 * @param cs_buf The scanner character specification. 66 */ 67 PJ_DECL(void) pj_cis_buf_init(pj_cis_buf_t *cs_buf); 68 69 /** 70 * Create a new input specification. 71 * 72 * @param cs_buf Specification buffer. 73 * @param cis Character input specification to be initialized. 74 * 75 * @return PJ_SUCCESS if new specification has been successfully 76 * created, or PJ_ETOOMANY if there are already too many 77 * specifications in the buffer. 78 */ 79 PJ_DECL(pj_status_t) pj_cis_init(pj_cis_buf_t *cs_buf, pj_cis_t *cis); 80 81 /** 82 * Create a new input specification based on an existing specification. 83 * 84 * @param new_cis The new specification to be initialized. 85 * @param existing The existing specification, from which the input 86 * bitmask will be copied to the new specification. 87 * 88 * @return PJ_SUCCESS if new specification has been successfully 89 * created, or PJ_ETOOMANY if there are already too many 90 * specifications in the buffer. 91 */ 92 PJ_DECL(pj_status_t) pj_cis_dup(pj_cis_t *new_cis, pj_cis_t *existing); 93 94 /** 95 * Set the membership of the specified character. 96 * Note that this is a macro, and arguments may be evaluated more than once. 97 * 98 * @param cis Pointer to character input specification. 99 * @param c The character. 100 */ 101 #define PJ_CIS_SET(cis,c) ((cis)->cis_buf[(c)] |= (1 << (cis)->cis_id)) 102 103 /** 104 * Remove the membership of the specified character. 105 * Note that this is a macro, and arguments may be evaluated more than once. 106 * 107 * @param cis Pointer to character input specification. 108 * @param c The character to be removed from the membership. 109 */ 110 #define PJ_CIS_CLR(cis,c) ((cis)->cis_buf[c] &= ~(1 << (cis)->cis_id)) 111 112 /** 113 * Check the membership of the specified character. 114 * Note that this is a macro, and arguments may be evaluated more than once. 115 * 116 * @param cis Pointer to character input specification. 117 * @param c The character. 118 */ 119 #define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[c] & (1 << (cis)->cis_id)) 61 120 62 121 /** 63 122 * Add the characters in the specified range '[cstart, cend)' to the 64 123 * specification (the last character itself ('cend') is not added). 65 * @param cs the scanner character specification. 66 * @param cstart the first character in the range. 67 * @param cend the next character after the last character in the range. 68 */ 69 PJ_DECL(void) pj_cs_add_range( pj_char_spec cs, int cstart, int cend); 124 * 125 * @param cis The scanner character specification. 126 * @param cstart The first character in the range. 127 * @param cend The next character after the last character in the range. 128 */ 129 PJ_DECL(void) pj_cis_add_range( pj_cis_t *cis, int cstart, int cend); 70 130 71 131 /** 72 132 * Add alphabetic characters to the specification. 73 * @param cs the scanner character specification. 74 */ 75 PJ_DECL(void) pj_cs_add_alpha( pj_char_spec cs); 133 * 134 * @param cis The scanner character specification. 135 */ 136 PJ_DECL(void) pj_cis_add_alpha( pj_cis_t *cis); 76 137 77 138 /** 78 139 * Add numeric characters to the specification. 79 * @param cs the scanner character specification. 80 */ 81 PJ_DECL(void) pj_cs_add_num( pj_char_spec cs); 140 * 141 * @param cis The scanner character specification. 142 */ 143 PJ_DECL(void) pj_cis_add_num( pj_cis_t *cis); 82 144 83 145 /** 84 146 * Add the characters in the string to the specification. 85 * @param cs the scanner character specification. 86 * @param str the string. 87 */ 88 PJ_DECL(void) pj_cs_add_str( pj_char_spec cs, const char *str); 147 * 148 * @param cis The scanner character specification. 149 * @param str The string. 150 */ 151 PJ_DECL(void) pj_cis_add_str( pj_cis_t *cis, const char *str); 89 152 90 153 /** 91 154 * Delete characters in the specified range from the specification. 92 * @param cs the scanner character specification. 93 * @param cstart the first character in the range. 94 * @param cend the next character after the last character in the range. 95 */ 96 PJ_DECL(void) pj_cs_del_range( pj_char_spec cs, int cstart, int cend); 155 * 156 * @param cis The scanner character specification. 157 * @param cstart The first character in the range. 158 * @param cend The next character after the last character in the range. 159 */ 160 PJ_DECL(void) pj_cis_del_range( pj_cis_t *cis, int cstart, int cend); 97 161 98 162 /** 99 163 * Delete characters in the specified string from the specification. 100 * @param cs the scanner character specification. 101 * @param str the string. 102 */ 103 PJ_DECL(void) pj_cs_del_str( pj_char_spec cs, const char *str); 164 * 165 * @param cis The scanner character specification. 166 * @param str The string. 167 */ 168 PJ_DECL(void) pj_cis_del_str( pj_cis_t *cis, const char *str); 104 169 105 170 /** 106 171 * Invert specification. 107 * @param cs the scanner character specification. 108 */ 109 PJ_DECL(void) pj_cs_invert( pj_char_spec cs ); 172 * 173 * @param cis The scanner character specification. 174 */ 175 PJ_DECL(void) pj_cis_invert( pj_cis_t *cis ); 110 176 111 177 /** 112 178 * Check whether the specified character belongs to the specification. 113 * @param cs the scanner character specification. 114 * @param c the character to check for matching. 115 */ 116 PJ_INLINE(int) pj_cs_match( const pj_char_spec cs, int c ) 117 { 118 return cs[c]; 179 * 180 * @param cis The scanner character specification. 181 * @param c The character to check for matching. 182 */ 183 PJ_INLINE(int) pj_cis_match( const pj_cis_t *cis, int c ) 184 { 185 return PJ_CIS_ISSET(cis, c); 119 186 } 120 187 121 /**122 * @}123 */124 125 /**126 * @defgroup PJ_SCANNER Text Scanner127 * @ingroup PJ_SCAN128 * @{129 */130 188 131 189 /** … … 157 215 * The callback function type to be called by the scanner when it encounters 158 216 * syntax error. 159 * @param scanner The scanner instance that calls the callback . 217 * 218 * @param scanner The scanner instance that calls the callback . 160 219 */ 161 220 typedef void (*pj_syn_err_func_ptr)(struct pj_scanner *scanner); … … 245 304 */ 246 305 PJ_DECL(int) pj_scan_peek( pj_scanner *scanner, 247 const pj_char_specspec, pj_str_t *out);306 const pj_cis_t *spec, pj_str_t *out); 248 307 249 308 … … 262 321 */ 263 322 PJ_DECL(int) pj_scan_peek_n( pj_scanner *scanner, 264 323 pj_size_t len, pj_str_t *out); 265 324 266 325 … … 278 337 */ 279 338 PJ_DECL(int) pj_scan_peek_until( pj_scanner *scanner, 280 const pj_char_specspec,281 339 const pj_cis_t *spec, 340 pj_str_t *out); 282 341 283 342 … … 294 353 */ 295 354 PJ_DECL(void) pj_scan_get( pj_scanner *scanner, 296 const pj_char_specspec, pj_str_t *out);355 const pj_cis_t *spec, pj_str_t *out); 297 356 298 357 … … 318 377 */ 319 378 PJ_DECL(void) pj_scan_get_n( pj_scanner *scanner, 320 379 unsigned N, pj_str_t *out); 321 380 322 381 … … 326 385 * @param scanner The scanner. 327 386 * 328 * @return (unknown)387 * @return The character. 329 388 */ 330 389 PJ_DECL(int) pj_scan_get_char( pj_scanner *scanner ); … … 349 408 */ 350 409 PJ_DECL(void) pj_scan_get_until( pj_scanner *scanner, 351 const pj_char_specspec, pj_str_t *out);410 const pj_cis_t *spec, pj_str_t *out); 352 411 353 412 … … 361 420 */ 362 421 PJ_DECL(void) pj_scan_get_until_ch( pj_scanner *scanner, 363 422 int until_char, pj_str_t *out); 364 423 365 424 … … 373 432 */ 374 433 PJ_DECL(void) pj_scan_get_until_chr( pj_scanner *scanner, 375 434 const char *until_spec, pj_str_t *out); 376 435 377 436 /** … … 385 444 */ 386 445 PJ_DECL(void) pj_scan_advance_n( pj_scanner *scanner, 387 446 unsigned N, pj_bool_t skip); 388 447 389 448 … … 446 505 */ 447 506 448 #if PJ_FUNCTIONS_ARE_INLINED 449 # include "scanner_i.h" 507 508 PJ_END_DECL 509 450 510 #endif 451 511 452 453 PJ_END_DECL454 455 #endif456 -
pjproject/main/pjlib-util/src/pjlib-util/scanner.c
r32 r43 5 5 #include <pj/except.h> 6 6 #include <pj/os.h> 7 #include <pj/errno.h> 7 8 8 9 #define PJ_SCAN_IS_SPACE(c) ((c)==' ' || (c)=='\t') … … 16 17 } 17 18 18 PJ_DEF(void) pj_cs_init( pj_char_spec cs) 19 { 20 PJ_CHECK_STACK(); 21 memset(cs, 0, sizeof(cs)); 22 } 23 24 PJ_DEF(void) pj_cs_set( pj_char_spec cs, int c) 25 { 26 PJ_CHECK_STACK(); 27 cs[c] = 1; 28 } 29 30 PJ_DEF(void) pj_cs_add_range( pj_char_spec cs, int cstart, int cend) 31 { 32 PJ_CHECK_STACK(); 33 while (cstart != cend) 34 cs[cstart++] = 1; 35 } 36 37 PJ_DEF(void) pj_cs_add_alpha( pj_char_spec cs) 38 { 39 pj_cs_add_range( cs, 'a', 'z'+1); 40 pj_cs_add_range( cs, 'A', 'Z'+1); 41 } 42 43 PJ_DEF(void) pj_cs_add_num( pj_char_spec cs) 44 { 45 pj_cs_add_range( cs, '0', '9'+1); 46 } 47 48 PJ_DEF(void) pj_cs_add_str( pj_char_spec cs, const char *str) 49 { 50 PJ_CHECK_STACK(); 19 PJ_DEF(void) pj_cis_buf_init( pj_cis_buf_t *cis_buf) 20 { 21 pj_memset(cis_buf->cis_buf, 0, sizeof(cis_buf->cis_buf)); 22 cis_buf->use_mask = 0; 23 } 24 25 PJ_DEF(pj_status_t) pj_cis_init(pj_cis_buf_t *cis_buf, pj_cis_t *cis) 26 { 27 unsigned i; 28 29 cis->cis_buf = cis_buf->cis_buf; 30 31 for (i=0; i<PJ_CIS_MAX_INDEX; ++i) { 32 if ((cis_buf->use_mask & (1 << i)) == 0) { 33 cis->cis_index = i; 34 return PJ_SUCCESS; 35 } 36 } 37 38 cis->cis_index = PJ_CIS_MAX_INDEX; 39 return PJ_ETOOMANY; 40 } 41 42 PJ_DEF(pj_status_t) pj_cis_dup( pj_cis_t *new_cis, pj_cis_t *existing) 43 { 44 pj_status_t status; 45 unsigned i; 46 47 status = pj_cis_init(existing->cis_buf, new_cis); 48 if (status != PJ_SUCCESS) 49 return status; 50 51 for (i=0; i<256; ++i) { 52 if (PJ_CIS_ISSET(existing, i)) 53 PJ_CIS_SET(new_cis, i); 54 else 55 PJ_CIS_CLR(new_cis, i); 56 } 57 58 return PJ_SUCCESS; 59 } 60 61 PJ_DEF(void) pj_cis_add_range(pj_cis_t *cis, int cstart, int cend) 62 { 63 while (cstart != cend) { 64 PJ_CIS_SET(cis, cstart); 65 ++cstart; 66 } 67 } 68 69 PJ_DEF(void) pj_cis_add_alpha(pj_cis_t *cis) 70 { 71 pj_cis_add_range( cis, 'a', 'z'+1); 72 pj_cis_add_range( cis, 'A', 'Z'+1); 73 } 74 75 PJ_DEF(void) pj_cis_add_num(pj_cis_t *cis) 76 { 77 pj_cis_add_range( cis, '0', '9'+1); 78 } 79 80 PJ_DEF(void) pj_cis_add_str( pj_cis_t *cis, const char *str) 81 { 51 82 while (*str) { 52 cs[(int)*str] = 1;83 PJ_CIS_SET(cis, *str); 53 84 ++str; 54 85 } 55 86 } 56 87 57 PJ_DEF(void) pj_c s_del_range( pj_char_spec cs, int cstart, int cend)58 { 59 PJ_CHECK_STACK();60 while (cstart != cend)61 cs[cstart++] = 0;62 }63 64 PJ_DEF(void) pj_cs_del_str( pj_char_spec cs, const char *str) 65 { 66 PJ_CHECK_STACK(); 88 PJ_DEF(void) pj_cis_del_range( pj_cis_t *cis, int cstart, int cend) 89 { 90 while (cstart != cend) { 91 PJ_CIS_CLR(cis, cstart); 92 cstart++; 93 } 94 } 95 96 PJ_DEF(void) pj_cis_del_str( pj_cis_t *cis, const char *str) 97 { 67 98 while (*str) { 68 cs[(int)*str] = 0;99 PJ_CIS_CLR(cis, *str); 69 100 ++str; 70 101 } 71 102 } 72 103 73 PJ_DEF(void) pj_c s_invert( pj_char_spec cs )104 PJ_DEF(void) pj_cis_invert( pj_cis_t *cis ) 74 105 { 75 106 unsigned i; 76 PJ_CHECK_STACK(); 77 for (i=0; i<sizeof(pj_char_spec)/sizeof(cs[0]); ++i) { 78 cs[i] = (pj_char_spec_element_t) !cs[i]; 107 for (i=0; i<256; ++i) { 108 if (PJ_CIS_ISSET(cis,i)) 109 PJ_CIS_CLR(cis,i); 110 else 111 PJ_CIS_SET(cis,i); 79 112 } 80 113 } … … 166 199 167 200 PJ_DEF(int) pj_scan_peek( pj_scanner *scanner, 168 const pj_char_specspec, pj_str_t *out)201 const pj_cis_t *spec, pj_str_t *out) 169 202 { 170 203 register char *s = scanner->curptr; … … 178 211 } 179 212 180 while (PJ_SCAN_CHECK_EOF(s) && pj_c s_match(spec, *s))213 while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s)) 181 214 ++s; 182 215 … … 204 237 205 238 PJ_DEF(int) pj_scan_peek_until( pj_scanner *scanner, 206 const pj_char_specspec,207 239 const pj_cis_t *spec, 240 pj_str_t *out) 208 241 { 209 242 register char *s = scanner->curptr; … … 217 250 } 218 251 219 while (PJ_SCAN_CHECK_EOF(s) && !pj_c s_match( spec, *s))252 while (PJ_SCAN_CHECK_EOF(s) && !pj_cis_match( spec, *s)) 220 253 ++s; 221 254 … … 226 259 227 260 PJ_DEF(void) pj_scan_get( pj_scanner *scanner, 228 const pj_char_specspec, pj_str_t *out)261 const pj_cis_t *spec, pj_str_t *out) 229 262 { 230 263 register char *s = scanner->curptr; … … 234 267 PJ_CHECK_STACK(); 235 268 236 if (pj_scan_is_eof(scanner) || !pj_c s_match(spec, *s)) {269 if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s)) { 237 270 pj_scan_syntax_err(scanner); 238 271 return; … … 241 274 do { 242 275 ++s; 243 } while (PJ_SCAN_CHECK_EOF(s) && pj_c s_match(spec, *s));276 } while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s)); 244 277 245 278 pj_strset3(out, scanner->curptr, s); … … 396 429 397 430 PJ_DEF(void) pj_scan_get_until( pj_scanner *scanner, 398 const pj_char_specspec, pj_str_t *out)431 const pj_cis_t *spec, pj_str_t *out) 399 432 { 400 433 register char *s = scanner->curptr; … … 409 442 } 410 443 411 while (PJ_SCAN_CHECK_EOF(s) && !pj_c s_match(spec, *s)) {444 while (PJ_SCAN_CHECK_EOF(s) && !pj_cis_match(spec, *s)) { 412 445 ++s; 413 446 } … … 425 458 426 459 PJ_DEF(void) pj_scan_get_until_ch( pj_scanner *scanner, 427 460 int until_char, pj_str_t *out) 428 461 { 429 462 register char *s = scanner->curptr; -
pjproject/main/pjlib/build/pjlib.dsw
r36 r43 24 24 Package=<4> 25 25 {{{ 26 }}} 27 28 ############################################################################### 29 30 Project: "pjlib++_test"=".\pjlib++-test.dsp" - Package Owner=<4> 31 32 Package=<5> 33 {{{ 34 }}} 35 36 Package=<4> 37 {{{ 38 Begin Project Dependency 39 Project_Dep_Name pjlib 40 End Project Dependency 41 Begin Project Dependency 42 Project_Dep_Name pjlib++ 43 End Project Dependency 26 44 }}} 27 45 … … 58 76 ############################################################################### 59 77 60 Project: "pjlib++_test"=.\pjlib++-test.dsp - Package Owner=<4>61 62 Package=<5>63 {{{64 }}}65 66 Package=<4>67 {{{68 Begin Project Dependency69 Project_Dep_Name pjlib70 End Project Dependency71 Begin Project Dependency72 Project_Dep_Name pjlib++73 End Project Dependency74 }}}75 76 ###############################################################################77 78 78 Global: 79 79 -
pjproject/main/pjlib/include/pj++/file.hpp
r36 r43 1 /* $Id$ */2 1 /* $Id$ 2 */ 3 3 #ifndef __PJPP_FILE_HPP__ 4 4 #define __PJPP_FILE_HPP__ -
pjproject/main/pjlib/include/pj++/hash.hpp
r36 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_HASH_H __4 #define __PJPP_HASH_H __3 #ifndef __PJPP_HASH_HPP__ 4 #define __PJPP_HASH_HPP__ 5 5 6 6 #include <pj++/types.hpp> … … 136 136 137 137 138 #endif /* __PJPP_HASH_H __ */138 #endif /* __PJPP_HASH_HPP__ */ 139 139 -
pjproject/main/pjlib/include/pj++/list.hpp
r36 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_LIST_H __4 #define __PJPP_LIST_H __3 #ifndef __PJPP_LIST_HPP__ 4 #define __PJPP_LIST_HPP__ 5 5 6 6 #include <pj/list.h> … … 308 308 309 309 310 #endif /* __PJPP_LIST_H__ */ 310 #endif /* __PJPP_LIST_HPP__ */ 311 -
pjproject/main/pjlib/include/pj++/lock.hpp
r36 r43 1 /* $Id$ */ 2 #ifndef __PJPP_LOCK_H__ 3 #define __PJPP_LOCK_H__ 1 /* $Id$ 2 */ 3 #ifndef __PJPP_LOCK_HPP__ 4 #define __PJPP_LOCK_HPP__ 4 5 5 6 #include <pj++/types.hpp> … … 128 129 129 130 130 #endif /* __PJPP_LOCK_H __ */131 #endif /* __PJPP_LOCK_HPP__ */ 131 132 -
pjproject/main/pjlib/include/pj++/os.hpp
r36 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_OS_H __4 #define __PJPP_OS_H __3 #ifndef __PJPP_OS_HPP__ 4 #define __PJPP_OS_HPP__ 5 5 6 6 #include <pj/os.h> … … 785 785 } 786 786 787 #endif /* __PJPP_OS_H__ */ 787 #endif /* __PJPP_OS_HPP__ */ 788 -
pjproject/main/pjlib/include/pj++/pool.hpp
r37 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_POOL_H __4 #define __PJPP_POOL_H __3 #ifndef __PJPP_POOL_HPP__ 4 #define __PJPP_POOL_HPP__ 5 5 6 6 #include <pj/pool.h> … … 251 251 252 252 253 #endif /* __PJPP_POOL_H__ */ 253 #endif /* __PJPP_POOL_HPP__ */ 254 -
pjproject/main/pjlib/include/pj++/proactor.hpp
r37 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_PROACTOR_H __4 #define __PJPP_PROACTOR_H __3 #ifndef __PJPP_PROACTOR_HPP__ 4 #define __PJPP_PROACTOR_HPP__ 5 5 6 6 #include <pj/ioqueue.h> … … 30 30 : handler_(NULL) 31 31 { 32 pj_ioqueue_op_key_init(this, sizeof(*this)); 32 33 } 33 34 … … 38 39 : handler_(handler) 39 40 { 40 pj_memset(this, 0, sizeof(pj_ioqueue_op_key_t));41 pj_ioqueue_op_key_init(this, sizeof(*this)); 41 42 } 42 43 … … 498 499 }; 499 500 500 #endif /* __PJPP_PROACTOR_H__ */ 501 #endif /* __PJPP_PROACTOR_HPP__ */ 502 -
pjproject/main/pjlib/include/pj++/scanner.hpp
r36 r43 1 1 /* $Id$ 2 *3 2 */ 4 #ifndef __PJPP_SCANNER_H __5 #define __PJPP_SCANNER_H __3 #ifndef __PJPP_SCANNER_HPP__ 4 #define __PJPP_SCANNER_HPP__ 6 5 7 6 #include <pjlib-util/scanner.h> … … 171 170 }; 172 171 173 #endif /* __PJPP_SCANNER_H__ */ 172 #endif /* __PJPP_SCANNER_HPP__ */ 173 -
pjproject/main/pjlib/include/pj++/sock.hpp
r36 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_SOCK_H __4 #define __PJPP_SOCK_H __3 #ifndef __PJPP_SOCK_HPP__ 4 #define __PJPP_SOCK_HPP__ 5 5 6 6 #include <pj/sock.h> … … 424 424 425 425 426 #endif /* __PJPP_SOCK_H__ */ 426 #endif /* __PJPP_SOCK_HPP__ */ 427 -
pjproject/main/pjlib/include/pj++/string.hpp
r36 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_STRING_H __4 #define __PJPP_STRING_H __3 #ifndef __PJPP_STRING_HPP__ 4 #define __PJPP_STRING_HPP__ 5 5 6 6 #include <pj/string.h> … … 406 406 }; 407 407 408 #endif /* __PJPP_STRING_H__ */ 408 #endif /* __PJPP_STRING_HPP__ */ 409 -
pjproject/main/pjlib/include/pj++/timer.hpp
r36 r43 1 1 /* $Id$ 2 2 */ 3 #ifndef __PJPP_TIMER_H __4 #define __PJPP_TIMER_H __3 #ifndef __PJPP_TIMER_HPP__ 4 #define __PJPP_TIMER_HPP__ 5 5 6 6 #include <pj/timer.h> … … 178 178 }; 179 179 180 #endif /* __PJPP_TIMER_H__ */ 180 #endif /* __PJPP_TIMER_HPP__ */ 181 -
pjproject/main/pjlib/include/pj++/tree.hpp
r36 r43 1 1 /* $Id$ 2 *3 2 */ 4 #ifndef __PJPP_TREE_H __5 #define __PJPP_TREE_H __3 #ifndef __PJPP_TREE_HPP__ 4 #define __PJPP_TREE_HPP__ 6 5 7 6 #include <pj/rbtree.h> … … 110 109 }; 111 110 112 #endif /* __PJPP_TREE_H__ */ 111 #endif /* __PJPP_TREE_HPP__ */ 112 -
pjproject/main/pjlib/include/pj++/types.hpp
r36 r43 1 1 /* $Id$ 2 *3 2 */ 4 #ifndef __PJPP_TYPES_H __5 #define __PJPP_TYPES_H __3 #ifndef __PJPP_TYPES_HPP__ 4 #define __PJPP_TYPES_HPP__ 6 5 7 6 #include <pj/types.h> … … 142 141 }; 143 142 144 #endif /* __PJPP_TYPES_H__ */ 143 #endif /* __PJPP_TYPES_HPP__ */ 144 -
pjproject/main/pjlib/include/pj/compat/string.h
r4 r43 41 41 42 42 43 #define pj_native_strcmp strcmp 44 #define pj_native_strlen strlen 45 #define pj_native_strcpy strcpy 46 #define pj_native_strstr strstr 47 #define pj_native_strchr strchr 48 #define pj_native_strcasecmp strcasecmp 49 #define pj_native_strncasecmp strncasecmp 50 51 43 52 #endif /* __PJ_COMPAT_STRING_H__ */ -
pjproject/main/pjlib/include/pj/config.h
r35 r43 148 148 */ 149 149 #ifndef PJ_LOG_MAX_LEVEL 150 # define PJ_LOG_MAX_LEVEL 4150 # define PJ_LOG_MAX_LEVEL 5 151 151 #endif 152 152 … … 404 404 #endif 405 405 406 /** 407 * Function attributes to inform that the function may throw exception. 408 * 409 * @param x The exception list, enclosed in parenthesis. 410 */ 411 #define __pj_throw__(x) 412 406 413 407 414 /******************************************************************** -
pjproject/main/pjlib/include/pj/errno.h
r36 r43 216 216 */ 217 217 #define PJ_ECANCELLED (PJ_ERRNO_START_STATUS + 14) 218 /** 219 * @hideinitializer 220 * Object already exists. 221 */ 222 #define PJ_EEXISTS (PJ_ERRNO_START_STATUS + 14) 218 223 219 224 /** @} */ /* pj_errnum */ -
pjproject/main/pjlib/include/pj/except.h
r4 r43 184 184 PJ_DECL(const char*) pj_exception_id_name(pj_exception_id_t id); 185 185 186 186 187 /** @} */ 187 188 -
pjproject/main/pjlib/include/pj/hash.h
r4 r43 45 45 const void *key, unsigned keylen); 46 46 47 48 /** 49 * Convert the key to lowercase and calculate the hash value. The resulting 50 * string is stored in \c result. 51 * 52 * @param hval The initial hash value, normally zero. 53 * @param result Buffer to store the result, which must be enough to hold 54 * the string. 55 * @param key The input key to be converted and calculated. 56 * 57 * @return The hash value. 58 */ 59 PJ_DECL(pj_uint32_t) pj_hash_calc_tolower(pj_uint32_t hval, 60 char *result, 61 const pj_str_t *key); 47 62 48 63 /** -
pjproject/main/pjlib/include/pj/ioqueue.h
r36 r43 342 342 343 343 /** 344 * Initialize operation key. 345 * 346 * @param op_key The operation key to be initialied. 347 * @param size The size of the operation key. 348 */ 349 PJ_DECL(void) pj_ioqueue_op_key_init( pj_ioqueue_op_key_t *op_key, 350 pj_size_t size ); 351 352 /** 344 353 * Check if operation is pending on the specified operation key. 345 * The \c op_key must have been submitted as pending operation before, 346 * or otherwise the result is undefined. 354 * The \c op_key must have been initialized with #pj_ioqueue_op_key_init() 355 * or submitted as pending operation before, or otherwise the result 356 * is undefined. 347 357 * 348 358 * @param key The key. -
pjproject/main/pjlib/include/pj/string.h
r4 r43 13 13 #include <pj/types.h> 14 14 #include <pj/compat/string.h> 15 #include <pj/compat/sprintf.h> 16 #include <pj/compat/vsprintf.h> 17 15 18 16 19 PJ_BEGIN_DECL -
pjproject/main/pjlib/src/pj/errno.c
r36 r43 31 31 { PJ_ENOTSUP, "Option/operation is not supported"}, 32 32 { PJ_EINVALIDOP, "Invalid operation"}, 33 { PJ_ECANCELLED, "Operation cancelled"} 33 { PJ_ECANCELLED, "Operation cancelled"}, 34 { PJ_EEXISTS, "Object already exists" } 34 35 }; 35 36 -
pjproject/main/pjlib/src/pj/hash.c
r6 r43 50 50 } 51 51 return hash; 52 } 53 54 PJ_DEF(pj_uint32_t) pj_hash_calc_tolower( pj_uint32_t hval, 55 char *result, 56 const pj_str_t *key) 57 { 58 long i; 59 60 for (i=0; i<key->slen; ++i) { 61 result[i] = (char)pj_tolower(key->ptr[i]); 62 hval = hval * PJ_HASH_MULTIPLIER + result[i]; 63 } 64 65 return hval; 52 66 } 53 67 -
pjproject/main/pjlib/src/pj/ioqueue_common_abs.c
r36 r43 834 834 #endif /* PJ_HAS_TCP */ 835 835 836 837 PJ_DEF(void) pj_ioqueue_op_key_init( pj_ioqueue_op_key_t *op_key, 838 pj_size_t size ) 839 { 840 pj_memset(op_key, 0, size); 841 } 842 843 836 844 /* 837 845 * pj_ioqueue_is_pending() -
pjproject/main/pjlib/src/pj/ioqueue_winnt.c
r36 r43 893 893 894 894 895 PJ_DEF(void) pj_ioqueue_op_key_init( pj_ioqueue_op_key_t *op_key, 896 pj_size_t size ) 897 { 898 pj_memset(op_key, 0, size); 899 } 895 900 896 901 PJ_DEF(pj_bool_t) pj_ioqueue_is_pending( pj_ioqueue_key_t *key, -
pjproject/main/pjsip/bin
-
Property
svn:ignore
set to
*
-
Property
svn:ignore
set to
-
pjproject/main/pjsip/build
- Property svn:ignore
-
old new 2 2 *.ncb 3 3 *.plg 4 TODO-LIST.TXT
-
- Property svn:ignore
-
pjproject/main/pjsip/build/output
-
Property
svn:ignore
set to
*
-
Property
svn:ignore
set to
-
pjproject/main/pjsip/build/pjsip_core.dsp
r1 r43 33 33 # PROP BASE Use_MFC 0 34 34 # PROP BASE Use_Debug_Libraries 0 35 # PROP BASE Output_Dir " Release"36 # PROP BASE Intermediate_Dir " Release"35 # PROP BASE Output_Dir ".\output\pjsip-core-i386-win32-vc6-release" 36 # PROP BASE Intermediate_Dir ".\output\pjsip-core-i386-win32-vc6-release" 37 37 # PROP BASE Target_Dir "" 38 38 # PROP Use_MFC 0 39 39 # PROP Use_Debug_Libraries 0 40 # PROP Output_Dir ".\output\pjsip _core_vc6_Release"41 # PROP Intermediate_Dir ".\output\pjsip _core_vc6_Release"40 # PROP Output_Dir ".\output\pjsip-core-i386-win32-vc6-release" 41 # PROP Intermediate_Dir ".\output\pjsip-core-i386-win32-vc6-release" 42 42 # PROP Target_Dir "" 43 43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 # ADD CPP /nologo /MD /W4 /Zi /O2 /I "../ src" /I "../../pjlib/src" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB"/FR /FD /c44 # ADD CPP /nologo /MD /W4 /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /c 45 45 # SUBTRACT CPP /YX 46 46 # ADD BASE RSC /l 0x409 /d "NDEBUG" … … 51 51 LIB32=link.exe -lib 52 52 # ADD BASE LIB32 /nologo 53 # ADD LIB32 /nologo /out:"../lib/pjsip _core_vc6s.lib"53 # ADD LIB32 /nologo /out:"../lib/pjsip-core-i386-win32-vc6-release.lib" 54 54 55 55 !ELSEIF "$(CFG)" == "pjsip_core - Win32 Debug" … … 57 57 # PROP BASE Use_MFC 0 58 58 # PROP BASE Use_Debug_Libraries 1 59 # PROP BASE Output_Dir " Debug"60 # PROP BASE Intermediate_Dir " Debug"59 # PROP BASE Output_Dir ".\output\pjsip-core-i386-win32-vc6-debug" 60 # PROP BASE Intermediate_Dir ".\output\pjsip-core-i386-win32-vc6-debug" 61 61 # PROP BASE Target_Dir "" 62 62 # PROP Use_MFC 0 63 63 # PROP Use_Debug_Libraries 1 64 # PROP Output_Dir ".\output\pjsip _core_vc6_Debug"65 # PROP Intermediate_Dir ".\output\pjsip _core_vc6_Debug"64 # PROP Output_Dir ".\output\pjsip-core-i386-win32-vc6-debug" 65 # PROP Intermediate_Dir ".\output\pjsip-core-i386-win32-vc6-debug" 66 66 # PROP Target_Dir "" 67 67 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../ src" /I "../../pjlib/src" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB"/FR /FD /GZ /c68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /GZ /c 69 69 # SUBTRACT CPP /YX 70 70 # ADD BASE RSC /l 0x409 /d "_DEBUG" … … 75 75 LIB32=link.exe -lib 76 76 # ADD BASE LIB32 /nologo 77 # ADD LIB32 /nologo /out:"../lib/pjsip _core_vc6sd.lib"77 # ADD LIB32 /nologo /out:"../lib/pjsip-core-i386-win32-vc6-debug.lib" 78 78 79 79 !ENDIF … … 136 136 # Begin Source File 137 137 138 SOURCE=..\src\pjsip_core.h 139 # End Source File 140 # Begin Source File 141 142 SOURCE=..\src\pjsip\print.h 143 # End Source File 144 # Begin Source File 145 146 SOURCE=..\src\pjsip\sip_auth.h 147 # End Source File 148 # Begin Source File 149 150 SOURCE=..\src\pjsip\sip_auth_msg.h 151 # End Source File 152 # Begin Source File 153 154 SOURCE=..\src\pjsip\sip_auth_parser.h 155 # End Source File 156 # Begin Source File 157 158 SOURCE=..\src\pjsip\sip_config.h 159 # End Source File 160 # Begin Source File 161 162 SOURCE=..\src\pjsip\sip_endpoint.h 163 # End Source File 164 # Begin Source File 165 166 SOURCE=..\src\pjsip\sip_event.h 167 # End Source File 168 # Begin Source File 169 170 SOURCE=..\src\pjsip\sip_misc.h 171 # End Source File 172 # Begin Source File 173 174 SOURCE=..\src\pjsip\sip_module.h 175 # End Source File 176 # Begin Source File 177 178 SOURCE=..\src\pjsip\sip_msg.h 179 # End Source File 180 # Begin Source File 181 182 SOURCE=..\src\pjsip\sip_parser.h 183 # End Source File 184 # Begin Source File 185 186 SOURCE=..\src\pjsip\sip_private.h 187 # End Source File 188 # Begin Source File 189 190 SOURCE=..\src\pjsip\sip_resolve.h 191 # End Source File 192 # Begin Source File 193 194 SOURCE=..\src\pjsip\sip_transaction.h 195 # End Source File 196 # Begin Source File 197 198 SOURCE=..\src\pjsip\sip_transport.h 199 # End Source File 200 # Begin Source File 201 202 SOURCE=..\src\pjsip\sip_types.h 203 # End Source File 204 # Begin Source File 205 206 SOURCE=..\src\pjsip\sip_uri.h 138 SOURCE=..\include\pjsip_core.h 139 # End Source File 140 # Begin Source File 141 142 SOURCE=..\include\pjsip\print_util.h 143 # End Source File 144 # Begin Source File 145 146 SOURCE=..\include\pjsip\sip_auth.h 147 # End Source File 148 # Begin Source File 149 150 SOURCE=..\include\pjsip\sip_auth_msg.h 151 # End Source File 152 # Begin Source File 153 154 SOURCE=..\include\pjsip\sip_auth_parser.h 155 # End Source File 156 # Begin Source File 157 158 SOURCE=..\include\pjsip\sip_config.h 159 # End Source File 160 # Begin Source File 161 162 SOURCE=..\include\pjsip\sip_endpoint.h 163 # End Source File 164 # Begin Source File 165 166 SOURCE=..\include\pjsip\sip_errno.h 167 # End Source File 168 # Begin Source File 169 170 SOURCE=..\include\pjsip\sip_event.h 171 # End Source File 172 # Begin Source File 173 174 SOURCE=..\include\pjsip\sip_misc.h 175 # End Source File 176 # Begin Source File 177 178 SOURCE=..\include\pjsip\sip_module.h 179 # End Source File 180 # Begin Source File 181 182 SOURCE=..\include\pjsip\sip_msg.h 183 # End Source File 184 # Begin Source File 185 186 SOURCE=..\include\pjsip\sip_parser.h 187 # End Source File 188 # Begin Source File 189 190 SOURCE=..\include\pjsip\sip_private.h 191 # End Source File 192 # Begin Source File 193 194 SOURCE=..\include\pjsip\sip_resolve.h 195 # End Source File 196 # Begin Source File 197 198 SOURCE=..\include\pjsip\sip_transaction.h 199 # End Source File 200 # Begin Source File 201 202 SOURCE=..\include\pjsip\sip_transport.h 203 # End Source File 204 # Begin Source File 205 206 SOURCE=..\include\pjsip\sip_types.h 207 # End Source File 208 # Begin Source File 209 210 SOURCE=..\include\pjsip\sip_uri.h 207 211 # End Source File 208 212 # End Group … … 212 216 # Begin Source File 213 217 214 SOURCE=..\ src\pjsip\sip_msg_i.h218 SOURCE=..\include\pjsip\sip_msg_i.h 215 219 # End Source File 216 220 # End Group -
pjproject/main/pjsip/build/pjsip_ua.dsp
r1 r43 88 88 # Begin Source File 89 89 90 SOURCE= ..\src\pjsip_mod_ua\sip_dialog.c90 SOURCE="..\src\pjsip-ua\sip_dialog.c" 91 91 # End Source File 92 92 # Begin Source File 93 93 94 SOURCE= ..\src\pjsip_mod_ua\sip_reg.c94 SOURCE="..\src\pjsip-ua\sip_reg.c" 95 95 # End Source File 96 96 # Begin Source File 97 97 98 SOURCE=..\src\pjsip_mod_ua\sip_ua.c 98 SOURCE="..\src\pjsip-ua\sip_ua.c" 99 # End Source File 100 # Begin Source File 101 102 SOURCE="..\src\pjsip-ua\sip_ua_private.h" 99 103 # End Source File 100 104 # End Group -
pjproject/main/pjsip/docs
-
Property
svn:ignore
set to
html
latex
rtf
-
Property
svn:ignore
set to
-
pjproject/main/pjsip/include/pjsip/print_util.h
- Property svn:keywords set to Id
r35 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_PRINT_H__ -
pjproject/main/pjsip/include/pjsip/sip_auth.h
- Property svn:keywords set to Id
r42 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_AUTH_SIP_AUTH_H__ … … 61 60 typedef struct pjsip_cached_auth_hdr 62 61 { 63 PJ_DECL_LIST_MEMBER(struct pjsip_cached_auth_hdr) 62 PJ_DECL_LIST_MEMBER(struct pjsip_cached_auth_hdr); 64 63 65 64 pjsip_method method; … … 81 80 typedef struct pjsip_auth_session 82 81 { 83 PJ_DECL_LIST_MEMBER(struct pjsip_auth_session) 82 PJ_DECL_LIST_MEMBER(struct pjsip_auth_session); 84 83 85 84 pj_str_t realm; -
pjproject/main/pjsip/include/pjsip/sip_auth_msg.h
- Property svn:keywords set to Id
r42 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_AUTH_SIP_AUTH_MSG_H__ … … 69 68 struct pjsip_authorization_hdr 70 69 { 71 PJSIP_DECL_HDR_MEMBER(struct pjsip_authorization_hdr) 70 PJSIP_DECL_HDR_MEMBER(struct pjsip_authorization_hdr); 72 71 pj_str_t scheme; 73 72 union … … 158 157 struct pjsip_www_authenticate_hdr 159 158 { 160 PJSIP_DECL_HDR_MEMBER(struct pjsip_www_authenticate_hdr) 159 PJSIP_DECL_HDR_MEMBER(struct pjsip_www_authenticate_hdr); 161 160 pj_str_t scheme; 162 161 union -
pjproject/main/pjsip/include/pjsip/sip_auth_parser.h
- Property svn:keywords set to Id
r42 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_AUTH_SIP_AUTH_PARSER_H__ … … 25 24 * such as Authorization, WWW-Authenticate, Proxy-Authorizization, and 26 25 * Proxy-Authenticate headers. 26 * 27 * @return PJ_SUCCESS or the appropriate status code. 27 28 */ 28 PJ_DECL( void) pjsip_auth_init_parser();29 PJ_DECL(pj_status_t) pjsip_auth_init_parser(void); 29 30 30 31 /** -
pjproject/main/pjsip/include/pjsip/sip_config.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_CONFIG_H__ … … 134 133 135 134 #include <pj/config.h> 136 #include <pj/compat.h>137 135 138 136 -
pjproject/main/pjsip/include/pjsip/sip_endpoint.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_ENDPOINT_H__ … … 29 28 * all SIP objects in an application. It performs the following roles: 30 29 * - it manages the allocation/deallocation of memory pools for all objects. 31 * - it manages listeners and transports, and how they are used by transactions. 30 * - it manages listeners and transports, and how they are used by 31 * transactions. 32 32 * - it owns transaction hash table. 33 33 * - it receives incoming messages from transport layer and automatically … … 35 35 * - it has a single instance of timer management (timer heap). 36 36 * - it manages modules, which is the primary means of extending the library. 37 * - it provides single polling function for all objects and distributes events. 37 * - it provides single polling function for all objects and distributes 38 * events. 38 39 * - it provides SIP policy such as which outbound proxy to use for all 39 40 * outgoing SIP request messages. … … 50 51 /** 51 52 * Create an instance of SIP endpoint from the specified pool factory. 52 * The pool factory reference then will be kept by the endpoint, so that future 53 * memory allocations by SIP components will be taken from the same pool factory. 54 * 55 * @param pf Pool factory that will be used for the lifetime of endpoint. 56 * 57 * @return the endpoint instance on success. 58 */ 59 PJ_DECL(pjsip_endpoint*) pjsip_endpt_create(pj_pool_factory *pf); 53 * The pool factory reference then will be kept by the endpoint, so that 54 * future memory allocations by SIP components will be taken from the same 55 * pool factory. 56 * 57 * @param pf Pool factory that will be used for the lifetime of 58 * endpoint. 59 * @param name Optional name to be specified for the endpoint. 60 * If this parameter is NULL, then the name will use 61 * local host name. 62 * @param endpt Pointer to receive endpoint instance. 63 * 64 * @return PJ_SUCCESS on success. 65 */ 66 PJ_DECL(pj_status_t) pjsip_endpt_create(pj_pool_factory *pf, 67 pjsip_endpoint **endpt); 60 68 61 69 /** … … 67 75 */ 68 76 PJ_DECL(void) pjsip_endpt_destroy(pjsip_endpoint *endpt); 77 78 /** 79 * Get endpoint name. 80 * 81 * @param endpt The SIP endpoint instance. 82 * 83 * @return Endpoint name, as was registered during endpoint 84 * creation. The string is NULL terminated. 85 */ 86 PJ_DECL(const pj_str_t*) pjsip_endpt_name(const pjsip_endpoint *endpt); 69 87 70 88 /** … … 155 173 * 156 174 * @param endpt The SIP endpoint. 157 * @return The new transaction, or NULL on failure. 158 */ 159 PJ_DECL(pjsip_transaction*) pjsip_endpt_create_tsx(pjsip_endpoint *endpt); 175 * @param p_tsx Pointer to receive the transaction. 176 * 177 * @return PJ_SUCCESS or the appropriate error code. 178 */ 179 PJ_DECL(pj_status_t) pjsip_endpt_create_tsx(pjsip_endpoint *endpt, 180 pjsip_transaction **p_tsx); 160 181 161 182 /** … … 188 209 * This function, like all other endpoint functions, is thread safe. 189 210 * 190 * @param endpt the endpoint. 191 * @return new transmit data. 192 */ 193 PJ_DECL(pjsip_tx_data*) pjsip_endpt_create_tdata( pjsip_endpoint *endpt ); 211 * @param endpt The endpoint. 212 * @param p_tdata Pointer to receive transmit data buffer. 213 * 214 * @return PJ_SUCCESS or the appropriate error code. 215 */ 216 PJ_DECL(pj_status_t) pjsip_endpt_create_tdata( pjsip_endpoint *endpt, 217 pjsip_tx_data **p_tdata); 194 218 195 219 /** … … 333 357 334 358 /** 359 * Log an error. 360 */ 361 PJ_DECL(void) pjsip_endpt_log_error( pjsip_endpoint *endpt, 362 const char *sender, 363 pj_status_t error_code, 364 const char *format, 365 ... ); 366 367 #define PJSIP_ENDPT_LOG_ERROR(expr) \ 368 pjsip_endpt_log_error expr 369 370 #define PJSIP_ENDPT_TRACE(tracing,expr) \ 371 do { \ 372 if ((tracing)) \ 373 PJ_LOG(4,expr); \ 374 } while (0) 375 376 /** 335 377 * @} 336 378 */ -
pjproject/main/pjsip/include/pjsip/sip_event.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_EVENT_H__ … … 26 25 { 27 26 /** Unidentified event. */ 28 PJSIP_EVENT_UN IDENTIFIED,27 PJSIP_EVENT_UNKNOWN, 29 28 30 29 /** Timer event, normally only used internally in transaction. */ … … 41 40 42 41 /** Transaction state changed event. */ 43 PJSIP_EVENT_TSX_STATE _CHANGED,42 PJSIP_EVENT_TSX_STATE, 44 43 45 44 /** 2xx response received event. */ 46 PJSIP_EVENT_RX_200_ RESPONSE,45 PJSIP_EVENT_RX_200_MSG, 47 46 48 47 /** ACK request received event. */ … … 56 55 57 56 /** On before transmitting message. */ 58 PJSIP_EVENT_ BEFORE_TX,57 PJSIP_EVENT_PRE_TX_MSG, 59 58 60 59 } pjsip_event_id_e; … … 77 76 { 78 77 /** This is necessary so that we can put events as a list. */ 79 PJ_DECL_LIST_MEMBER(struct pjsip_event) 78 PJ_DECL_LIST_MEMBER(struct pjsip_event); 80 79 81 80 /** The event type, can be any value of \b pjsip_event_id_e. 82 * @see pjsip_event_id_e83 81 */ 84 82 pjsip_event_id_e type; 85 83 86 /** This field determines what is the content of \b src (source data). 87 */ 88 pjsip_event_id_e src_type; 89 90 /** Source data, which content is dependent on \b src_type. 91 * - if src_type==PJSIP_EVENT_RX_MSG, src.rdata is valid. 92 * - if src_type==PJSIP_EVENT_TX_MSG, src.tdata is valid. 93 * - if src_type==PJSIP_EVENT_TIMER, src.timer is valid. 84 /* 85 * The event body. 86 * By convention, the first member of each struct in the union must be 87 * the pointer which is relevant to the event. 94 88 */ 95 89 union 96 90 { 97 pjsip_rx_data *rdata; 98 pjsip_tx_data *tdata; 99 pj_timer_entry *timer; 100 void *data; 101 unsigned long udata; 102 } src; 103 104 /** The object that generates this event. */ 105 union 106 { 107 pjsip_transaction *tsx; 108 void *ptr; 109 unsigned long udata; 110 } obj; 111 112 /** Other data. */ 113 union 114 { 115 long long_data; 116 void * ptr_data; 117 } data; 91 /** Timer event. */ 92 struct 93 { 94 pj_timer_entry *entry; /**< The timer entry. */ 95 } timer; 96 97 /** Transaction state has changed event. */ 98 struct 99 { 100 union 101 { 102 pjsip_rx_data *rdata; /**< The incoming message. */ 103 pjsip_tx_data *tdata; /**< The outgoing message. */ 104 pj_timer_entry *timer; /**< The timer. */ 105 pj_status_t status;/**< Transport error status. */ 106 void *data; /**< Generic data. */ 107 } src; 108 pjsip_transaction *tsx; /**< The transaction. */ 109 pjsip_event_id_e type; /**< Type of event source: 110 * - PJSIP_EVENT_TX_MSG 111 * - PJSIP_EVENT_RX_MSG, 112 * - PJSIP_EVENT_TRANSPORT_ERROR 113 * - PJSIP_EVENT_TIMER 114 * - PJSIP_EVENT_USER 115 */ 116 } tsx_state; 117 118 /** Message transmission event. */ 119 struct 120 { 121 pjsip_tx_data *tdata; /**< The transmit data buffer. */ 122 pjsip_transaction *tsx; /**< The transaction. */ 123 124 } tx_msg; 125 126 /** Pre-transmission event. */ 127 struct 128 { 129 pjsip_tx_data *tdata; /**< Msg to be transmitted. */ 130 pjsip_transaction *tsx; /**< The transaction. */ 131 int retcnt;/**< Retransmission count. */ 132 } pre_tx_msg; 133 134 /** Transmission error event. */ 135 struct 136 { 137 pjsip_tx_data *tdata; /**< The transmit data. */ 138 pjsip_transaction *tsx; /**< The transaction. */ 139 } tx_error; 140 141 /** Message arrival event. */ 142 struct 143 { 144 pjsip_rx_data *rdata; /**< The receive data buffer. */ 145 pjsip_transaction *tsx; /**< The transaction. */ 146 } rx_msg; 147 148 /** Receipt of 200/INVITE response. */ 149 struct 150 { 151 pjsip_rx_data *rdata; /**< The 200 response msg. */ 152 } rx_200_msg; 153 154 /** Receipt of ACK message. */ 155 struct 156 { 157 pjsip_rx_data *rdata; /**< The ack message. */ 158 } rx_ack_msg; 159 160 /** Notification that endpoint has discarded a message. */ 161 struct 162 { 163 pjsip_rx_data *rdata; /**< The discarded message. */ 164 pj_status_t reason;/**< The reason. */ 165 } discard_msg; 166 167 /** User event. */ 168 struct 169 { 170 void *user1; /**< User data 1. */ 171 void *user2; /**< User data 2. */ 172 void *user3; /**< User data 3. */ 173 void *user4; /**< User data 4. */ 174 } user; 175 176 } body; 118 177 }; 178 179 /** 180 * Init timer event. 181 */ 182 #define PJSIP_EVENT_INIT_TIMER(event,pentry) \ 183 do { \ 184 (event).type = PJSIP_EVENT_TIMER; \ 185 (event).body.timer.entry = pentry; \ 186 } while (0) 187 188 /** 189 * Init tsx state event. 190 */ 191 #define PJSIP_EVENT_INIT_TSX_STATE(event,ptsx,ptype,pdata) \ 192 do { \ 193 (event).type = PJSIP_EVENT_TSX_STATE; \ 194 (event).body.tsx_state.tsx = ptsx; \ 195 (event).body.tsx_state.type = ptype; \ 196 (event).body.tsx_state.src.data = pdata; \ 197 } while (0) 198 199 /** 200 * Init tx msg event. 201 */ 202 #define PJSIP_EVENT_INIT_TX_MSG(event,ptsx,ptdata) \ 203 do { \ 204 (event).type = PJSIP_EVENT_TX_MSG; \ 205 (event).body.tx_msg.tsx = ptsx; \ 206 (event).body.tx_msg.tdata = ptdata; \ 207 } while (0) 208 209 /** 210 * Init rx msg event. 211 */ 212 #define PJSIP_EVENT_INIT_RX_MSG(event,ptsx,prdata) \ 213 do { \ 214 (event).type = PJSIP_EVENT_RX_MSG; \ 215 (event).body.rx_msg.tsx = ptsx; \ 216 (event).body.rx_msg.rdata = prdata; \ 217 } while (0) 218 219 /** 220 * Init transport error event. 221 */ 222 #define PJSIP_EVENT_INIT_TRANSPORT_ERROR(event,ptsx,ptdata) \ 223 do { \ 224 (event).type = PJSIP_EVENT_TRANSPORT_ERROR; \ 225 (event).body.tx_error.tsx = ptsx; \ 226 (event).body.tx_error.tdata = ptdata; \ 227 } while (0) 228 229 /** 230 * Init rx 200/INVITE event. 231 */ 232 #define PJSIP_EVENT_INIT_RX_200_MSG(event,prdata) \ 233 do { \ 234 (event).type = PJSIP_EVENT_RX_200_MSG; \ 235 (event).body.rx_200_msg.rdata = prdata; \ 236 } while (0) 237 238 /** 239 * Init rx ack msg event. 240 */ 241 #define PJSIP_EVENT_INIT_RX_ACK_MSG(event,prdata) \ 242 do { \ 243 (event).type = PJSIP_EVENT_RX_ACK_MSG; \ 244 (event).body.rx_ack_msg.rdata = prdata; \ 245 } while (0) 246 247 /** 248 * Init discard msg event. 249 */ 250 #define PJSIP_EVENT_INIT_DISCARD_MSG(event,prdata,preason) \ 251 do { \ 252 (event).type = PJSIP_EVENT_DISCARD_MSG; \ 253 (event).body.discard_msg.rdata = prdata; \ 254 (event).body.discard_msg.reason = preason; \ 255 } while (0) 256 257 /** 258 * Init user event. 259 */ 260 #define PJSIP_EVENT_INIT_USER(event,u1,u2,u3,u4) \ 261 do { \ 262 (event).type = PJSIP_EVENT_USER; \ 263 (event).body.user.user1 = (void*)u1; \ 264 (event).body.user.user2 = (void*)u2; \ 265 (event).body.user.user3 = (void*)u3; \ 266 (event).body.user.user4 = (void*)u4; \ 267 } while (0) 268 269 /** 270 * Init pre tx msg event. 271 */ 272 #define PJSIP_EVENT_INIT_PRE_TX_MSG(event,ptsx,ptdata,pretcnt) \ 273 do { \ 274 (event).type = PJSIP_EVENT_PRE_TX_MSG; \ 275 (event).body.pre_tx_msg.tsx = ptsx; \ 276 (event).body.pre_tx_msg.tdata = ptdata; \ 277 (event).body.pre_tx_msg.retcnt = pretcnt; \ 278 } while (0) 279 119 280 120 281 /** -
pjproject/main/pjsip/include/pjsip/sip_misc.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_MISC_H__ … … 31 30 * @param cseq Optional CSeq (put -1 to generate random CSeq). 32 31 * @param text Optional text body (put NULL to omit body). 32 * @param p_tdata Pointer to receive the transmit data. 33 33 * 34 * @return The transmit data.34 * @return PJ_SUCCESS, or the appropriate error code. 35 35 */ 36 PJ_DECL(pjsip_tx_data*) pjsip_endpt_create_request( pjsip_endpoint *endpt, 37 const pjsip_method *method, 38 const pj_str_t *target, 39 const pj_str_t *from, 40 const pj_str_t *to, 41 const pj_str_t *contact, 42 const pj_str_t *call_id, 43 int cseq, 44 const pj_str_t *text); 36 PJ_DECL(pj_status_t) pjsip_endpt_create_request( pjsip_endpoint *endpt, 37 const pjsip_method *method, 38 const pj_str_t *target, 39 const pj_str_t *from, 40 const pj_str_t *to, 41 const pj_str_t *contact, 42 const pj_str_t *call_id, 43 int cseq, 44 const pj_str_t *text, 45 pjsip_tx_data **p_tdata); 45 46 46 47 /** … … 59 60 * @param cseq Optional CSeq (put -1 to generate random CSeq). 60 61 * @param text Optional text body (put NULL to omit body). 62 * @param p_tdata Pointer to receive the transmit data. 61 63 * 62 * @return The transmit data.64 * @return PJ_SUCCESS, or the appropriate error code. 63 65 */ 64 PJ_DECL(pj sip_tx_data*)66 PJ_DECL(pj_status_t) 65 67 pjsip_endpt_create_request_from_hdr( pjsip_endpoint *endpt, 66 68 const pjsip_method *method, … … 71 73 const pjsip_cid_hdr *call_id, 72 74 int cseq, 73 const pj_str_t *text ); 75 const pj_str_t *text, 76 pjsip_tx_data **p_tdata); 74 77 75 78 /** … … 90 93 * the completion of the transaction. 91 94 * 92 * @return Zero if transaction is started successfully.95 * @return PJ_SUCCESS, or the appropriate error code. 93 96 */ 94 97 PJ_DECL(pj_status_t) pjsip_endpt_send_request( pjsip_endpoint *endpt, … … 108 111 * @param rdata The request receive data. 109 112 * @param code Status code to be put in the response. 113 * @param p_tdata Pointer to receive the transmit data. 110 114 * 111 * @return Transmit data.115 * @return PJ_SUCCESS, or the appropriate error code. 112 116 */ 113 PJ_DECL(pjsip_tx_data*) pjsip_endpt_create_response(pjsip_endpoint *endpt, 114 const pjsip_rx_data *rdata, 115 int code); 117 PJ_DECL(pj_status_t) pjsip_endpt_create_response( pjsip_endpoint *endpt, 118 const pjsip_rx_data *rdata, 119 int code, 120 pjsip_tx_data **p_tdata); 116 121 117 122 /** … … 137 142 * @param endpt The endpoint. 138 143 * @param tdata The transmit buffer for the request being cancelled. 144 * @param p_tdata Pointer to receive the transmit data. 139 145 * 140 * @return Cancel request.146 * @return PJ_SUCCESS, or the appropriate error code. 141 147 */ 142 PJ_DECL(pjsip_tx_data*) pjsip_endpt_create_cancel( pjsip_endpoint *endpt, 143 pjsip_tx_data *tdata ); 148 PJ_DECL(pj_status_t) pjsip_endpt_create_cancel( pjsip_endpoint *endpt, 149 pjsip_tx_data *tdata, 150 pjsip_tx_data **p_tdata); 144 151 145 152 … … 160 167 pjsip_host_port *addr); 161 168 162 163 169 /** 164 170 * @} -
pjproject/main/pjsip/include/pjsip/sip_module.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_MODULE_H__ -
pjproject/main/pjsip/include/pjsip/sip_msg.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_MSG_H__ … … 261 260 #define PJSIP_DECL_HDR_MEMBER(hdr) \ 262 261 /** List members. */ \ 263 PJ_DECL_LIST_MEMBER(hdr) \262 PJ_DECL_LIST_MEMBER(hdr); \ 264 263 /** Header type */ \ 265 264 pjsip_hdr_e type; \ … … 269 268 pj_str_t sname; \ 270 269 /** Virtual function table. */ \ 271 pjsip_hdr_vptr *vptr ;270 pjsip_hdr_vptr *vptr 272 271 273 272 … … 276 275 * message. All header fields can be typecasted to this type. 277 276 */ 278 typedefstruct pjsip_hdr279 { 280 PJSIP_DECL_HDR_MEMBER(struct pjsip_hdr) 281 } pjsip_hdr;277 struct pjsip_hdr 278 { 279 PJSIP_DECL_HDR_MEMBER(struct pjsip_hdr); 280 }; 282 281 283 282 … … 688 687 * value if the message is too large for the specified buffer. 689 688 */ 690 PJ_DECL( int) pjsip_msg_print(pjsip_msg *msg, char *buf, pj_size_t size);689 PJ_DECL(pj_ssize_t) pjsip_msg_print(pjsip_msg *msg, char *buf, pj_size_t size); 691 690 692 691 /** … … 708 707 typedef struct pjsip_generic_string_hdr 709 708 { 710 PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_string_hdr) /**< Standard header field. */709 PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_string_hdr); /**< Standard header field. */ 711 710 pj_str_t hvalue; /**< hvalue */ 712 711 } pjsip_generic_string_hdr; … … 757 756 typedef struct pjsip_generic_int_hdr 758 757 { 759 PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_int_hdr) /**< Standard header field. */758 PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_int_hdr); /**< Standard header field. */ 760 759 pj_int32_t ivalue; /**< ivalue */ 761 760 } pjsip_generic_int_hdr; … … 806 805 typedef struct pjsip_generic_array_hdr 807 806 { 808 PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_array_hdr) 807 PJSIP_DECL_HDR_MEMBER(struct pjsip_generic_array_hdr); 809 808 unsigned count; /**< Number of elements. */ 810 809 pj_str_t values[PJSIP_GENERIC_ARRAY_MAX_COUNT]; /**< Elements. */ … … 887 886 typedef struct pjsip_cid_hdr 888 887 { 889 PJSIP_DECL_HDR_MEMBER(struct pjsip_cid_hdr) 888 PJSIP_DECL_HDR_MEMBER(struct pjsip_cid_hdr); 890 889 pj_str_t id; /**< Call-ID string. */ 891 890 } pjsip_cid_hdr; … … 918 917 typedef struct pjsip_clen_hdr 919 918 { 920 PJSIP_DECL_HDR_MEMBER(struct pjsip_clen_hdr) 919 PJSIP_DECL_HDR_MEMBER(struct pjsip_clen_hdr); 921 920 int len; /**< Content length. */ 922 921 } pjsip_clen_hdr; … … 946 945 typedef struct pjsip_cseq_hdr 947 946 { 948 PJSIP_DECL_HDR_MEMBER(struct pjsip_cseq_hdr) 947 PJSIP_DECL_HDR_MEMBER(struct pjsip_cseq_hdr); 949 948 int cseq; /**< CSeq number. */ 950 949 pjsip_method method; /**< CSeq method. */ … … 978 977 typedef struct pjsip_contact_hdr 979 978 { 980 PJSIP_DECL_HDR_MEMBER(struct pjsip_contact_hdr) 979 PJSIP_DECL_HDR_MEMBER(struct pjsip_contact_hdr); 981 980 int star; /**< The contact contains only a '*' character */ 982 981 pjsip_uri *uri; /**< URI in the contact. */ … … 1011 1010 typedef struct pjsip_ctype_hdr 1012 1011 { 1013 PJSIP_DECL_HDR_MEMBER(struct pjsip_ctype_hdr) 1012 PJSIP_DECL_HDR_MEMBER(struct pjsip_ctype_hdr); 1014 1013 pjsip_media_type media; /**< Media type. */ 1015 1014 } pjsip_ctype_hdr; … … 1062 1061 typedef struct pjsip_fromto_hdr 1063 1062 { 1064 PJSIP_DECL_HDR_MEMBER(struct pjsip_fromto_hdr) 1063 PJSIP_DECL_HDR_MEMBER(struct pjsip_fromto_hdr); 1065 1064 pjsip_uri *uri; /**< URI in From/To header. */ 1066 1065 pj_str_t tag; /**< Header "tag" parameter. */ … … 1171 1170 typedef struct pjsip_routing_hdr 1172 1171 { 1173 PJSIP_DECL_HDR_MEMBER(struct pjsip_routing_hdr) /**< Generic header fields. */1172 PJSIP_DECL_HDR_MEMBER(struct pjsip_routing_hdr); /**< Generic header fields. */ 1174 1173 pjsip_name_addr name_addr; /**< The URL in the Route/Record-Route header. */ 1175 1174 pj_str_t other_param; /** Other parameter. */ … … 1328 1327 typedef struct pjsip_via_hdr 1329 1328 { 1330 PJSIP_DECL_HDR_MEMBER(struct pjsip_via_hdr) 1329 PJSIP_DECL_HDR_MEMBER(struct pjsip_via_hdr); 1331 1330 pj_str_t transport; /**< Transport type. */ 1332 1331 pjsip_host_port sent_by; /**< Host and optional port */ -
pjproject/main/pjsip/include/pjsip/sip_msg_i.h
- Property svn:keywords set to Id
-
pjproject/main/pjsip/include/pjsip/sip_parser.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_PARSER_H__ … … 11 10 12 11 #include <pjsip/sip_types.h> 13 #include <pj /scanner.h>12 #include <pjlib-util/scanner.h> 14 13 #include <pj/list.h> 15 14 … … 52 51 typedef struct pjsip_parser_err_report 53 52 { 54 PJ_DECL_LIST_MEMBER(struct pjsip_parser_err_report) 53 PJ_DECL_LIST_MEMBER(struct pjsip_parser_err_report); 55 54 int exception_code; /**< Error exception (e.g. PJSIP_SYN_ERR_EXCEPTION) */ 56 55 int line; /**< Line number. */ … … 58 57 pj_str_t hname; /**< Header name, if any. */ 59 58 } pjsip_parser_err_report; 59 60 61 /** 62 * Parsing context, the default argument for parsing functions. 63 */ 64 typedef struct pjsip_parse_ctx 65 { 66 pj_scanner *scanner; /**< The scanner. */ 67 pj_pool_t *pool; /**< The pool. */ 68 pjsip_rx_data *rdata; /**< Optional rdata. */ 69 } pjsip_parse_ctx; 60 70 61 71 … … 77 87 * can be terminated when seeing EOF. 78 88 */ 79 typedef void* (pjsip_parse_hdr_func)(pj_scanner *scanner, pj_pool_t *pool);89 typedef pjsip_hdr* (pjsip_parse_hdr_func)(pjsip_parse_ctx *context); 80 90 81 91 /** … … 95 105 * @param fptr The pointer to function to parser the header. 96 106 * 97 * @return zero if success. 98 * @see pjsip_parse_hdr_func 107 * @return PJ_SUCCESS if success, or the appropriate error code. 99 108 */ 100 109 PJ_DECL(pj_status_t) pjsip_register_hdr_parser( const char *hname, … … 186 195 187 196 /** 197 * Parse a packet buffer and build a rdata. The resulting message will be 198 * stored in \c msg field in the \c rdata. This behaves pretty much like 199 * #pjsip_parse_msg(), except that it will also initialize the header fields 200 * in the \c rdata. 201 * 202 * This function is normally called by the transport layer. 203 * 204 * @param buf The input buffer 205 * @param buf The input buffer, which size must be at least (size+1) 206 * because the function will temporarily put NULL 207 * termination at the end of the buffer during parsing. 208 * @param size The length of the string (not counting NULL terminator). 209 * @param rdata The receive data buffer to store the message and 210 * its elements. 211 * 212 * @return The message inside the rdata if successfull, or NULL. 213 */ 214 PJ_DECL(pjsip_msg *) pjsip_parse_rdata( char *buf, pj_size_t size, 215 pjsip_rx_data *rdata ); 216 217 /** 188 218 * Check incoming packet to see if a (probably) valid SIP message has been 189 219 * received. … … 194 224 * the size of the SIP message (including body, if any). 195 225 * 196 * @return PJ_TRUE (1) if a message is found. 197 */ 198 PJ_DECL(pj_bool_t) pjsip_find_msg( const char *buf, pj_size_t size, 199 pj_bool_t is_datagram, pj_size_t *msg_size); 226 * @return PJ_SUCCESS if a message is found, or an error code. 227 */ 228 PJ_DECL(pj_status_t) pjsip_find_msg(const char *buf, 229 pj_size_t size, 230 pj_bool_t is_datagram, 231 pj_size_t *msg_size); 200 232 201 233 /** … … 248 280 */ 249 281 extern 250 pj_c har_specpjsip_HOST_SPEC, /* For scanning host part. */282 pj_cis_t pjsip_HOST_SPEC, /* For scanning host part. */ 251 283 pjsip_DIGIT_SPEC, /* Decimal digits */ 252 284 pjsip_ALPHA_SPEC, /* Alpha (A-Z, a-z) */ -
pjproject/main/pjsip/include/pjsip/sip_private.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_PRIVATE_H__ … … 27 26 * @param cb Callback to be called to receive messages from transport. 28 27 */ 29 PJ_DECL(pjsip_transport_mgr*) pjsip_transport_mgr_create( pj_pool_t *pool, 30 pjsip_endpoint *endpt, 31 void (*cb)(pjsip_endpoint *,pjsip_rx_data *)); 28 PJ_DECL(pj_status_t) pjsip_transport_mgr_create( pj_pool_t *pool, 29 pjsip_endpoint *endpt, 30 void (*cb)(pjsip_endpoint *, 31 pjsip_rx_data *), 32 pjsip_transport_mgr **); 32 33 33 34 … … 36 37 * @param mgr Transport manager to be destroyed. 37 38 */ 38 PJ_DECL( void) pjsip_transport_mgr_destroy( pjsip_transport_mgr *mgr );39 PJ_DECL(pj_status_t) pjsip_transport_mgr_destroy( pjsip_transport_mgr *mgr ); 39 40 40 41 /** -
pjproject/main/pjsip/include/pjsip/sip_resolve.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_RESOLVE_H__ -
pjproject/main/pjsip/include/pjsip/sip_transaction.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_TRANSACTION_H__ … … 12 11 #include <pjsip/sip_msg.h> 13 12 #include <pjsip/sip_resolve.h> 14 //#include <pjsip/sip_config.h>15 //#include <pjsip/sip_endpoint.h>16 13 #include <pj/timer.h> 17 14 … … 24 21 */ 25 22 23 /* Forward decl. */ 26 24 struct pjsip_transaction; 27 25 … … 62 60 struct pjsip_transaction 63 61 { 64 pj_pool_t *pool; 65 pjsip_endpoint *endpt; 66 char obj_name[PJ_MAX_OBJ_NAME]; 67 pjsip_role_e role; 68 int status_code; 69 pjsip_tsx_state_e state; 70 int (*state_handler)(struct pjsip_transaction *, pjsip_event *); 71 72 pj_mutex_t *mutex; 73 pjsip_method method; 74 int cseq; 75 pj_str_t transaction_key; 76 pj_str_t branch; 77 78 pjsip_tsx_transport_state_e transport_state; 79 pjsip_host_port dest_name; 80 int current_addr; 81 pjsip_server_addresses remote_addr; 82 pjsip_transport_t *transport; 83 84 pjsip_tx_data *last_tx; 85 int has_unsent_msg; 86 int handle_ack; 87 int retransmit_count; 88 89 pj_timer_entry retransmit_timer; 90 pj_timer_entry timeout_timer; 62 /* 63 * Administrivia 64 */ 65 pj_pool_t *pool; /**< Pool owned by the tsx. */ 66 pjsip_endpoint *endpt; /**< Endpoint instance. */ 67 pj_mutex_t *mutex; /**< Mutex for this tsx. */ 68 char obj_name[PJ_MAX_OBJ_NAME]; /**< Tsx name. */ 69 int tracing; /**< Tracing enabled? */ 70 71 /* 72 * Transaction identification. 73 */ 74 pjsip_role_e role; /**< Role (UAS or UAC) */ 75 pjsip_method method; /**< The method. */ 76 int cseq; /**< The CSeq */ 77 pj_str_t transaction_key;/**< hash table key. */ 78 pj_str_t branch; /**< The branch Id. */ 79 80 /* 81 * State and status. 82 */ 83 int status_code; /**< Last status code seen. */ 84 pjsip_tsx_state_e state; /**< State. */ 85 int handle_ack; /**< Should we handle ACK? */ 86 87 /** Handler according to current state. */ 88 pj_status_t (*state_handler)(struct pjsip_transaction *, pjsip_event *); 89 90 /* 91 * Transport. 92 */ 93 pjsip_tsx_transport_state_e transport_state;/**< Transport's state. */ 94 pjsip_host_port dest_name; /**< Destination address. */ 95 pjsip_server_addresses remote_addr; /**< Addresses resolved. */ 96 int current_addr; /**< Address currently used. */ 97 98 pjsip_transport_t *transport; /**< Transport to use. */ 99 100 /* 101 * Messages and timer. 102 */ 103 pjsip_tx_data *last_tx; /**< Msg kept for retrans. */ 104 int has_unsent_msg; /**< Non-zero if tsx need to 105 transmit msg once resolver 106 completes. */ 107 int retransmit_count;/**< Retransmission count. */ 108 pj_timer_entry retransmit_timer;/**< Retransmit timer. */ 109 pj_timer_entry timeout_timer; /**< Timeout timer. */ 110 111 /** Module specific data. */ 91 112 void *module_data[PJSIP_MAX_MODULE]; 92 113 }; … … 94 115 95 116 /** 96 * Init transaction as UAC. 97 * @param tsx the transaction. 98 * @param tdata the transmit data. 99 * @return PJ_SUCCESS if successfull. 117 * Init transaction as UAC from the specified transmit data (\c tdata). 118 * The transmit data must have a valid \c Request-Line and \c CSeq header. 119 * If \c Route headers are present, it will be used to calculate remote 120 * destination. 121 * 122 * If \c Via header does not exist, it will be created along with a unique 123 * \c branch parameter. If it exists and contains branch parameter, then 124 * the \c branch parameter will be used as is as the transaction key. 125 * 126 * The \c Route headers in the transmit data, if present, are used to 127 * calculate remote destination. 128 * 129 * At the end of the function, the transaction will start resolving the 130 * addresses of remote server to contact. Transport will be acquired as soon 131 * as the resolving job completes. 132 * 133 * @param tsx The transaction. 134 * @param tdata The transmit data. 135 * 136 * @return PJ_SUCCESS if successfull. 100 137 */ 101 138 PJ_DECL(pj_status_t) pjsip_tsx_init_uac( pjsip_transaction *tsx, … … 104 141 /** 105 142 * Init transaction as UAS. 106 * @param tsx the transaction to be initialized. 107 * @param rdata the received incoming request. 143 * 144 * @param tsx The transaction to be initialized. 145 * @param rdata The received incoming request. 146 * 108 147 * @return PJ_SUCCESS if successfull. 109 148 */ … … 113 152 /** 114 153 * Process incoming message for this transaction. 115 * @param tsx the transaction. 116 * @param rdata the incoming message. 154 * 155 * @param tsx The transaction. 156 * @param rdata The incoming message. 117 157 */ 118 158 PJ_DECL(void) pjsip_tsx_on_rx_msg( pjsip_transaction *tsx, … … 121 161 /** 122 162 * Transmit message with this transaction. 123 * @param tsx the transaction. 124 * @param tdata the outgoing message. 163 * 164 * @param tsx The transaction. 165 * @param tdata The outgoing message. 125 166 */ 126 167 PJ_DECL(void) pjsip_tsx_on_tx_msg( pjsip_transaction *tsx, … … 135 176 * transaction will comply with RFC-3261, i.e. it will set itself to 136 177 * TERMINATED state when it receives 2xx/INVITE. 137 * @param tsx The transaction. 138 * @param tdata The ACK request. 178 * 179 * @param tsx The transaction. 180 * @param tdata The ACK request. 139 181 */ 140 182 PJ_DECL(void) pjsip_tsx_on_tx_ack( pjsip_transaction *tsx, … … 142 184 143 185 /** 144 * Forcely terminate transaction. 145 * @param tsx the transaction. 146 * @param code the status code to report. 186 * Force terminate transaction. 187 * 188 * @param tsx The transaction. 189 * @param code The status code to report. 147 190 */ 148 191 PJ_DECL(void) pjsip_tsx_terminate( pjsip_transaction *tsx, … … 152 195 * Create transaction key, which is used to match incoming requests 153 196 * or response (retransmissions) against transactions. 154 * @param pool The pool 155 * @param key Output key. 156 * @param role The role of the transaction. 157 * @param method The method to be put as a key. 158 * @param rdata The received data to calculate. 159 */ 160 PJ_DECL(void) pjsip_tsx_create_key( pj_pool_t *pool, 161 pj_str_t *key, 162 pjsip_role_e role, 163 const pjsip_method *method, 164 const pjsip_rx_data *rdata ); 197 * 198 * @param pool The pool 199 * @param key Output key. 200 * @param role The role of the transaction. 201 * @param method The method to be put as a key. 202 * @param rdata The received data to calculate. 203 * 204 * @return PJ_SUCCESS or the appropriate error code. 205 */ 206 PJ_DECL(pj_status_t) pjsip_tsx_create_key( pj_pool_t *pool, 207 pj_str_t *key, 208 pjsip_role_e role, 209 const pjsip_method *method, 210 const pjsip_rx_data *rdata ); 211 165 212 166 213 /** … … 184 231 185 232 /* Thread Local Storage ID for transaction lock (initialized by endpoint) */ 186 extern intpjsip_tsx_lock_tls_id;233 extern long pjsip_tsx_lock_tls_id; 187 234 188 235 PJ_END_DECL -
pjproject/main/pjsip/include/pjsip/sip_transport.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_TRANSPORT_H__ … … 14 13 #include <pj/sock.h> 15 14 #include <pj/list.h> 15 #include <pj/ioqueue.h> 16 16 17 17 PJ_BEGIN_DECL … … 37 37 struct pjsip_rx_data 38 38 { 39 PJ_DECL_LIST_MEMBER(struct pjsip_rx_data)39 //PJ_DECL_LIST_MEMBER(struct pjsip_rx_data); 40 40 41 41 /** Memory pool for this buffer. */ 42 42 pj_pool_t *pool; 43 44 /** Ioqueue op key. */ 45 pj_ioqueue_op_key_t op_key; 43 46 44 47 /** Time when the message was received. */ … … 74 77 pjsip_from_hdr *from; 75 78 76 /** The tag in the From header as found in the message. */77 pj_str_t from_tag;78 79 79 /** The To header as found in the message. */ 80 80 pjsip_to_hdr *to; 81 81 82 /** The To tag header as found in the message. */83 pj_str_t to_tag;84 85 82 /** The topmost Via header as found in the message. */ 86 83 pjsip_via_hdr *via; … … 88 85 /** The CSeq header as found in the message. */ 89 86 pjsip_cseq_hdr *cseq; 87 88 /** Max forwards header. */ 89 pjsip_max_forwards_hdr *max_fwd; 90 91 /** The first route header. */ 92 pjsip_route_hdr *route; 93 94 /** The first record-route header. */ 95 pjsip_rr_hdr *record_route; 96 97 /** Content-type header. */ 98 pjsip_ctype_hdr *ctype; 99 100 /** Content-length header. */ 101 pjsip_clen_hdr *clen; 102 103 /** The first Require header. */ 104 pjsip_require_hdr *require; 90 105 91 106 /** The list of error generated by the parser when parsing this message. */ … … 110 125 struct pjsip_tx_data 111 126 { 112 PJ_DECL_LIST_MEMBER(struct pjsip_tx_data) 127 PJ_DECL_LIST_MEMBER(struct pjsip_tx_data); 113 128 114 129 /** Memory pool for this buffer. */ … … 127 142 /** The transport manager for this buffer. */ 128 143 pjsip_transport_mgr *mgr; 144 145 /** Ioqueue asynchronous operation key. */ 146 pj_ioqueue_op_key_t op_key; 129 147 130 148 /** The message in this buffer. */ … … 357 375 * @param tdata The outgoing message buffer. 358 376 * @param addr The remote address. 359 * 360 * @return The number of bytes sent, or zero if the connection 361 * has closed, or -1 on error. 362 */ 363 PJ_DECL(int) pjsip_transport_send_msg( pjsip_transport_t *tr, 364 pjsip_tx_data *tdata, 365 const pj_sockaddr_in *addr); 377 * @param sent If not null, it will be filled up with the length of 378 * data sent. 379 * 380 * @return PJ_SUCCESS on success, or the appropriate error code. 381 */ 382 PJ_DECL(pj_status_t) pjsip_transport_send_msg( pjsip_transport_t *tr, 383 pjsip_tx_data *tdata, 384 const pj_sockaddr_in *addr, 385 pj_ssize_t *sent); 366 386 367 387 … … 387 407 * @return The transmit buffer data, or NULL on error. 388 408 */ 389 pjsip_tx_data* pjsip_tx_data_create( pjsip_transport_mgr *mgr ); 409 pj_status_t pjsip_tx_data_create( pjsip_transport_mgr *mgr, 410 pjsip_tx_data **tdata ); 390 411 391 412 -
pjproject/main/pjsip/include/pjsip/sip_types.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_TYPES_H__ … … 74 73 75 74 /** 75 * Forward declaration for header field (sip_msg.h). 76 */ 77 typedef struct pjsip_hdr pjsip_hdr; 78 79 /** 76 80 * Forward declaration for URI (sip_uri.h). 77 81 */ … … 135 139 136 140 141 /** 142 * Convert exception ID into pj_status_t status. 143 * 144 * @param exception_id Exception Id. 145 * 146 * @return Error code for the specified exception Id. 147 */ 148 PJ_DECL(pj_status_t) pjsip_exception_to_status(int exception_id); 149 150 /** 151 * Return standard pj_status_t status from current exception. 152 */ 153 #define PJSIP_RETURN_EXCEPTION() pjsip_exception_to_status(PJ_GET_EXCEPTION()) 154 155 /** 156 * Attributes to inform that the function may throw exceptions. 157 */ 158 #define PJSIP_THROW_SPEC(list) 159 137 160 #endif /* __PJSIP_SIP_TYPES_H__ */ 138 161 -
pjproject/main/pjsip/include/pjsip/sip_uri.h
- Property svn:keywords set to Id
r38 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_SIP_URI_H__ -
pjproject/main/pjsip/include/pjsip_auth.h
- Property svn:keywords set to Id
-
pjproject/main/pjsip/include/pjsip_core.h
- Property svn:keywords set to Id
r42 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #ifndef __PJSIP_CORE_H__ -
pjproject/main/pjsip/include/pjsip_simple.h
- Property svn:keywords set to Id
-
pjproject/main/pjsip/include/pjsip_ua.h
- Property svn:keywords set to Id
-
pjproject/main/pjsip/lib
-
Property
svn:ignore
set to
*
-
Property
svn:ignore
set to
-
pjproject/main/pjsip/src/pjsip/sip_auth.c
- Property svn:keywords set to Id
r3 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #include <pjsip/sip_auth.h> … … 6 5 #include <pjsip/sip_transport.h> 7 6 #include <pjsip/sip_endpoint.h> 8 #include <pj /md5.h>7 #include <pjlib-util/md5.h> 9 8 #include <pj/log.h> 10 9 #include <pj/string.h> 11 10 #include <pj/pool.h> 12 11 #include <pj/guid.h> 12 #include <pj/assert.h> 13 #include <pj/ctype.h> 13 14 14 15 /* Length of digest string. */ … … 147 148 p = qop.ptr; 148 149 while (*p) { 149 *p = (char) tolower(*p);150 *p = (char)pj_tolower(*p); 150 151 ++p; 151 152 } … … 218 219 cred->qop = pjsip_AUTH_STR; 219 220 cred->nc.ptr = pj_pool_alloc(pool, 16); 220 sprintf(cred->nc.ptr, "%06u", nc);221 pj_snprintf(cred->nc.ptr, 16, "%06u", nc); 221 222 222 223 if (cnonce && cnonce->slen) { … … 485 486 { 486 487 unsigned i; 487 PJ_UNUSED_ARG(scheme) 488 PJ_UNUSED_ARG(scheme); 488 489 for (i=0; i<count; ++i) { 489 490 if (pj_stricmp(&cred[i].realm, realm) == 0) … … 716 717 pjsip_via_hdr *via; 717 718 718 PJ_UNUSED_ARG(endpt) 719 PJ_UNUSED_ARG(endpt); 719 720 720 721 pj_assert(rdata->msg->type == PJSIP_RESPONSE_MSG); -
pjproject/main/pjsip/src/pjsip/sip_auth_msg.c
- Property svn:keywords set to Id
r3 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #include <pjsip/sip_auth_msg.h> … … 7 6 #include <pj/list.h> 8 7 #include <pj/string.h> 9 #include <pjsip/print.h> 8 #include <pj/assert.h> 9 #include <pjsip/print_util.h> 10 10 11 11 /////////////////////////////////////////////////////////////////////////////// … … 68 68 static int print_pgp_credential(pjsip_pgp_credential *cred, char *buf, pj_size_t size) 69 69 { 70 PJ_UNUSED_ARG(cred) 71 PJ_UNUSED_ARG(buf) 72 PJ_UNUSED_ARG(size) 70 PJ_UNUSED_ARG(cred); 71 PJ_UNUSED_ARG(buf); 72 PJ_UNUSED_ARG(size); 73 73 return -1; 74 74 } … … 213 213 char *buf, pj_size_t size) 214 214 { 215 PJ_UNUSED_ARG(chal) 216 PJ_UNUSED_ARG(buf) 217 PJ_UNUSED_ARG(size) 215 PJ_UNUSED_ARG(chal); 216 PJ_UNUSED_ARG(buf); 217 PJ_UNUSED_ARG(size); 218 218 return -1; 219 219 } -
pjproject/main/pjsip/src/pjsip/sip_auth_parser.c
- Property svn:keywords set to Id
r3 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #include <pjsip/sip_auth_parser.h> 5 4 #include <pjsip/sip_auth_msg.h> 6 5 #include <pjsip/sip_parser.h> 6 #include <pj/assert.h> 7 7 #include <pj/string.h> 8 8 #include <pj/except.h> 9 9 10 static pjsip_authorization_hdr* parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool); 11 static pjsip_proxy_authorization_hdr* parse_hdr_proxy_authorization( pj_scanner *scanner, pj_pool_t *pool); 12 static pjsip_www_authenticate_hdr* parse_hdr_www_authenticate( pj_scanner *scanner, pj_pool_t *pool); 13 static pjsip_proxy_authenticate_hdr* parse_hdr_proxy_authenticate( pj_scanner *scanner, pj_pool_t *pool); 14 15 static void parse_digest_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_credential *cred); 16 static void parse_pgp_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_credential *cred); 17 static void parse_digest_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_challenge *chal); 18 static void parse_pgp_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_challenge *chal); 10 static pjsip_hdr* parse_hdr_authorization ( pjsip_parse_ctx *ctx ); 11 static pjsip_hdr* parse_hdr_proxy_authorization ( pjsip_parse_ctx *ctx ); 12 static pjsip_hdr* parse_hdr_www_authenticate ( pjsip_parse_ctx *ctx ); 13 static pjsip_hdr* parse_hdr_proxy_authenticate ( pjsip_parse_ctx *ctx ); 14 15 static void parse_digest_credential ( pj_scanner *scanner, pj_pool_t *pool, 16 pjsip_digest_credential *cred); 17 static void parse_pgp_credential ( pj_scanner *scanner, pj_pool_t *pool, 18 pjsip_pgp_credential *cred); 19 static void parse_digest_challenge ( pj_scanner *scanner, pj_pool_t *pool, 20 pjsip_digest_challenge *chal); 21 static void parse_pgp_challenge ( pj_scanner *scanner, pj_pool_t *pool, 22 pjsip_pgp_challenge *chal); 19 23 20 24 const pj_str_t pjsip_USERNAME_STR = { "username", 8 }, … … 44 48 45 49 46 static void parse_digest_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_credential *cred) 50 static void parse_digest_credential( pj_scanner *scanner, pj_pool_t *pool, 51 pjsip_digest_credential *cred) 47 52 { 48 53 for (;;) { 49 54 pj_str_t name, value; 50 55 51 pjsip_parse_param_imp(scanner, &name, &value, 56 pjsip_parse_param_imp(scanner, &name, &value,PJSIP_PARSE_REMOVE_QUOTE); 52 57 53 58 if (!pj_stricmp(&name, &pjsip_USERNAME_STR)) { … … 82 87 83 88 } else { 84 pjsip_concat_param_imp(&cred->other_param, pool, &name,&value, ',');89 pjsip_concat_param_imp(&cred->other_param,pool,&name,&value, ','); 85 90 } 86 91 87 92 /* Eat comma */ 88 if (!pj_scan_is_eof(scanner) && *scanner->cur rent== ',')93 if (!pj_scan_is_eof(scanner) && *scanner->curptr == ',') 89 94 pj_scan_get_char(scanner); 90 95 else … … 93 98 } 94 99 95 static void parse_pgp_credential( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_credential *cred) 96 { 97 PJ_UNUSED_ARG(scanner) 98 PJ_UNUSED_ARG(pool) 99 PJ_UNUSED_ARG(cred) 100 static void parse_pgp_credential( pj_scanner *scanner, pj_pool_t *pool, 101 pjsip_pgp_credential *cred) 102 { 103 PJ_UNUSED_ARG(scanner); 104 PJ_UNUSED_ARG(pool); 105 PJ_UNUSED_ARG(cred); 100 106 101 107 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 102 108 } 103 109 104 static void parse_digest_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_digest_challenge *chal) 110 static void parse_digest_challenge( pj_scanner *scanner, pj_pool_t *pool, 111 pjsip_digest_challenge *chal) 105 112 { 106 113 for (;;) { 107 114 pj_str_t name, value; 108 115 109 pjsip_parse_param_imp(scanner, &name, &value, 116 pjsip_parse_param_imp(scanner, &name, &value,PJSIP_PARSE_REMOVE_QUOTE); 110 117 111 118 if (!pj_stricmp(&name, &pjsip_REALM_STR)) { … … 122 129 123 130 } else if (!pj_stricmp(&name, &pjsip_STALE_STR)) { 124 if (!pj_stricmp(&value, &pjsip_TRUE_STR) || !pj_stricmp(&value, &pjsip_QUOTED_TRUE_STR)) 131 if (!pj_stricmp(&value, &pjsip_TRUE_STR) || 132 !pj_stricmp(&value, &pjsip_QUOTED_TRUE_STR)) 133 { 125 134 chal->stale = 1; 135 } 126 136 127 137 } else if (!pj_stricmp(&name, &pjsip_ALGORITHM_STR)) { … … 133 143 134 144 } else { 135 pjsip_concat_param_imp(&chal->other_param, pool, &name, &value, ','); 145 pjsip_concat_param_imp(&chal->other_param, pool, 146 &name, &value, ','); 136 147 } 137 148 138 149 /* Eat comma */ 139 if (!pj_scan_is_eof(scanner) && *scanner->cur rent== ',')150 if (!pj_scan_is_eof(scanner) && *scanner->curptr == ',') 140 151 pj_scan_get_char(scanner); 141 152 else … … 144 155 } 145 156 146 static void parse_pgp_challenge( pj_scanner *scanner, pj_pool_t *pool, pjsip_pgp_challenge *chal) 147 { 148 PJ_UNUSED_ARG(scanner) 149 PJ_UNUSED_ARG(pool) 150 PJ_UNUSED_ARG(chal) 157 static void parse_pgp_challenge( pj_scanner *scanner, pj_pool_t *pool, 158 pjsip_pgp_challenge *chal) 159 { 160 PJ_UNUSED_ARG(scanner); 161 PJ_UNUSED_ARG(pool); 162 PJ_UNUSED_ARG(chal); 151 163 152 164 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 153 165 } 154 166 155 static void int_parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool, 167 static void int_parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool, 156 168 pjsip_authorization_hdr *hdr) 157 169 { 158 if (*scanner->cur rent== '"') {170 if (*scanner->curptr == '"') { 159 171 pj_scan_get_quote(scanner, '"', '"', &hdr->scheme); 160 172 hdr->scheme.ptr++; 161 173 hdr->scheme.slen -= 2; 162 174 } else { 163 pj_scan_get(scanner, pjsip_TOKEN_SPEC, &hdr->scheme);175 pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->scheme); 164 176 } 165 177 … … 182 194 pjsip_www_authenticate_hdr *hdr) 183 195 { 184 if (*scanner->cur rent== '"') {196 if (*scanner->curptr == '"') { 185 197 pj_scan_get_quote(scanner, '"', '"', &hdr->scheme); 186 198 hdr->scheme.ptr++; 187 199 hdr->scheme.slen -= 2; 188 200 } else { 189 pj_scan_get(scanner, pjsip_TOKEN_SPEC, &hdr->scheme);201 pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->scheme); 190 202 } 191 203 … … 206 218 207 219 208 static pjsip_authorization_hdr *parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool) 209 { 210 pjsip_authorization_hdr *hdr = pjsip_authorization_hdr_create(pool); 211 int_parse_hdr_authorization(scanner, pool, hdr); 212 return hdr; 213 } 214 215 static pjsip_proxy_authorization_hdr *parse_hdr_proxy_authorization( pj_scanner *scanner, pj_pool_t *pool) 216 { 217 pjsip_proxy_authorization_hdr *hdr = pjsip_proxy_authorization_hdr_create(pool); 218 int_parse_hdr_authorization(scanner, pool, hdr); 219 return hdr; 220 } 221 222 static pjsip_www_authenticate_hdr *parse_hdr_www_authenticate( pj_scanner *scanner, pj_pool_t *pool) 223 { 224 pjsip_www_authenticate_hdr *hdr = pjsip_www_authenticate_hdr_create(pool); 225 int_parse_hdr_authenticate(scanner, pool, hdr); 226 return hdr; 227 } 228 229 static pjsip_proxy_authenticate_hdr *parse_hdr_proxy_authenticate( pj_scanner *scanner, pj_pool_t *pool) 230 { 231 pjsip_proxy_authenticate_hdr *hdr = pjsip_proxy_authenticate_hdr_create(pool); 232 int_parse_hdr_authenticate(scanner, pool, hdr); 233 return hdr; 234 } 235 236 237 PJ_DEF(void) pjsip_auth_init_parser() 238 { 239 pjsip_register_hdr_parser( "Authorization", NULL, (pjsip_parse_hdr_func*) &parse_hdr_authorization); 240 pjsip_register_hdr_parser( "Proxy-Authorization", NULL, (pjsip_parse_hdr_func*) &parse_hdr_proxy_authorization); 241 pjsip_register_hdr_parser( "WWW-Authenticate", NULL, (pjsip_parse_hdr_func*) &parse_hdr_www_authenticate); 242 pjsip_register_hdr_parser( "Proxy-Authenticate", NULL, (pjsip_parse_hdr_func*) &parse_hdr_proxy_authenticate); 220 static pjsip_hdr* parse_hdr_authorization( pjsip_parse_ctx *ctx ) 221 { 222 pjsip_authorization_hdr *hdr = pjsip_authorization_hdr_create(ctx->pool); 223 int_parse_hdr_authorization(ctx->scanner, ctx->pool, hdr); 224 return (pjsip_hdr*)hdr; 225 } 226 227 static pjsip_hdr* parse_hdr_proxy_authorization( pjsip_parse_ctx *ctx ) 228 { 229 pjsip_proxy_authorization_hdr *hdr = 230 pjsip_proxy_authorization_hdr_create(ctx->pool); 231 int_parse_hdr_authorization(ctx->scanner, ctx->pool, hdr); 232 return (pjsip_hdr*)hdr; 233 } 234 235 static pjsip_hdr* parse_hdr_www_authenticate( pjsip_parse_ctx *ctx ) 236 { 237 pjsip_www_authenticate_hdr *hdr = 238 pjsip_www_authenticate_hdr_create(ctx->pool); 239 int_parse_hdr_authenticate(ctx->scanner, ctx->pool, hdr); 240 return (pjsip_hdr*)hdr; 241 } 242 243 static pjsip_hdr* parse_hdr_proxy_authenticate( pjsip_parse_ctx *ctx ) 244 { 245 pjsip_proxy_authenticate_hdr *hdr = 246 pjsip_proxy_authenticate_hdr_create(ctx->pool); 247 int_parse_hdr_authenticate(ctx->scanner, ctx->pool, hdr); 248 return (pjsip_hdr*)hdr; 249 } 250 251 252 PJ_DEF(pj_status_t) pjsip_auth_init_parser() 253 { 254 pj_status_t status; 255 256 status = pjsip_register_hdr_parser( "Authorization", NULL, 257 &parse_hdr_authorization); 258 PJ_ASSERT_RETURN(status==PJ_SUCCESS, status); 259 status = pjsip_register_hdr_parser( "Proxy-Authorization", NULL, 260 &parse_hdr_proxy_authorization); 261 PJ_ASSERT_RETURN(status==PJ_SUCCESS, status); 262 status = pjsip_register_hdr_parser( "WWW-Authenticate", NULL, 263 &parse_hdr_www_authenticate); 264 PJ_ASSERT_RETURN(status==PJ_SUCCESS, status); 265 status = pjsip_register_hdr_parser( "Proxy-Authenticate", NULL, 266 &parse_hdr_proxy_authenticate); 267 PJ_ASSERT_RETURN(status==PJ_SUCCESS, status); 268 269 return PJ_SUCCESS; 243 270 } 244 271 -
pjproject/main/pjsip/src/pjsip/sip_endpoint.c
- Property svn:keywords set to Id
r3 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #include <pjsip/sip_endpoint.h> … … 9 8 #include <pjsip/sip_module.h> 10 9 #include <pjsip/sip_misc.h> 10 #include <pjsip/sip_errno.h> 11 11 #include <pj/except.h> 12 12 #include <pj/log.h> … … 15 15 #include <pj/pool.h> 16 16 #include <pj/hash.h> 17 #include <pj/assert.h> 18 #include <pj/errno.h> 17 19 18 20 19 21 #define PJSIP_EX_NO_MEMORY PJ_NO_MEMORY_EXCEPTION 20 #define LOG_THIS "endpoint..."22 #define THIS_FILE "endpoint" 21 23 22 24 #define MAX_METHODS 32 … … 85 87 * Defined in sip_transaction.c 86 88 */ 87 pjsip_transaction * pjsip_tsx_create( pj_pool_t *pool, pjsip_endpoint *endpt); 89 pj_status_t pjsip_tsx_create( pj_pool_t *pool, pjsip_endpoint *endpt, 90 pjsip_transaction **tsx ); 88 91 89 92 /* … … 95 98 static void pool_callback( pj_pool_t *pool, pj_size_t size ) 96 99 { 97 PJ_UNUSED_ARG(pool) 98 PJ_UNUSED_ARG(size) 100 PJ_UNUSED_ARG(pool); 101 PJ_UNUSED_ARG(size); 99 102 100 103 PJ_THROW(PJSIP_EX_NO_MEMORY); … … 112 115 extern pjsip_module aux_tsx_module; 113 116 114 PJ_LOG(5, ( LOG_THIS, "init_modules()"));117 PJ_LOG(5, (THIS_FILE, "init_modules()")); 115 118 116 119 /* Load static modules. */ … … 165 168 endpt->methods[endpt->method_cnt++] = mod->methods[j]; 166 169 } else { 167 PJ_LOG(1,( LOG_THIS, "Too many methods"));170 PJ_LOG(1,(THIS_FILE, "Too many methods")); 168 171 return -1; 169 172 } … … 201 204 pjsip_transaction *tsx) 202 205 { 203 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_destroy_tsx(%s)", tsx->obj_name));206 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_destroy_tsx(%s)", tsx->obj_name)); 204 207 205 208 pj_assert(tsx->state == PJSIP_TSX_STATE_DESTROYED); … … 227 230 pj_pool_release(tsx->pool); 228 231 229 PJ_LOG(4, ( LOG_THIS, "tsx%p destroyed", tsx));232 PJ_LOG(4, (THIS_FILE, "tsx%p destroyed", tsx)); 230 233 } 231 234 … … 248 251 249 252 /* Destroy transaction if it is terminated. */ 250 if (evt->type == PJSIP_EVENT_TSX_STATE _CHANGED&&251 evt-> obj.tsx->state == PJSIP_TSX_STATE_DESTROYED)253 if (evt->type == PJSIP_EVENT_TSX_STATE && 254 evt->body.tsx_state.tsx->state == PJSIP_TSX_STATE_DESTROYED) 252 255 { 253 256 /* No need to lock mutex. Mutex is locked inside the destroy function */ 254 pjsip_endpt_destroy_tsx( endpt, evt-> obj.tsx );257 pjsip_endpt_destroy_tsx( endpt, evt->body.tsx_state.tsx ); 255 258 } 256 259 } … … 262 265 void pjsip_endpt_send_tsx_event( pjsip_endpoint *endpt, pjsip_event *evt ) 263 266 { 267 // Need to protect this with try/catch? 264 268 endpt_do_event(endpt, evt); 265 269 } … … 302 306 if (!hdr) { 303 307 pj_mutex_unlock(endpt->mutex); 304 PJ_LOG(4,( LOG_THIS, "Invalid URL %s in proxy URL", dup));308 PJ_LOG(4,(THIS_FILE, "Invalid URL %s in proxy URL", dup)); 305 309 return -1; 306 310 } … … 328 332 * Initialize endpoint. 329 333 */ 330 PJ_DEF(pjsip_endpoint*) pjsip_endpt_create(pj_pool_factory *pf) 334 PJ_DEF(pj_status_t) pjsip_endpt_create(pj_pool_factory *pf, 335 pjsip_endpoint **p_endpt) 331 336 { 332 337 pj_status_t status; … … 335 340 pjsip_max_forwards_hdr *mf_hdr; 336 341 337 PJ_LOG(5, (LOG_THIS, "pjsip_endpt_create()")); 342 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_create()")); 343 344 *p_endpt = NULL; 338 345 339 346 /* Create pool */ … … 342 349 &pool_callback); 343 350 if (!pool) 344 return NULL;351 return PJ_ENOMEM; 345 352 346 353 /* Create endpoint. */ … … 350 357 351 358 /* Create mutex for the events, etc. */ 352 endpt->mutex = pj_mutex_create( endpt->pool, "ept%p", 0 ); 353 if (!endpt->mutex) { 354 PJ_LOG(4, (LOG_THIS, "pjsip_endpt_init(): error creating endpoint mutex")); 359 status = pj_mutex_create_recursive( endpt->pool, "ept%p", &endpt->mutex ); 360 if (status != PJ_SUCCESS) { 355 361 goto on_error; 356 362 } 357 363 358 364 /* Create mutex for the transaction table. */ 359 endpt->tsx_table_mutex = pj_mutex_create( endpt->pool, "mtbl%p", 0);360 if (!endpt->tsx_table_mutex) {361 PJ_LOG(4, (LOG_THIS, "pjsip_endpt_init(): error creating endpoint mutex(2)")); 365 status = pj_mutex_create_recursive( endpt->pool, "mtbl%p", 366 &endpt->tsx_table_mutex); 367 if (status != PJ_SUCCESS) { 362 368 goto on_error; 363 369 } … … 366 372 endpt->tsx_table = pj_hash_create( endpt->pool, PJSIP_MAX_TSX_COUNT ); 367 373 if (!endpt->tsx_table) { 368 PJ_LOG(4, (LOG_THIS, "pjsip_endpt_init(): error creating tsx hash table"));374 status = PJ_ENOMEM; 369 375 goto on_error; 370 376 } 371 377 372 378 /* Create timer heap to manage all timers within this endpoint. */ 373 endpt->timer_heap = pj_timer_heap_create( endpt->pool, PJSIP_MAX_TIMER_COUNT, 0);374 if (!endpt->timer_heap) {375 PJ_LOG(4, (LOG_THIS, "pjsip_endpt_init(): error creating timer heap")); 379 status = pj_timer_heap_create( endpt->pool, PJSIP_MAX_TIMER_COUNT, 380 &endpt->timer_heap); 381 if (status != PJ_SUCCESS) { 376 382 goto on_error; 377 383 } 378 384 379 385 /* Create transport manager. */ 380 endpt->transport_mgr= pjsip_transport_mgr_create( endpt->pool,381 382 &endpt_transport_callback);383 if (!endpt->transport_mgr) { 384 PJ_LOG(4, (LOG_THIS, "pjsip_endpt_init(): error creating transport mgr")); 386 status = pjsip_transport_mgr_create( endpt->pool, 387 endpt, 388 &endpt_transport_callback, 389 &endpt->transport_mgr); 390 if (status != PJ_SUCCESS) { 385 391 goto on_error; 386 392 } … … 389 395 endpt->resolver = pjsip_resolver_create(endpt->pool); 390 396 if (!endpt->resolver) { 391 PJ_LOG(4, ( LOG_THIS, "pjsip_endpt_init(): error creating resolver"));397 PJ_LOG(4, (THIS_FILE, "pjsip_endpt_init(): error creating resolver")); 392 398 goto on_error; 393 399 } 394 400 395 401 /* Initialize TLS ID for transaction lock. */ 396 pjsip_tsx_lock_tls_id = pj_thread_local_alloc(); 397 if (pjsip_tsx_lock_tls_id == -1) { 398 PJ_LOG(4, (LOG_THIS, "pjsip_endpt_init(): error allocating TLS")); 402 status = pj_thread_local_alloc(&pjsip_tsx_lock_tls_id); 403 if (status != PJ_SUCCESS) { 399 404 goto on_error; 400 405 } … … 415 420 status = init_modules(endpt); 416 421 if (status != PJ_SUCCESS) { 417 PJ_LOG(4, ( LOG_THIS, "pjsip_endpt_init(): error in init_modules()"));418 return NULL;422 PJ_LOG(4, (THIS_FILE, "pjsip_endpt_init(): error in init_modules()")); 423 return status; 419 424 } 420 425 421 426 /* Done. */ 422 return endpt; 427 *p_endpt = endpt; 428 return status; 423 429 424 430 on_error: … … 437 443 pj_pool_release( endpt->pool ); 438 444 439 PJ_LOG(4, ( LOG_THIS, "pjsip_endpt_init() failed"));440 return NULL;445 PJ_LOG(4, (THIS_FILE, "pjsip_endpt_init() failed")); 446 return status; 441 447 } 442 448 … … 446 452 PJ_DEF(void) pjsip_endpt_destroy(pjsip_endpoint *endpt) 447 453 { 448 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_destroy()"));454 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_destroy()")); 449 455 450 456 /* Shutdown and destroy all transports. */ … … 471 477 pj_pool_t *pool; 472 478 473 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_create_pool()"));479 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_create_pool()")); 474 480 475 481 /* Lock endpoint mutex. */ … … 484 490 485 491 if (pool) { 486 PJ_LOG(5, ( LOG_THIS, " pool %s created", pj_pool_getobjname(pool)));492 PJ_LOG(5, (THIS_FILE, " pool %s created", pj_pool_getobjname(pool))); 487 493 } else { 488 PJ_LOG(4, ( LOG_THIS, "Unable to create pool %s!", pool_name));494 PJ_LOG(4, (THIS_FILE, "Unable to create pool %s!", pool_name)); 489 495 } 490 496 … … 498 504 PJ_DEF(void) pjsip_endpt_destroy_pool( pjsip_endpoint *endpt, pj_pool_t *pool ) 499 505 { 500 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_destroy_pool(%s)", pj_pool_getobjname(pool)));506 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_destroy_pool(%s)", pj_pool_getobjname(pool))); 501 507 502 508 pj_mutex_lock(endpt->mutex); … … 514 520 int i; 515 521 516 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_handle_events()"));522 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_handle_events()")); 517 523 518 524 /* Poll the timer. The timer heap has its own mutex for better … … 544 550 const pj_time_val *delay ) 545 551 { 546 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_schedule_timer(entry=%p, delay=%u.%u)",552 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_schedule_timer(entry=%p, delay=%u.%u)", 547 553 entry, delay->sec, delay->msec)); 548 554 return pj_timer_heap_schedule( endpt->timer_heap, entry, delay ); … … 555 561 pj_timer_entry *entry ) 556 562 { 557 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_cancel_timer(entry=%p)", entry));563 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_cancel_timer(entry=%p)", entry)); 558 564 pj_timer_heap_cancel( endpt->timer_heap, entry ); 559 565 } … … 564 570 * register it to the hash table. 565 571 */ 566 PJ_DEF(pjsip_transaction*) pjsip_endpt_create_tsx(pjsip_endpoint *endpt) 572 PJ_DEF(pj_status_t) pjsip_endpt_create_tsx(pjsip_endpoint *endpt, 573 pjsip_transaction **p_tsx) 567 574 { 568 575 pj_pool_t *pool; 569 pjsip_transaction *tsx; 570 571 PJ_LOG(5, (LOG_THIS, "pjsip_endpt_create_tsx()")); 576 577 PJ_ASSERT_RETURN(endpt && p_tsx, PJ_EINVAL); 578 579 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_create_tsx()")); 572 580 573 581 /* Request one pool for the transaction. Mutex is locked there. */ … … 575 583 PJSIP_POOL_LEN_TSX, PJSIP_POOL_INC_TSX); 576 584 if (pool == NULL) { 577 PJ_LOG(2, (LOG_THIS, "failed to create transaction (no pool)")); 578 return NULL; 585 return PJ_ENOMEM; 579 586 } 580 587 581 588 /* Create the transaction. */ 582 tsx = pjsip_tsx_create(pool, endpt); 583 584 /* Return */ 585 return tsx; 589 return pjsip_tsx_create(pool, endpt, p_tsx); 586 590 } 587 591 … … 595 599 pjsip_transaction *tsx) 596 600 { 597 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_register_tsx(%s)", tsx->obj_name));601 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_register_tsx(%s)", tsx->obj_name)); 598 602 599 603 pj_assert(tsx->transaction_key.slen != 0); … … 619 623 pjsip_transaction *tsx; 620 624 621 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_find_tsx()"));625 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_find_tsx()")); 622 626 623 627 /* Start lock mutex in the endpoint. */ … … 659 663 pj_bool_t a_new_transaction_just_been_created = PJ_FALSE; 660 664 661 PJ_LOG(5, ( LOG_THIS, "endpt_transport_callback(rdata=%p)", rdata));665 PJ_LOG(5, (THIS_FILE, "endpt_transport_callback(rdata=%p)", rdata)); 662 666 663 667 /* For response, check that the value in Via sent-by match the transport. … … 676 680 } 677 681 addr = pjsip_transport_get_addr_name(rdata->transport); 678 addr_addr = pj_ sockaddr_get_str_addr(addr);682 addr_addr = pj_inet_ntoa(addr->sin_addr); 679 683 if (pj_strcmp2(&rdata->via->sent_by.host, addr_addr) != 0) 680 684 mismatch = PJ_TRUE; 681 else if (port != pj_ sockaddr_get_port(addr)) {685 else if (port != pj_ntohs(addr->sin_port)) { 682 686 /* Port or address mismatch, we should discard response */ 683 687 /* But we saw one implementation (we don't want to name it to … … 687 691 * both the port in sent-by and rport. We try to be lenient here! 688 692 */ 689 if (rdata->via->rport_param != pj_sockaddr_ get_port(addr))693 if (rdata->via->rport_param != pj_sockaddr_in_get_port(addr)) 690 694 mismatch = PJ_TRUE; 691 695 else { 692 PJ_LOG(4,( LOG_THIS, "Response %p has mismatch port in sent-by"696 PJ_LOG(4,(THIS_FILE, "Response %p has mismatch port in sent-by" 693 697 " but the rport parameter is correct", 694 698 rdata)); … … 699 703 pjsip_event e; 700 704 701 PJ_LOG(3, (LOG_THIS, "Response %p discarded: sent-by mismatch", 702 rdata)); 703 704 e.type = PJSIP_EVENT_DISCARD_MSG; 705 e.src_type = PJSIP_EVENT_RX_MSG; 706 e.src.rdata = rdata; 707 e.obj.ptr = NULL; 705 PJSIP_EVENT_INIT_DISCARD_MSG(e, rdata, PJSIP_EINVALIDVIA); 708 706 endpt_do_event( endpt, &e ); 709 707 return; … … 715 713 716 714 /* Find the transaction for the received message. */ 717 PJ_LOG(5, ( LOG_THIS, "finding tsx with key=%.*s",715 PJ_LOG(5, (THIS_FILE, "finding tsx with key=%.*s", 718 716 rdata->key.slen, rdata->key.ptr)); 719 717 … … 748 746 pj_assert(0); 749 747 750 e.type = PJSIP_EVENT_RX_200_RESPONSE; 751 e.src_type = PJSIP_EVENT_RX_MSG; 752 e.src.rdata = rdata; 753 e.obj.ptr = NULL; 748 PJSIP_EVENT_INIT_RX_200_MSG(e, rdata); 754 749 endpt_do_event( endpt, &e ); 755 750 … … 758 753 pjsip_event e; 759 754 760 PJ_LOG(3, (LOG_THIS, "Response %p discarded: transaction not found", 761 rdata)); 762 763 e.type = PJSIP_EVENT_DISCARD_MSG; 764 e.src_type = PJSIP_EVENT_RX_MSG; 765 e.src.rdata = rdata; 766 e.obj.ptr = NULL; 755 PJSIP_EVENT_INIT_DISCARD_MSG(e, rdata, 756 PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_CALL_TSX_DOES_NOT_EXIST)); 767 757 endpt_do_event( endpt, &e ); 768 758 } … … 772 762 */ 773 763 } else if (rdata->msg->line.req.method.id != PJSIP_ACK_METHOD) { 764 765 pj_status_t status; 766 774 767 /* Create transaction, mutex is locked there. */ 775 tsx = pjsip_endpt_create_tsx(endpt); 776 if (!tsx) 768 status = pjsip_endpt_create_tsx(endpt, &tsx); 769 if (status != PJ_SUCCESS) { 770 PJSIP_ENDPT_LOG_ERROR((endpt, THIS_FILE, status, 771 "Unable to create transaction")); 777 772 return; 773 } 778 774 779 775 /* Initialize transaction as UAS. */ … … 803 799 pjsip_event event; 804 800 805 event.type = PJSIP_EVENT_RX_ACK_MSG; 806 event.src_type = PJSIP_EVENT_RX_MSG; 807 event.src.rdata = rdata; 808 event.obj.ptr = NULL; 801 PJSIP_EVENT_INIT_RX_ACK_MSG(event,rdata); 809 802 endpt_do_event( endpt, &event ); 810 803 } … … 835 828 */ 836 829 pjsip_tx_data *tdata; 830 pj_status_t status; 837 831 838 832 if (tsx->method.id == PJSIP_OPTIONS_METHOD) { 839 tdata = pjsip_endpt_create_response(endpt, rdata, 200); 833 status = pjsip_endpt_create_response(endpt, rdata, 200, 834 &tdata); 840 835 } else { 841 tdata = pjsip_endpt_create_response(endpt, rdata, 842 PJSIP_SC_METHOD_NOT_ALLOWED); 843 } 836 status = pjsip_endpt_create_response(endpt, rdata, 837 PJSIP_SC_METHOD_NOT_ALLOWED, 838 &tdata); 839 } 840 841 if (status != PJ_SUCCESS) { 842 PJSIP_ENDPT_LOG_ERROR((endpt, THIS_FILE, status, 843 "Unable to create response")); 844 return; 845 } 846 844 847 if (endpt->allow_hdr) { 845 848 pjsip_msg_add_hdr( tdata->msg, … … 856 859 */ 857 860 pjsip_tx_data *tdata; 858 tdata = pjsip_endpt_create_response(endpt, rdata, 500); 861 pj_status_t status; 862 863 status = pjsip_endpt_create_response(endpt, rdata, 500, &tdata); 864 if (status != PJ_SUCCESS) { 865 PJSIP_ENDPT_LOG_ERROR((endpt, THIS_FILE, status, 866 "Unable to create response")); 867 return; 868 } 869 859 870 pjsip_tsx_on_tx_msg(tsx, tdata); 860 871 } … … 865 876 * Create transmit data buffer. 866 877 */ 867 PJ_DEF(pjsip_tx_data*) pjsip_endpt_create_tdata( pjsip_endpoint *endpt ) 868 { 869 PJ_LOG(5, (LOG_THIS, "pjsip_endpt_create_tdata()")); 870 return pjsip_tx_data_create(endpt->transport_mgr); 878 PJ_DEF(pj_status_t) pjsip_endpt_create_tdata( pjsip_endpoint *endpt, 879 pjsip_tx_data **p_tdata) 880 { 881 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_create_tdata()")); 882 return pjsip_tx_data_create(endpt->transport_mgr, p_tdata); 871 883 } 872 884 … … 880 892 pjsip_resolver_callback *cb) 881 893 { 882 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_resolve()"));894 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_resolve()")); 883 895 pjsip_resolve( endpt->resolver, pool, target, token, cb); 884 896 } … … 894 906 pjsip_transport_completion_callback *cb) 895 907 { 896 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_get_transport()"));908 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_get_transport()")); 897 909 pjsip_transport_get( endpt->transport_mgr, pool, type, 898 910 remote, token, cb); … … 905 917 const pj_sockaddr_in *addr_name) 906 918 { 907 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_create_listener()"));919 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_create_listener()")); 908 920 return pjsip_create_listener( endpt->transport_mgr, type, addr, addr_name ); 909 921 } … … 913 925 const pj_sockaddr_in *addr_name) 914 926 { 915 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_create_udp_listener()"));927 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_create_udp_listener()")); 916 928 return pjsip_create_udp_listener( endpt->transport_mgr, sock, addr_name ); 917 929 } … … 924 936 pj_hash_iterator_t *itr; 925 937 926 PJ_LOG(5, ( LOG_THIS, "pjsip_endpt_dump()"));938 PJ_LOG(5, (THIS_FILE, "pjsip_endpt_dump()")); 927 939 928 940 /* Lock mutex. */ 929 941 pj_mutex_lock(endpt->mutex); 930 942 931 PJ_LOG(3, ( LOG_THIS, "Dumping endpoint %p:", endpt));943 PJ_LOG(3, (THIS_FILE, "Dumping endpoint %p:", endpt)); 932 944 933 945 /* Dumping pool factory. */ … … 935 947 936 948 /* Pool health. */ 937 PJ_LOG(3, ( LOG_THIS," Endpoint pool capacity=%u, used_size=%u",949 PJ_LOG(3, (THIS_FILE," Endpoint pool capacity=%u, used_size=%u", 938 950 pj_pool_get_capacity(endpt->pool), 939 951 pj_pool_get_used_size(endpt->pool))); … … 941 953 /* Transaction tables. */ 942 954 count = pj_hash_count(endpt->tsx_table); 943 PJ_LOG(3, ( LOG_THIS, " Number of transactions: %u", count));955 PJ_LOG(3, (THIS_FILE, " Number of transactions: %u", count)); 944 956 945 957 if (count && detail) { … … 948 960 pj_time_val now; 949 961 950 PJ_LOG(3, ( LOG_THIS, " Dumping transaction tables:"));962 PJ_LOG(3, (THIS_FILE, " Dumping transaction tables:")); 951 963 952 964 pj_gettimeofday(&now); … … 975 987 } 976 988 977 PJ_LOG(3, ( LOG_THIS, " %s %s %10.*s %.9u %s t=%ds",989 PJ_LOG(3, (THIS_FILE, " %s %s %10.*s %.9u %s t=%ds", 978 990 tsx->obj_name, role, 979 991 tsx->method.name.slen, tsx->method.name.ptr, … … 992 1004 itr = pjsip_transport_first( endpt->transport_mgr, &itr_val ); 993 1005 if (itr) { 994 PJ_LOG(3, ( LOG_THIS, " Dumping transports:"));1006 PJ_LOG(3, (THIS_FILE, " Dumping transports:")); 995 1007 996 1008 do { … … 1002 1014 t = pjsip_transport_this(endpt->transport_mgr, itr); 1003 1015 addr = pjsip_transport_get_local_addr(t); 1004 strcpy(src_addr, pj_sockaddr_get_str_addr(addr));1005 src_port = pj_ sockaddr_get_port(addr);1016 pj_native_strcpy(src_addr, pj_inet_ntoa(addr->sin_addr)); 1017 src_port = pj_ntohs(addr->sin_port); 1006 1018 1007 1019 addr = pjsip_transport_get_remote_addr(t); 1008 strcpy(dst_addr, pj_sockaddr_get_str_addr(addr));1009 dst_port = pj_ sockaddr_get_port(addr);1010 1011 PJ_LOG(3, ( LOG_THIS, " %s %s %s:%d --> %s:%d (refcnt=%d)",1020 pj_native_strcpy(dst_addr, pj_inet_ntoa(addr->sin_addr)); 1021 dst_port = pj_ntohs(addr->sin_port); 1022 1023 PJ_LOG(3, (THIS_FILE, " %s %s %s:%d --> %s:%d (refcnt=%d)", 1012 1024 pjsip_transport_get_type_name(t), 1013 1025 pjsip_transport_get_obj_name(t), … … 1021 1033 1022 1034 /* Timer. */ 1023 PJ_LOG(3,( LOG_THIS, " Timer heap has %u entries",1035 PJ_LOG(3,(THIS_FILE, " Timer heap has %u entries", 1024 1036 pj_timer_heap_count(endpt->timer_heap))); 1025 1037 … … 1027 1039 pj_mutex_unlock(endpt->mutex); 1028 1040 #else 1029 PJ_LOG(3,( LOG_THIS, "pjsip_end_dump: can't dump because it's disabled."));1041 PJ_LOG(3,(THIS_FILE, "pjsip_end_dump: can't dump because it's disabled.")); 1030 1042 #endif 1031 1043 } -
pjproject/main/pjsip/src/pjsip/sip_misc.c
- Property svn:keywords set to Id
r3 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #include <pjsip/sip_misc.h> … … 14 13 #include <pj/pool.h> 15 14 #include <pj/except.h> 16 17 #define LOG_THIS "endpoint..." 15 #include <pj/rand.h> 16 #include <pj/assert.h> 17 #include <pj/errno.h> 18 19 #define THIS_FILE "endpoint" 18 20 19 21 static const char *event_str[] = … … 45 47 struct pjsip_module *mod, pj_uint32_t id ) 46 48 { 47 PJ_UNUSED_ARG(endpt) 48 PJ_UNUSED_ARG(mod) 49 PJ_UNUSED_ARG(endpt); 50 PJ_UNUSED_ARG(mod); 49 51 50 52 aux_mod_id = id; … … 54 56 static void aux_tsx_handler( struct pjsip_module *mod, pjsip_event *event ) 55 57 { 56 pjsip_transaction *tsx = event->obj.tsx;58 pjsip_transaction *tsx; 57 59 struct aux_tsx_data *tsx_data; 58 60 59 PJ_UNUSED_ARG(mod) 60 61 if (event->type != PJSIP_EVENT_TSX_STATE _CHANGED)61 PJ_UNUSED_ARG(mod); 62 63 if (event->type != PJSIP_EVENT_TSX_STATE) 62 64 return; 65 66 pj_assert(event->body.tsx_state.tsx != NULL); 67 tsx = event->body.tsx_state.tsx; 63 68 if (tsx == NULL) 64 69 return; … … 101 106 pjsip_transaction *tsx; 102 107 struct aux_tsx_data *tsx_data; 103 104 tsx = pjsip_endpt_create_tsx(endpt); 108 pj_status_t status; 109 110 status = pjsip_endpt_create_tsx(endpt, &tsx); 105 111 if (!tsx) { 106 112 pjsip_tx_data_dec_ref(tdata); … … 135 141 * this function. 136 142 */ 137 static void init_request_throw( pjsip_tx_data *tdata, 143 static void init_request_throw( pjsip_endpoint *endpt, 144 pjsip_tx_data *tdata, 138 145 pjsip_method *method, 139 146 pjsip_uri *param_target, … … 147 154 pjsip_msg *msg; 148 155 pjsip_msg_body *body; 156 const pjsip_hdr *endpt_hdr; 149 157 150 158 /* Create the message. */ … … 154 162 pj_memcpy(&msg->line.req.method, method, sizeof(*method)); 155 163 msg->line.req.uri = param_target; 164 165 /* Add additional request headers from endpoint. */ 166 endpt_hdr = pjsip_endpt_get_request_headers(endpt)->next; 167 while (endpt_hdr != pjsip_endpt_get_request_headers(endpt)) { 168 pjsip_hdr *hdr = pjsip_hdr_shallow_clone(tdata->pool, endpt_hdr); 169 pjsip_msg_add_hdr( tdata->msg, hdr ); 170 endpt_hdr = endpt_hdr->next; 171 } 156 172 157 173 /* Add From header. */ … … 190 206 * Create arbitrary request. 191 207 */ 192 PJ_DEF(pjsip_tx_data*) pjsip_endpt_create_request( pjsip_endpoint *endpt, 193 const pjsip_method *method, 194 const pj_str_t *param_target, 195 const pj_str_t *param_from, 196 const pj_str_t *param_to, 197 const pj_str_t *param_contact, 198 const pj_str_t *param_call_id, 199 int param_cseq, 200 const pj_str_t *param_text) 208 PJ_DEF(pj_status_t) pjsip_endpt_create_request( pjsip_endpoint *endpt, 209 const pjsip_method *method, 210 const pj_str_t *param_target, 211 const pj_str_t *param_from, 212 const pj_str_t *param_to, 213 const pj_str_t *param_contact, 214 const pj_str_t *param_call_id, 215 int param_cseq, 216 const pj_str_t *param_text, 217 pjsip_tx_data **p_tdata) 201 218 { 202 219 pjsip_uri *target; … … 208 225 pjsip_cid_hdr *call_id; 209 226 pj_str_t tmp; 227 pj_status_t status; 210 228 PJ_USE_EXCEPTION; 211 229 212 PJ_LOG(5,( LOG_THIS, "Entering pjsip_endpt_create_request()"));213 214 tdata = pjsip_endpt_create_tdata(endpt);215 if ( !tdata)216 return NULL;230 PJ_LOG(5,(THIS_FILE, "Entering pjsip_endpt_create_request()")); 231 232 status = pjsip_endpt_create_tdata(endpt, &tdata); 233 if (status != PJ_SUCCESS) 234 return status; 217 235 218 236 /* Init reference counter to 1. */ … … 224 242 target = pjsip_parse_uri( tdata->pool, tmp.ptr, tmp.slen, 0); 225 243 if (target == NULL) { 226 PJ_LOG(4,( LOG_THIS, "Error creating request: invalid target %s",244 PJ_LOG(4,(THIS_FILE, "Error creating request: invalid target %s", 227 245 tmp.ptr)); 228 246 goto on_error; … … 235 253 PJSIP_PARSE_URI_AS_NAMEADDR); 236 254 if (from->uri == NULL) { 237 PJ_LOG(4,( LOG_THIS, "Error creating request: invalid 'From' URI '%s'",255 PJ_LOG(4,(THIS_FILE, "Error creating request: invalid 'From' URI '%s'", 238 256 tmp.ptr)); 239 257 goto on_error; … … 247 265 PJSIP_PARSE_URI_AS_NAMEADDR); 248 266 if (to->uri == NULL) { 249 PJ_LOG(4,( LOG_THIS, "Error creating request: invalid 'To' URI '%s'",267 PJ_LOG(4,(THIS_FILE, "Error creating request: invalid 'To' URI '%s'", 250 268 tmp.ptr)); 251 269 goto on_error; … … 259 277 PJSIP_PARSE_URI_AS_NAMEADDR); 260 278 if (contact->uri == NULL) { 261 PJ_LOG(4,( LOG_THIS,279 PJ_LOG(4,(THIS_FILE, 262 280 "Error creating request: invalid 'Contact' URI '%s'", 263 281 tmp.ptr)); … … 286 304 287 305 /* Create the request. */ 288 init_request_throw( tdata, &cseq->method, target, from, to, contact,289 306 init_request_throw( endpt, tdata, &cseq->method, target, from, to, 307 contact, call_id, cseq, param_text); 290 308 } 291 309 PJ_DEFAULT { 292 PJ_LOG(4,(LOG_THIS, "Caught exception %d when creating request", 293 PJ_GET_EXCEPTION())); 310 status = PJ_ENOMEM; 294 311 goto on_error; 295 312 } 296 313 PJ_END 297 314 298 PJ_LOG(4,( LOG_THIS, "Request %s (%d %.*s) created.",315 PJ_LOG(4,(THIS_FILE, "Request %s (%d %.*s) created.", 299 316 tdata->obj_name, 300 317 cseq->cseq, … … 302 319 cseq->method.name.ptr)); 303 320 304 return tdata; 321 *p_tdata = tdata; 322 return PJ_SUCCESS; 305 323 306 324 on_error: 307 325 pjsip_tx_data_dec_ref(tdata); 308 return NULL;309 } 310 311 PJ_DEF(pj sip_tx_data*)326 return status; 327 } 328 329 PJ_DEF(pj_status_t) 312 330 pjsip_endpt_create_request_from_hdr( pjsip_endpoint *endpt, 313 331 const pjsip_method *method, … … 318 336 const pjsip_cid_hdr *param_call_id, 319 337 int param_cseq, 320 const pj_str_t *param_text ) 338 const pj_str_t *param_text, 339 pjsip_tx_data **p_tdata) 321 340 { 322 341 pjsip_uri *target; … … 327 346 pjsip_cid_hdr *call_id; 328 347 pjsip_cseq_hdr *cseq = NULL; /* The NULL because warning in VC6 */ 348 pj_status_t status; 329 349 PJ_USE_EXCEPTION; 330 350 331 PJ_LOG(5,( LOG_THIS, "Entering pjsip_endpt_create_request_from_hdr()"));332 333 tdata = pjsip_endpt_create_tdata(endpt);334 if ( !tdata)335 return NULL;351 PJ_LOG(5,(THIS_FILE, "Entering pjsip_endpt_create_request_from_hdr()")); 352 353 status = pjsip_endpt_create_tdata(endpt, &tdata); 354 if (status != PJ_SUCCESS) 355 return status; 336 356 337 357 pjsip_tx_data_add_ref(tdata); … … 355 375 pjsip_method_copy(tdata->pool, &cseq->method, method); 356 376 357 init_request_throw( tdata, &cseq->method, target, from, to, contact,358 377 init_request_throw(endpt, tdata, &cseq->method, target, from, to, 378 contact, call_id, cseq, param_text); 359 379 } 360 380 PJ_DEFAULT { 361 PJ_LOG(4,(LOG_THIS, "Caught exception %d when creating request", 362 PJ_GET_EXCEPTION())); 381 status = PJ_ENOMEM; 363 382 goto on_error; 364 383 } 365 384 PJ_END; 366 385 367 PJ_LOG(4,( LOG_THIS, "Request %s (%d %.*s) created.",386 PJ_LOG(4,(THIS_FILE, "Request %s (%d %.*s) created.", 368 387 tdata->obj_name, 369 388 cseq->cseq, 370 389 cseq->method.name.slen, 371 390 cseq->method.name.ptr)); 372 return tdata; 391 392 *p_tdata = tdata; 393 return PJ_SUCCESS; 373 394 374 395 on_error: 375 396 pjsip_tx_data_dec_ref(tdata); 376 return NULL;397 return status; 377 398 } 378 399 … … 380 401 * Construct a minimal response message for the received request. 381 402 */ 382 PJ_DEF(pjsip_tx_data*) pjsip_endpt_create_response( pjsip_endpoint *endpt, 383 const pjsip_rx_data *rdata, 384 int code) 403 PJ_DEF(pj_status_t) pjsip_endpt_create_response( pjsip_endpoint *endpt, 404 const pjsip_rx_data *rdata, 405 int code, 406 pjsip_tx_data **p_tdata) 385 407 { 386 408 pjsip_tx_data *tdata; … … 389 411 pjsip_via_hdr *via; 390 412 pjsip_rr_hdr *rr; 413 pj_status_t status; 391 414 392 415 /* rdata must be a request message. */ … … 395 418 396 419 /* Log this action. */ 397 PJ_LOG(5,( LOG_THIS, "pjsip_endpt_create_response(rdata=%p, code=%d)",420 PJ_LOG(5,(THIS_FILE, "pjsip_endpt_create_response(rdata=%p, code=%d)", 398 421 rdata, code)); 399 422 400 423 /* Create a new transmit buffer. */ 401 tdata = pjsip_endpt_create_tdata( endpt);402 if ( !tdata)403 return NULL;424 status = pjsip_endpt_create_tdata( endpt, &tdata); 425 if (status != PJ_SUCCESS) 426 return status; 404 427 405 428 /* Create new response message. */ … … 452 475 453 476 /* All done. */ 454 return tdata; 477 *p_tdata = tdata; 478 return PJ_SUCCESS; 455 479 } 456 480 … … 479 503 480 504 /* Log this action. */ 481 PJ_LOG(5,( LOG_THIS, "pjsip_endpt_create_ack(rdata=%p)", rdata));505 PJ_LOG(5,(THIS_FILE, "pjsip_endpt_create_ack(rdata=%p)", rdata)); 482 506 483 507 /* Create new request message. */ … … 503 527 to = (pjsip_to_hdr*)pjsip_msg_find_remove_hdr( invite_msg, 504 528 PJSIP_H_TO, NULL); 505 pj_strdup(tdata->pool, &to->tag, &rdata->to _tag);529 pj_strdup(tdata->pool, &to->tag, &rdata->to->tag); 506 530 pjsip_msg_add_hdr( ack_msg, (pjsip_hdr*)to ); 507 531 … … 543 567 * chapter 9.1 of RFC3261. 544 568 */ 545 PJ_DEF(pjsip_tx_data*) pjsip_endpt_create_cancel( pjsip_endpoint *endpt, 546 pjsip_tx_data *req_tdata ) 569 PJ_DEF(pj_status_t) pjsip_endpt_create_cancel( pjsip_endpoint *endpt, 570 pjsip_tx_data *req_tdata, 571 pjsip_tx_data **p_tdata) 547 572 { 548 573 pjsip_msg *req_msg; /* the original request. */ … … 552 577 pjsip_cseq_hdr *req_cseq, *cseq; 553 578 pjsip_uri *req_uri; 579 pj_status_t status; 554 580 555 581 /* Log this action. */ 556 PJ_LOG(5,( LOG_THIS, "pjsip_endpt_create_cancel(tdata=%p)", req_tdata));582 PJ_LOG(5,(THIS_FILE, "pjsip_endpt_create_cancel(tdata=%p)", req_tdata)); 557 583 558 584 /* Get the original request. */ … … 560 586 561 587 /* The transmit buffer must INVITE request. */ 562 pj_assert(req_msg->type == PJSIP_REQUEST_MSG && 563 req_msg->line.req.method.id == PJSIP_INVITE_METHOD ); 588 PJ_ASSERT_RETURN(req_msg->type == PJSIP_REQUEST_MSG && 589 req_msg->line.req.method.id == PJSIP_INVITE_METHOD, 590 PJ_EINVAL); 564 591 565 592 /* Create new transmit buffer. */ 566 cancel_tdata = pjsip_endpt_create_tdata( endpt);567 if ( !cancel_tdata) {568 return NULL;593 status = pjsip_endpt_create_tdata( endpt, &cancel_tdata); 594 if (status != PJ_SUCCESS) { 595 return status; 569 596 } 570 597 … … 624 651 * Return the transmit buffer containing the CANCEL request. 625 652 */ 626 return cancel_tdata; 653 *p_tdata = cancel_tdata; 654 return PJ_SUCCESS; 627 655 } 628 656 … … 651 679 remote_addr = pjsip_transport_get_remote_addr(req_transport); 652 680 pj_strdup2(pool, &send_addr->host, 653 pj_ sockaddr_get_str_addr(remote_addr));654 send_addr->port = pj_sockaddr_ get_port(remote_addr);681 pj_inet_ntoa(remote_addr->sin_addr)); 682 send_addr->port = pj_sockaddr_in_get_port(remote_addr); 655 683 656 684 } else { -
pjproject/main/pjsip/src/pjsip/sip_msg.c
- Property svn:keywords set to Id
r3 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #include <pjsip/sip_msg.h> 5 #include <pjsip/print .h>4 #include <pjsip/print_util.h> 6 5 #include <pj/string.h> 7 6 #include <pj/pool.h> … … 265 264 } 266 265 267 PJ_DEF( int) pjsip_msg_print( pjsip_msg *msg, char *buf, pj_size_t size)266 PJ_DEF(pj_ssize_t) pjsip_msg_print( pjsip_msg *msg, char *buf, pj_size_t size) 268 267 { 269 268 char *p=buf, *end=buf+size; -
pjproject/main/pjsip/src/pjsip/sip_parser.c
- Property svn:keywords set to Id
r3 r43 1 1 /* $Id$ 2 *3 2 */ 4 3 #include <pjsip/sip_parser.h> … … 6 5 #include <pjsip/sip_msg.h> 7 6 #include <pjsip/sip_auth_parser.h> 8 #include <pj/scanner.h> 7 #include <pjsip/sip_errno.h> 8 #include <pjsip/sip_transport.h> /* rdata structure */ 9 #include <pjlib-util/scanner.h> 9 10 #include <pj/except.h> 10 11 #include <pj/log.h> … … 13 14 #include <pj/pool.h> 14 15 #include <pj/string.h> 15 #include <ctype.h> /* tolower() */ 16 #include <pj/ctype.h> 17 #include <pj/assert.h> 16 18 17 19 #define RESERVED ";/?:@&=+$," … … 20 22 #define USER "&=+$,;?/" 21 23 #define PASS "&=+$," 22 #define TOKEN "-.!%*_=`'~+" /* '+' is because of application/pidf+xml in Content-Type! */ 24 #define TOKEN "-.!%*_=`'~+" /* '+' is because of application/pidf+xml 25 * in Content-Type! */ 23 26 #define HOST "_-." 24 27 #define HEX_DIGIT "abcdefABCDEF" … … 46 49 * Global vars (also extern). 47 50 */ 48 const pj_str_t pjsip_USER_STR = { "user", 4};49 const pj_str_t pjsip_METHOD_STR = { "method", 6};51 const pj_str_t pjsip_USER_STR = { "user", 4}; 52 const pj_str_t pjsip_METHOD_STR = { "method", 6}; 50 53 const pj_str_t pjsip_TRANSPORT_STR = { "transport", 9}; 51 const pj_str_t pjsip_MADDR_STR = { "maddr", 5 }; 52 const pj_str_t pjsip_LR_STR = { "lr", 2 }; 53 const pj_str_t pjsip_SIP_STR = { "sip", 3 }; 54 const pj_str_t pjsip_SIPS_STR = { "sips", 4 }; 55 const pj_str_t pjsip_TEL_STR = { "tel", 3 }; 56 const pj_str_t pjsip_BRANCH_STR = { "branch", 6 }; 57 const pj_str_t pjsip_TTL_STR = { "ttl", 3 }; 58 const pj_str_t pjsip_PNAME_STR = { "received", 8 }; 59 const pj_str_t pjsip_Q_STR = { "q", 1 }; 60 const pj_str_t pjsip_EXPIRES_STR = { "expires", 7 }; 61 const pj_str_t pjsip_TAG_STR = { "tag", 3 }; 62 const pj_str_t pjsip_RPORT_STR = { "rport", 5}; 63 64 pj_char_spec pjsip_HOST_SPEC, /* For scanning host part. */ 65 pjsip_DIGIT_SPEC, /* Decimal digits */ 66 pjsip_ALPHA_SPEC, /* Alpha (A-Z, a-z) */ 67 pjsip_ALNUM_SPEC, /* Decimal + Alpha. */ 68 pjsip_TOKEN_SPEC, /* Token. */ 69 pjsip_HEX_SPEC, /* Hexadecimal digits. */ 70 pjsip_PARAM_CHAR_SPEC, /* For scanning pname (or pvalue when it's not quoted.) */ 71 pjsip_PROBE_USER_HOST_SPEC, /* Hostname characters. */ 72 pjsip_PASSWD_SPEC, /* Password. */ 73 pjsip_USER_SPEC, /* User */ 74 pjsip_ARRAY_ELEMENTS, /* Array separator. */ 75 pjsip_NEWLINE_OR_EOF_SPEC, /* For eating up header.*/ 76 pjsip_DISPLAY_SCAN_SPEC; /* Used when searching for display name in URL. */ 54 const pj_str_t pjsip_MADDR_STR = { "maddr", 5 }; 55 const pj_str_t pjsip_LR_STR = { "lr", 2 }; 56 const pj_str_t pjsip_SIP_STR = { "sip", 3 }; 57 const pj_str_t pjsip_SIPS_STR = { "sips", 4 }; 58 const pj_str_t pjsip_TEL_STR = { "tel", 3 }; 59 const pj_str_t pjsip_BRANCH_STR = { "branch", 6 }; 60 const pj_str_t pjsip_TTL_STR = { "ttl", 3 }; 61 const pj_str_t pjsip_PNAME_STR = { "received", 8 }; 62 const pj_str_t pjsip_Q_STR = { "q", 1 }; 63 const pj_str_t pjsip_EXPIRES_STR = { "expires", 7 }; 64 const pj_str_t pjsip_TAG_STR = { "tag", 3 }; 65 const pj_str_t pjsip_RPORT_STR = { "rport", 5}; 66 67 /* Character Input Specification buffer. */ 68 static pj_cis_buf_t cis_buf; 69 70 /* Character Input Specifications. */ 71 pj_cis_t pjsip_HOST_SPEC, /* For scanning host part. */ 72 pjsip_DIGIT_SPEC, /* Decimal digits */ 73 pjsip_ALPHA_SPEC, /* Alpha (A-Z, a-z) */ 74 pjsip_ALNUM_SPEC, /* Decimal + Alpha. */ 75 pjsip_TOKEN_SPEC, /* Token. */ 76 pjsip_HEX_SPEC, /* Hexadecimal digits. */ 77 pjsip_PARAM_CHAR_SPEC, /* For scanning pname (or pvalue when 78 * it's not quoted.) */ 79 pjsip_PROBE_USER_HOST_SPEC, /* Hostname characters. */ 80 pjsip_PASSWD_SPEC, /* Password. */ 81 pjsip_USER_SPEC, /* User */ 82 pjsip_ARRAY_ELEMENTS, /* Array separator. */ 83 pjsip_NEWLINE_OR_EOF_SPEC, /* For eating up header.*/ 84 pjsip_DISPLAY_SCAN_SPEC; /* Used when searching for display name 85 * in URL. */ 77 86 78 87 … … 80 89 * Forward decl. 81 90 */ 82 static pjsip_msg * int_parse_msg( pj_scanner *scanner, 83 pj_pool_t *pool, 84 pjsip_parser_err_report *err_list); 85 static void int_parse_param( pj_scanner *scanner, 86 pj_str_t *pname, 87 pj_str_t *pvalue); 88 static void int_parse_req_line( pj_scanner *scanner, 89 pj_pool_t *pool, 90 pjsip_request_line *req_line); 91 static int int_is_next_user( pj_scanner *scanner); 92 static void int_parse_status_line( pj_scanner *scanner, 93 pjsip_status_line *line); 94 static void int_parse_user_pass( pj_scanner *scanner, 95 pj_str_t *user, 96 pj_str_t *pass); 97 static void int_parse_uri_host_port( pj_scanner *scanner, 98 pj_str_t *p_host, 99 int *p_port); 100 static pjsip_uri * int_parse_uri_or_name_addr( pj_scanner *scanner, 101 pj_pool_t *pool, unsigned option); 102 static pjsip_url * int_parse_sip_url( pj_scanner *scanner, 103 pj_pool_t *pool, 104 pj_bool_t parse_params); 105 static pjsip_name_addr* int_parse_name_addr( pj_scanner *scanner, 106 pj_pool_t *pool ); 107 static void parse_hdr_end( pj_scanner *scanner ); 108 static pjsip_accept_hdr* parse_hdr_accept( pj_scanner *scanner, 109 pj_pool_t *pool); 110 static pjsip_allow_hdr* parse_hdr_allow( pj_scanner *scanner, 111 pj_pool_t *pool); 112 static pjsip_cid_hdr* parse_hdr_call_id( pj_scanner *scanner, 113 pj_pool_t *pool); 114 static pjsip_contact_hdr* parse_hdr_contact( pj_scanner *scanner, 115 pj_pool_t *pool); 116 static pjsip_clen_hdr* parse_hdr_content_length( pj_scanner *scanner, 117 pj_pool_t *pool); 118 static pjsip_ctype_hdr* parse_hdr_content_type( pj_scanner *scanner, 119 pj_pool_t *pool); 120 static pjsip_cseq_hdr* parse_hdr_cseq( pj_scanner *scanner, 121 pj_pool_t *pool); 122 static pjsip_expires_hdr* parse_hdr_expires( pj_scanner *scanner, 123 pj_pool_t *pool); 124 static pjsip_from_hdr* parse_hdr_from( pj_scanner *scanner, 125 pj_pool_t *pool); 126 static pjsip_max_forwards_hdr* parse_hdr_max_forwards( pj_scanner *scanner, 127 pj_pool_t *pool); 128 static pjsip_min_expires_hdr* parse_hdr_min_expires( pj_scanner *scanner, 129 pj_pool_t *pool); 130 static pjsip_rr_hdr* parse_hdr_rr( pj_scanner *scanner, 131 pj_pool_t *pool); 132 static pjsip_route_hdr* parse_hdr_route( pj_scanner *scanner, 133 pj_pool_t *pool); 134 static pjsip_require_hdr* parse_hdr_require( pj_scanner *scanner, 135 pj_pool_t *pool); 136 static pjsip_retry_after_hdr* parse_hdr_retry_after( pj_scanner *scanner, 137 pj_pool_t *pool); 138 static pjsip_supported_hdr* parse_hdr_supported( pj_scanner *scanner, 139 pj_pool_t *pool); 140 static pjsip_to_hdr* parse_hdr_to( pj_scanner *scanner, 141 pj_pool_t *pool); 142 static pjsip_unsupported_hdr* parse_hdr_unsupported( pj_scanner *scanner, 143 pj_pool_t *pool); 144 static pjsip_via_hdr* parse_hdr_via( pj_scanner *scanner, 145 pj_pool_t *pool); 146 static pjsip_generic_string_hdr* parse_hdr_generic_string( pj_scanner *scanner, 147 pj_pool_t *pool); 91 static pjsip_msg * int_parse_msg( pjsip_parse_ctx *ctx, 92 pjsip_parser_err_report *err_list); 93 static void int_parse_param( pj_scanner *scanner, 94 pj_str_t *pname, 95 pj_str_t *pvalue); 96 static void int_parse_req_line( pj_scanner *scanner, 97 pj_pool_t *pool, 98 pjsip_request_line *req_line); 99 static int int_is_next_user( pj_scanner *scanner); 100 static void int_parse_status_line( pj_scanner *scanner, 101 pjsip_status_line *line); 102 static void int_parse_user_pass( pj_scanner *scanner, 103 pj_str_t *user, 104 pj_str_t *pass); 105 static void int_parse_uri_host_port( pj_scanner *scanner, 106 pj_str_t *p_host, 107 int *p_port); 108 static pjsip_uri * int_parse_uri_or_name_addr( pj_scanner *scanner, 109 pj_pool_t *pool, 110 unsigned option); 111 static pjsip_url * int_parse_sip_url( pj_scanner *scanner, 112 pj_pool_t *pool, 113 pj_bool_t parse_params); 114 static pjsip_name_addr * 115 int_parse_name_addr( pj_scanner *scanner, 116 pj_pool_t *pool ); 117 static void parse_hdr_end( pj_scanner *scanner ); 118 119 static pjsip_hdr* parse_hdr_accept( pjsip_parse_ctx *ctx ); 120 static pjsip_hdr* parse_hdr_allow( pjsip_parse_ctx *ctx ); 121 static pjsip_hdr* parse_hdr_call_id( pjsip_parse_ctx *ctx); 122 static pjsip_hdr* parse_hdr_contact( pjsip_parse_ctx *ctx); 123 static pjsip_hdr* parse_hdr_content_len( pjsip_parse_ctx *ctx ); 124 static pjsip_hdr* parse_hdr_content_type( pjsip_parse_ctx *ctx ); 125 static pjsip_hdr* parse_hdr_cseq( pjsip_parse_ctx *ctx ); 126 static pjsip_hdr* parse_hdr_expires( pjsip_parse_ctx *ctx ); 127 static pjsip_hdr* parse_hdr_from( pjsip_parse_ctx *ctx ); 128 static pjsip_hdr* parse_hdr_max_forwards( pjsip_parse_ctx *ctx); 129 static pjsip_hdr* parse_hdr_min_expires( pjsip_parse_ctx *ctx ); 130 static pjsip_hdr* parse_hdr_rr( pjsip_parse_ctx *ctx ); 131 static pjsip_hdr* parse_hdr_route( pjsip_parse_ctx *ctx ); 132 static pjsip_hdr* parse_hdr_require( pjsip_parse_ctx *ctx ); 133 static pjsip_hdr* parse_hdr_retry_after( pjsip_parse_ctx *ctx ); 134 static pjsip_hdr* parse_hdr_supported( pjsip_parse_ctx *ctx ); 135 static pjsip_hdr* parse_hdr_to( pjsip_parse_ctx *ctx ); 136 static pjsip_hdr* parse_hdr_unsupported( pjsip_parse_ctx *ctx ); 137 static pjsip_hdr* parse_hdr_via( pjsip_parse_ctx *ctx ); 138 static pjsip_hdr* parse_hdr_generic_string( pjsip_parse_ctx *ctx); 148 139 149 140 /* Convert non NULL terminated string to integer. */ 150 static unsigned long pj_strtoul_mindigit(const pj_str_t *str, unsigned mindig) 141 static unsigned long pj_strtoul_mindigit(const pj_str_t *str, 142 unsigned mindig) 151 143 { 152 144 unsigned long value; … … 164 156 165 157 /* Case insensitive comparison */ 166 #define parser_stricmp(str1, str2) \ 167 (str1.slen != str2.slen ? -1 : \ 168 !(memcmp(str1.ptr, str2.ptr, str1.slen)==0 || stricmp(str1.ptr, str2.ptr)==0)) 158 #define parser_stricmp(str1, str2) pj_stricmp(&str1, &str2) 159 169 160 170 161 /* Syntax error handler for parser. */ 171 162 static void on_syntax_error(pj_scanner *scanner) 172 163 { 173 PJ_UNUSED_ARG(scanner) 164 PJ_UNUSED_ARG(scanner); 174 165 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 175 166 } … … 177 168 /* Concatenate unrecognized params into single string. */ 178 169 void pjsip_concat_param_imp( pj_str_t *param, pj_pool_t *pool, 179 const pj_str_t *pname, const pj_str_t *pvalue, int sepchar) 170 const pj_str_t *pname, const pj_str_t *pvalue, 171 int sepchar) 180 172 { 181 173 char *new_param, *p; … … 214 206 215 207 /* Initialize static properties of the parser. */ 216 static voidinit_parser()208 static pj_status_t init_parser() 217 209 { 218 210 static int initialized; 211 pj_status_t status; 219 212 220 213 if (initialized) 221 return ;214 return PJ_SUCCESS; 222 215 223 216 initialized = 1; 224 217 225 pj_cs_add_num( pjsip_DIGIT_SPEC ); 226 pj_cs_add_alpha( pjsip_ALPHA_SPEC ); 218 pj_cis_buf_init(&cis_buf); 219 220 status = pj_cis_init(&cis_buf, &pjsip_DIGIT_SPEC); 221 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 222 pj_cis_add_num(&pjsip_DIGIT_SPEC); 227 223 228 pj_cs_add_alpha( pjsip_ALNUM_SPEC ); 229 pj_cs_add_num( pjsip_ALNUM_SPEC ); 230 231 pj_cs_add_str(pjsip_NEWLINE_OR_EOF_SPEC, "\r\n"); 224 status = pj_cis_init(&cis_buf, &pjsip_ALPHA_SPEC); 225 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 226 pj_cis_add_alpha( &pjsip_ALPHA_SPEC ); 227 228 status = pj_cis_init(&cis_buf, &pjsip_ALNUM_SPEC); 229 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 230 pj_cis_add_alpha( &pjsip_ALNUM_SPEC ); 231 pj_cis_add_num( &pjsip_ALNUM_SPEC ); 232 233 status = pj_cis_init(&cis_buf, &pjsip_NEWLINE_OR_EOF_SPEC); 234 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 235 pj_cis_add_str(&pjsip_NEWLINE_OR_EOF_SPEC, "\r\n"); 232 236 //pj_cs_set(pjsip_NEWLINE_OR_EOF_SPEC, 0); 233 237 234 pj_cs_add_str( pjsip_ARRAY_ELEMENTS, ",\r\n"); 235 236 pj_memcpy(pjsip_TOKEN_SPEC, pjsip_ALNUM_SPEC, sizeof(pj_char_spec)); 237 pj_cs_add_str( pjsip_TOKEN_SPEC, TOKEN); 238 239 pj_memcpy(pjsip_HOST_SPEC, pjsip_ALNUM_SPEC, sizeof(pj_char_spec)); 240 pj_cs_add_str( pjsip_HOST_SPEC, HOST); 241 242 pj_memcpy(pjsip_HEX_SPEC, pjsip_DIGIT_SPEC, sizeof(pj_char_spec)); 243 pj_cs_add_str( pjsip_HEX_SPEC, HEX_DIGIT); 244 245 pj_memcpy(pjsip_PARAM_CHAR_SPEC, pjsip_ALNUM_SPEC, sizeof(pj_char_spec)); 246 pj_cs_add_str( pjsip_PARAM_CHAR_SPEC, PARAM_CHAR); 247 248 pj_memcpy(pjsip_USER_SPEC, pjsip_ALNUM_SPEC, sizeof(pj_char_spec)); 249 pj_cs_add_str( pjsip_USER_SPEC, MARK ESCAPED USER ); 250 251 pj_memcpy(pjsip_PASSWD_SPEC, pjsip_ALNUM_SPEC, sizeof(pj_char_spec)); 252 pj_cs_add_str( pjsip_PASSWD_SPEC, MARK ESCAPED PASS); 253 254 pj_cs_add_str( pjsip_PROBE_USER_HOST_SPEC, "@ \n>"); 255 pj_cs_invert( pjsip_PROBE_USER_HOST_SPEC ); 256 257 pj_cs_add_str( pjsip_DISPLAY_SCAN_SPEC, ":\r\n<"); 258 259 pjsip_register_hdr_parser( "Accept", NULL, (pjsip_parse_hdr_func*) &parse_hdr_accept); 260 pjsip_register_hdr_parser( "Allow", NULL, (pjsip_parse_hdr_func*) &parse_hdr_allow); 261 pjsip_register_hdr_parser( "Call-ID", NULL, (pjsip_parse_hdr_func*) &parse_hdr_call_id); 262 pjsip_register_hdr_parser( "Contact", "m", (pjsip_parse_hdr_func*) &parse_hdr_contact); 263 pjsip_register_hdr_parser( "Content-Length", NULL, (pjsip_parse_hdr_func*) &parse_hdr_content_length); 264 pjsip_register_hdr_parser( "Content-Type", NULL, (pjsip_parse_hdr_func*) &parse_hdr_content_type); 265 pjsip_register_hdr_parser( "CSeq", NULL, (pjsip_parse_hdr_func*) &parse_hdr_cseq); 266 pjsip_register_hdr_parser( "Expires", NULL, (pjsip_parse_hdr_func*) &parse_hdr_expires); 267 pjsip_register_hdr_parser( "From", "f", (pjsip_parse_hdr_func*) &parse_hdr_from); 268 pjsip_register_hdr_parser( "Max-Forwards", NULL, (pjsip_parse_hdr_func*) &parse_hdr_max_forwards); 269 pjsip_register_hdr_parser( "Min-Expires", NULL, (pjsip_parse_hdr_func*) &parse_hdr_min_expires); 270 pjsip_register_hdr_parser( "Record-Route", NULL, (pjsip_parse_hdr_func*) &parse_hdr_rr); 271 pjsip_register_hdr_parser( "Route", NULL, (pjsip_parse_hdr_func*) &parse_hdr_route); 272 pjsip_register_hdr_parser( "Require", NULL, (pjsip_parse_hdr_func*) &parse_hdr_require); 273 pjsip_register_hdr_parser( "Retry-After", NULL, (pjsip_parse_hdr_func*) &parse_hdr_retry_after); 274 pjsip_register_hdr_parser( "Supported", "k", (pjsip_parse_hdr_func*) &parse_hdr_supported); 275 pjsip_register_hdr_parser( "To", "t", (pjsip_parse_hdr_func*) &parse_hdr_to); 276 pjsip_register_hdr_parser( "Unsupported", NULL, (pjsip_parse_hdr_func*) &parse_hdr_unsupported); 277 pjsip_register_hdr_parser( "Via", NULL, (pjsip_parse_hdr_func*) &parse_hdr_via); 238 status = pj_cis_init(&cis_buf, &pjsip_ARRAY_ELEMENTS); 239 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 240 pj_cis_add_str( &pjsip_ARRAY_ELEMENTS, ",\r\n"); 241 242 status = pj_cis_dup(&pjsip_TOKEN_SPEC, &pjsip_ALNUM_SPEC); 243 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 244 pj_cis_add_str( &pjsip_TOKEN_SPEC, TOKEN); 245 246 status = pj_cis_dup(&pjsip_HOST_SPEC, &pjsip_ALNUM_SPEC); 247 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 248 pj_cis_add_str( &pjsip_HOST_SPEC, HOST); 249 250 status = pj_cis_dup(&pjsip_HEX_SPEC, &pjsip_DIGIT_SPEC); 251 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 252 pj_cis_add_str( &pjsip_HEX_SPEC, HEX_DIGIT); 253 254 status = pj_cis_dup(&pjsip_PARAM_CHAR_SPEC, &pjsip_ALNUM_SPEC); 255 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 256 pj_cis_add_str(&pjsip_PARAM_CHAR_SPEC, PARAM_CHAR); 257 258 status = pj_cis_dup(&pjsip_USER_SPEC, &pjsip_ALNUM_SPEC); 259 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 260 pj_cis_add_str( &pjsip_USER_SPEC, MARK ESCAPED USER ); 261 262 status = pj_cis_dup(&pjsip_PASSWD_SPEC, &pjsip_ALNUM_SPEC); 263 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 264 pj_cis_add_str( &pjsip_PASSWD_SPEC, MARK ESCAPED PASS); 265 266 status = pj_cis_init(&cis_buf, &pjsip_PROBE_USER_HOST_SPEC); 267 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 268 pj_cis_add_str( &pjsip_PROBE_USER_HOST_SPEC, "@ \n>"); 269 pj_cis_invert( &pjsip_PROBE_USER_HOST_SPEC ); 270 271 status = pj_cis_init(&cis_buf, &pjsip_DISPLAY_SCAN_SPEC); 272 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 273 pj_cis_add_str( &pjsip_DISPLAY_SCAN_SPEC, ":\r\n<"); 274 275 status = pjsip_register_hdr_parser( "Accept", NULL, &parse_hdr_accept); 276 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 277 278 status = pjsip_register_hdr_parser( "Allow", NULL, &parse_hdr_allow); 279 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 280 281 status = pjsip_register_hdr_parser( "Call-ID", NULL, &parse_hdr_call_id); 282 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 283 284 status = pjsip_register_hdr_parser( "Contact", "m", &parse_hdr_contact); 285 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 286 287 status = pjsip_register_hdr_parser( "Content-Length", NULL, 288 &parse_hdr_content_len); 289 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 290 291 status = pjsip_register_hdr_parser( "Content-Type", NULL, 292 &parse_hdr_content_type); 293 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 294 295 status = pjsip_register_hdr_parser( "CSeq", NULL, &parse_hdr_cseq); 296 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 297 298 status = pjsip_register_hdr_parser( "Expires", NULL, &parse_hdr_expires); 299 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 300 301 status = pjsip_register_hdr_parser( "From", "f", &parse_hdr_from); 302 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 303 304 status = pjsip_register_hdr_parser( "Max-Forwards", NULL, 305 &parse_hdr_max_forwards); 306 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 307 308 status = pjsip_register_hdr_parser( "Min-Expires", NULL, 309 &parse_hdr_min_expires); 310 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 311 312 status = pjsip_register_hdr_parser( "Record-Route", NULL, &parse_hdr_rr); 313 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 314 315 status = pjsip_register_hdr_parser( "Route", NULL, &parse_hdr_route); 316 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 317 318 status = pjsip_register_hdr_parser( "Require", NULL, &parse_hdr_require); 319 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 320 321 status = pjsip_register_hdr_parser( "Retry-After", NULL, 322 &parse_hdr_retry_after); 323 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 324 325 status = pjsip_register_hdr_parser( "Supported", "k", 326 &parse_hdr_supported); 327 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 328 329 status = pjsip_register_hdr_parser( "To", "t", &parse_hdr_to); 330 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 331 332 status = pjsip_register_hdr_parser( "Unsupported", NULL, 333 &parse_hdr_unsupported); 334 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 335 336 status = pjsip_register_hdr_parser( "Via", NULL, &parse_hdr_via); 337 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 278 338 279 339 /* Register auth parser. */ 280 pjsip_auth_init_parser(); 281 282 } 283 284 static void init_sip_parser() 340 status = pjsip_auth_init_parser(); 341 342 return status; 343 } 344 345 static void init_sip_parser(void) 285 346 { 286 347 if (!parser_is_initialized) { … … 318 379 319 380 /* Equal length and equal hash. compare the strings. */ 320 return strcmp(r1->hname, name);381 return pj_native_strcmp(r1->hname, name); 321 382 } 322 383 323 384 /* Register one handler for one header name. */ 324 static int int_register_parser( const char *name, pjsip_parse_hdr_func *fptr ) 385 static pj_status_t int_register_parser( const char *name, 386 pjsip_parse_hdr_func *fptr ) 325 387 { 326 388 unsigned pos; … … 329 391 330 392 if (handler_count >= PJ_ARRAY_SIZE(handler)) { 331 return -1;393 return PJ_ETOOMANY; 332 394 } 333 395 … … 336 398 rec.hname_len = strlen(name); 337 399 if (rec.hname_len >= sizeof(rec.hname)) { 338 return -1;400 return PJ_ENAMETOOLONG; 339 401 } 340 402 /* Name is copied in lowercase. */ 341 403 for (i=0; i<rec.hname_len; ++i) { 342 rec.hname[i] = (char) tolower(name[i]);404 rec.hname[i] = (char)pj_tolower(name[i]); 343 405 } 344 406 rec.hname[i] = '\0'; … … 349 411 for (pos=0; pos < handler_count; ++pos) { 350 412 int d; 351 d = compare_handler(&handler[pos], rec.hname, rec.hname_len, rec.hname_hash); 413 d = compare_handler(&handler[pos], rec.hname, rec.hname_len, 414 rec.hname_hash); 352 415 if (d == 0) { 353 416 pj_assert(0); 354 return -1;417 return PJ_EEXISTS; 355 418 } 356 419 if (d > 0) { … … 361 424 /* Shift handlers. */ 362 425 if (pos != handler_count) { 363 pj_memmove( &handler[pos+1], &handler[pos], (handler_count-pos)*sizeof(handler_rec)); 426 pj_memmove( &handler[pos+1], &handler[pos], 427 (handler_count-pos)*sizeof(handler_rec)); 364 428 } 365 429 /* Add new handler. */ … … 367 431 ++handler_count; 368 432 369 return 0;433 return PJ_SUCCESS; 370 434 } 371 435 … … 377 441 pjsip_parse_hdr_func *fptr) 378 442 { 379 if (int_register_parser(hname, fptr)) { 380 return -1; 381 } 382 if (hshortname && int_register_parser(hshortname, fptr)) { 383 return -1; 384 } 385 return 0; 443 pj_status_t status; 444 445 status = int_register_parser(hname, fptr); 446 if (status != PJ_SUCCESS) { 447 return status; 448 } 449 if (hshortname) { 450 status = int_register_parser(hshortname, fptr); 451 if (status != PJ_SUCCESS) 452 return status; 453 } 454 return PJ_SUCCESS; 386 455 } 387 456 … … 393 462 pj_uint32_t hash; 394 463 int comp; 395 unsigned i, n; 464 unsigned n; 465 466 if (hname->slen >= PJSIP_MAX_HNAME_LEN) { 467 pj_assert(!"Header name is too long!"); 468 return NULL; 469 } 396 470 397 471 /* Calculate hash value while converting the header to lowercase. 398 472 * Don't assume that 'hname' is NULL terminated. 399 473 */ 400 hash = 0; 401 for (i=0; i<(unsigned)hname->slen; ++i) { 402 hname_copy[i] = (char)tolower(hname->ptr[i]); 403 hash = hash * PJ_HASH_MULTIPLIER + hname_copy[i]; 404 } 405 hname_copy[i] = '\0'; 474 hash = pj_hash_calc_tolower(0, hname_copy, hname); 475 hname_copy[hname->slen] = '\0'; 406 476 407 477 /* Binary search for the handler. */ … … 429 499 430 500 /* Public function to parse SIP message. */ 431 PJ_DEF(pjsip_msg*) pjsip_parse_msg( pj_pool_t *pool, char *buf, pj_size_t size, 501 PJ_DEF(pjsip_msg*) pjsip_parse_msg( pj_pool_t *pool, 502 char *buf, pj_size_t size, 432 503 pjsip_parser_err_report *err_list) 433 504 { 434 505 pjsip_msg *msg = NULL; 435 506 pj_scanner scanner; 507 pjsip_parse_ctx context; 436 508 PJ_USE_EXCEPTION; 437 509 438 510 init_sip_parser(); 439 511 440 pj_scan_init(&scanner, buf, size, PJ_SCAN_AUTOSKIP_WS_HEADER, &on_syntax_error); 512 pj_scan_init(&scanner, buf, size, PJ_SCAN_AUTOSKIP_WS_HEADER, 513 &on_syntax_error); 514 515 context.scanner = &scanner; 516 context.pool = pool; 517 context.rdata = NULL; 441 518 442 519 PJ_TRY { 443 msg = int_parse_msg(& scanner, pool, err_list);520 msg = int_parse_msg(&context, err_list); 444 521 } 445 522 PJ_DEFAULT { … … 450 527 pj_scan_fini(&scanner); 451 528 return msg; 529 } 530 531 /* Public function to parse as rdata.*/ 532 PJ_DEF(pjsip_msg *) pjsip_parse_rdata( char *buf, pj_size_t size, 533 pjsip_rx_data *rdata ) 534 { 535 pj_scanner scanner; 536 pjsip_parse_ctx context; 537 PJ_USE_EXCEPTION; 538 539 init_sip_parser(); 540 541 pj_scan_init(&scanner, buf, size, PJ_SCAN_AUTOSKIP_WS_HEADER, 542 &on_syntax_error); 543 544 context.scanner = &scanner; 545 context.pool = rdata->pool; 546 context.rdata = rdata; 547 548 PJ_TRY { 549 rdata->msg = int_parse_msg(&context, &rdata->parse_err); 550 } 551 PJ_DEFAULT { 552 rdata->msg = NULL; 553 } 554 PJ_END 555 556 pj_scan_fini(&scanner); 557 return rdata->msg; 452 558 } 453 559 … … 467 573 /* For datagram, the whole datagram IS the message. */ 468 574 if (is_datagram) { 469 return PJ_ TRUE;575 return PJ_SUCCESS; 470 576 } 471 577 472 578 473 579 /* Find the end of header area by finding an empty line. */ 474 if ((pos = strstr(buf, "\n\r\n")) == NULL) {475 return PJ _FALSE;580 if ((pos = pj_native_strstr(buf, "\n\r\n")) == NULL) { 581 return PJSIP_EPARTIALMSG; 476 582 } 477 583 … … 480 586 481 587 /* Find "Content-Length" header the hard way. */ 482 line = strchr(buf, '\n');588 line = pj_native_strchr(buf, '\n'); 483 589 while (line && line < hdr_end-14) { 484 590 ++line; 485 if ( ((*line=='C' || *line=='c') && strncasecmp(line, "Content-Length", 14) == 0) || 486 ((*line=='l' || *line=='L') && (*(line+1)==' ' || *(line+1)=='\t' || *(line+1)==':'))) 591 if ( ((*line=='C' || *line=='c') && 592 pj_native_strncasecmp(line, "Content-Length", 14) == 0) || 593 ((*line=='l' || *line=='L') && 594 (*(line+1)==' ' || *(line+1)=='\t' || *(line+1)==':'))) 487 595 { 488 596 /* Try to parse the header. */ … … 510 618 511 619 /* Get number */ 512 pj_scan_get(&scanner, pjsip_DIGIT_SPEC, &str_clen);620 pj_scan_get(&scanner, &pjsip_DIGIT_SPEC, &str_clen); 513 621 514 622 /* Get newline. */ … … 528 636 529 637 /* Go to next line. */ 530 line = strchr(line, '\n');638 line = pj_native_strchr(line, '\n'); 531 639 } 532 640 533 641 /* Found Content-Length? */ 534 642 if (content_length == -1) { 535 PJ_LOG(4, ("sipparser", "pjsip_find_msg: incoming TCP packet has missing " 536 "Content-Length header, treated as incomplete.")); 537 return PJ_FALSE; 643 return PJSIP_EMISSINGHDR; 538 644 } 539 645 540 646 /* Enough packet received? */ 541 647 *msg_size = (body_start - buf) + content_length; 542 return (*msg_size) <= size ;648 return (*msg_size) <= size ? PJ_SUCCESS : PJSIP_EPARTIALMSG; 543 649 #else 544 PJ_UNUSED_ARG(buf) 545 PJ_UNUSED_ARG(is_datagram) 650 PJ_UNUSED_ARG(buf); 651 PJ_UNUSED_ARG(is_datagram); 546 652 *msg_size = size; 547 return 1;653 return PJ_SUCCESS; 548 654 #endif 549 655 } … … 558 664 pjsip_uri *uri = NULL; 559 665 560 if (!parser_is_initialized) { 561 init_parser(); 562 parser_is_initialized = 1; 563 } 666 init_sip_parser(); 564 667 565 668 pj_scan_init(&scanner, buf, size, 0, &on_syntax_error); … … 572 675 573 676 /* Must have exhausted all inputs. */ 574 if (pj_scan_is_eof(&scanner) || *scanner.current=='\r' || *scanner.current=='\n') { 677 if (pj_scan_is_eof(&scanner) || *scanner.curptr=='\r' || 678 *scanner.curptr=='\n') 679 { 575 680 /* Success. */ 576 681 pj_scan_fini(&scanner); … … 587 692 * actual body is laid. 588 693 */ 589 static int generic_print_body (pjsip_msg_body *msg_body, char *buf, pj_size_t size) 694 static int generic_print_body (pjsip_msg_body *msg_body, 695 char *buf, pj_size_t size) 590 696 { 591 697 pjsip_msg_body *body = msg_body; … … 598 704 599 705 /* Internal function to parse SIP message */ 600 static pjsip_msg *int_parse_msg( pj _scanner *scanner, pj_pool_t *pool,706 static pjsip_msg *int_parse_msg( pjsip_parse_ctx *ctx, 601 707 pjsip_parser_err_report *err_list) 602 708 { … … 605 711 pjsip_msg *msg; 606 712 pjsip_ctype_hdr *ctype_hdr = NULL; 713 pj_scanner *scanner = ctx->scanner; 714 pj_pool_t *pool = ctx->pool; 607 715 608 716 /* Skip leading newlines. */ 609 ch = *scanner->cur rent;717 ch = *scanner->curptr; 610 718 while (ch=='\r' || ch=='\n') { 611 719 pj_scan_get_char(scanner); 612 ch = *scanner->cur rent;720 ch = *scanner->curptr; 613 721 } 614 722 … … 631 739 632 740 /* Get hname. */ 633 pj_scan_get( scanner, pjsip_TOKEN_SPEC, &hname);741 pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &hname); 634 742 ch = pj_scan_get_char( scanner ); 635 743 if (ch != ':') { … … 646 754 */ 647 755 if (handler) { 648 hdr = (*handler)( scanner, pool);756 hdr = (*handler)(ctx); 649 757 } else { 650 pjsip_generic_string_hdr *ghdr = parse_hdr_generic_string(scanner, pool); 651 ghdr->type = PJSIP_H_OTHER; 652 ghdr->name = ghdr->sname = hname; 653 hdr = (pjsip_hdr*)ghdr; 758 hdr = parse_hdr_generic_string(ctx); 759 hdr->type = PJSIP_H_OTHER; 760 hdr->name = hdr->sname = hname; 654 761 } 655 762 … … 669 776 hdr = NULL; 670 777 671 PJ_LOG(4,("sipparser", "Syntax error in line %d col %d (hname=%.*s)", 672 scanner->line, scanner->col, hname.slen, hname.ptr)); 778 //PJ_LOG(4,("sipparser", 779 // "Syntax error in line %d col %d (hname=%.*s)", 780 // scanner->line, scanner->col, hname.slen, hname.ptr)); 673 781 674 782 if (err_list) { … … 685 793 686 794 if (!pj_scan_is_eof(scanner)) { 687 pj_scan_get_until(scanner, pjsip_NEWLINE_OR_EOF_SPEC, &token);795 pj_scan_get_until(scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &token); 688 796 parse_hdr_end(scanner); 689 797 } … … 703 811 /* Parse until EOF or an empty line is found. */ 704 812 } while (!pj_scan_is_eof(scanner) && 705 *scanner->cur rent != '\r' && *scanner->current!= '\n');813 *scanner->curptr != '\r' && *scanner->curptr != '\n'); 706 814 707 815 /* If empty line is found, eat it. */ 708 816 if (!pj_scan_is_eof(scanner)) { 709 if (*scanner->cur rent=='\r' || *scanner->current=='\n') {817 if (*scanner->curptr=='\r' || *scanner->curptr=='\n') { 710 818 pj_scan_get_newline(scanner); 711 819 } 712 820 } 713 821 714 /* If we have Content-Type header, treat the rest of the message as body. 822 /* If we have Content-Type header, treat the rest of the message as body.*/ 715 823 if (ctype_hdr) { 716 824 pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body)); 717 pj_strdup 718 pj_strdup 719 pj_strdup 720 body->data = scanner->cur rent;721 body->len = scanner->end - scanner->cur rent;825 pj_strdup(pool, &body->content_type.type, &ctype_hdr->media.type); 826 pj_strdup(pool, &body->content_type.subtype, &ctype_hdr->media.subtype); 827 pj_strdup(pool, &body->content_type.param, &ctype_hdr->media.param); 828 body->data = scanner->curptr; 829 body->len = scanner->end - scanner->curptr; 722 830 body->print_body = &generic_print_body; 723 831 … … 734 842 { 735 843 /* pname */ 736 pj_scan_get(scanner, pjsip_PARAM_CHAR_SPEC, pname);844 pj_scan_get(scanner, &pjsip_PARAM_CHAR_SPEC, pname); 737 845 738 846 /* pvalue, if any */ 739 if (*scanner->cur rent== '=') {847 if (*scanner->curptr == '=') { 740 848 pj_scan_get_char(scanner); 741 849 /* pvalue can be a quoted string. */ 742 if (*scanner->cur rent== '"') {850 if (*scanner->curptr == '"') { 743 851 pj_scan_get_quote( scanner, '"', '"', pvalue); 744 852 if (option & PJSIP_PARSE_REMOVE_QUOTE) { … … 747 855 } 748 856 } else { 749 pj_scan_get(scanner, pjsip_PARAM_CHAR_SPEC, pvalue);857 pj_scan_get(scanner, &pjsip_PARAM_CHAR_SPEC, pvalue); 750 858 } 751 859 } else { … … 770 878 pj_str_t *host, int *p_port) 771 879 { 772 pj_scan_get( scanner, pjsip_HOST_SPEC, host);773 if (*scanner->cur rent== ':') {880 pj_scan_get( scanner, &pjsip_HOST_SPEC, host); 881 if (*scanner->curptr == ':') { 774 882 pj_str_t port; 775 883 pj_scan_get_char(scanner); 776 pj_scan_get(scanner, pjsip_DIGIT_SPEC, &port);884 pj_scan_get(scanner, &pjsip_DIGIT_SPEC, &port); 777 885 *p_port = pj_strtoul(&port); 778 886 } else { … … 790 898 * must be a username. 791 899 */ 792 if (pj_scan_peek( scanner, pjsip_PROBE_USER_HOST_SPEC, &dummy) == '@')900 if (pj_scan_peek( scanner, &pjsip_PROBE_USER_HOST_SPEC, &dummy) == '@') 793 901 is_user = 1; 794 902 else … … 802 910 pj_str_t *user, pj_str_t *pass) 803 911 { 804 pj_scan_get( scanner, pjsip_USER_SPEC, user);805 if ( *scanner->cur rent== ':') {912 pj_scan_get( scanner, &pjsip_USER_SPEC, user); 913 if ( *scanner->curptr == ':') { 806 914 pj_scan_get_char( scanner ); 807 pj_scan_get( scanner, pjsip_PASSWD_SPEC, pass);915 pj_scan_get( scanner, &pjsip_PASSWD_SPEC, pass); 808 916 } else { 809 917 pass->ptr = NULL; … … 816 924 817 925 /* Parse all types of URI. */ 818 static pjsip_uri *int_parse_uri_or_name_addr( pj_scanner *scanner, pj_pool_t *pool,819 unsigned option)926 static pjsip_uri *int_parse_uri_or_name_addr( pj_scanner *scanner, pj_pool_t *pool, 927 unsigned opt) 820 928 { 821 929 pjsip_uri *uri; 822 930 int is_name_addr = 0; 823 931 824 if (*scanner->cur rent=='"' || *scanner->current=='<') {932 if (*scanner->curptr=='"' || *scanner->curptr=='<') { 825 933 uri = (pjsip_uri*)int_parse_name_addr( scanner, pool ); 826 934 is_name_addr = 1; … … 831 939 832 940 pj_scan_save_state( scanner, &backtrack); 833 pj_scan_get( scanner, pjsip_TOKEN_SPEC, &scheme);941 pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &scheme); 834 942 colon = pj_scan_get_char( scanner ); 835 943 pj_scan_restore_state( scanner, &backtrack); 836 944 837 if (colon==':' && (parser_stricmp(scheme, pjsip_SIP_STR)==0 || parser_stricmp(scheme, pjsip_SIPS_STR)==0)) 945 if (colon==':' && 946 (parser_stricmp(scheme, pjsip_SIP_STR)==0 || 947 parser_stricmp(scheme, pjsip_SIPS_STR)==0)) 838 948 { 839 uri = (pjsip_uri*)int_parse_sip_url( scanner, pool, 840 (option & PJSIP_PARSE_URI_IN_FROM_TO_HDR) == 0 ); 949 uri = (pjsip_uri*) 950 int_parse_sip_url( scanner, pool, 951 (opt & PJSIP_PARSE_URI_IN_FROM_TO_HDR)== 0); 841 952 842 953 } else if (colon==':' && parser_stricmp( scheme, pjsip_TEL_STR)==0) { … … 853 964 854 965 /* Should we return the URI object as name address? */ 855 if (opt ion& PJSIP_PARSE_URI_AS_NAMEADDR) {966 if (opt & PJSIP_PARSE_URI_AS_NAMEADDR) { 856 967 if (is_name_addr == 0) { 857 968 pjsip_name_addr *name_addr; … … 871 982 pj_bool_t parse_params) 872 983 { 873 if (*scanner->cur rent=='"' || *scanner->current=='<') {984 if (*scanner->curptr=='"' || *scanner->curptr=='<') { 874 985 return (pjsip_uri*)int_parse_name_addr( scanner, pool ); 875 986 } else { … … 878 989 879 990 /* Get scheme. */ 880 colon = pj_scan_peek(scanner, pjsip_TOKEN_SPEC, &scheme);991 colon = pj_scan_peek(scanner, &pjsip_TOKEN_SPEC, &scheme); 881 992 if (colon != ':') { 882 993 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 883 994 } 884 995 885 if ((parser_stricmp(scheme, pjsip_SIP_STR)==0 || parser_stricmp(scheme, pjsip_SIPS_STR)==0)) 996 if ((parser_stricmp(scheme, pjsip_SIP_STR)==0 || 997 parser_stricmp(scheme, pjsip_SIPS_STR)==0)) 886 998 { 887 return (pjsip_uri*)int_parse_sip_url( scanner, pool, parse_params 999 return (pjsip_uri*)int_parse_sip_url( scanner, pool, parse_params); 888 1000 889 1001 } else if (parser_stricmp(scheme, pjsip_TEL_STR)==0) { … … 909 1021 scanner->skip_ws = 0; 910 1022 911 pj_scan_get(scanner, pjsip_TOKEN_SPEC, &scheme);1023 pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &scheme); 912 1024 colon = pj_scan_get_char(scanner); 913 1025 if (colon != ':') { … … 938 1050 939 1051 /* Get URL parameters. */ 940 while ( parse_params && *scanner->cur rent== ';' ) {1052 while ( parse_params && *scanner->curptr == ';' ) { 941 1053 pj_str_t pname, pvalue; 942 1054 … … 949 1061 url->method_param = pvalue; 950 1062 951 } else if (!parser_stricmp(pname, 1063 } else if (!parser_stricmp(pname,pjsip_TRANSPORT_STR) && pvalue.slen) { 952 1064 url->transport_param = pvalue; 953 1065 … … 967 1079 968 1080 /* Get header params. */ 969 if (parse_params && *scanner->current == '?') { 970 pj_scan_get_until(scanner, pjsip_NEWLINE_OR_EOF_SPEC, &url->header_param); 1081 if (parse_params && *scanner->curptr == '?') { 1082 pj_scan_get_until(scanner, &pjsip_NEWLINE_OR_EOF_SPEC, 1083 &url->header_param); 971 1084 } 972 1085 … … 985 1098 name_addr = pjsip_name_addr_create(pool); 986 1099 987 if (*scanner->cur rent== '"') {1100 if (*scanner->curptr == '"') { 988 1101 pj_scan_get_quote( scanner, '"', '"', &name_addr->display); 989 1102 990 } else if (*scanner->cur rent!= '<') {1103 } else if (*scanner->curptr != '<') { 991 1104 int next; 992 1105 pj_str_t dummy; … … 997 1110 * will be parser later. 998 1111 */ 999 next = pj_scan_peek_until(scanner, pjsip_DISPLAY_SCAN_SPEC, &dummy);1112 next = pj_scan_peek_until(scanner, &pjsip_DISPLAY_SCAN_SPEC, &dummy); 1000 1113 if (next == '<') { 1001 1114 /* Ok, this is what we're looking for, a display name. */ … … 1009 1122 1010 1123 /* Get the SIP-URL */ 1011 has_bracket = (*scanner->cur rent== '<');1124 has_bracket = (*scanner->curptr == '<'); 1012 1125 if (has_bracket) 1013 1126 pj_scan_get_char(scanner); … … 1026 1139 pj_str_t token; 1027 1140 1028 pj_scan_get( scanner, pjsip_TOKEN_SPEC, &token);1141 pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &token); 1029 1142 pjsip_method_init_np( &req_line->method, &token); 1030 1143 … … 1046 1159 pj_scan_advance_n( scanner, 7, 1); 1047 1160 1048 pj_scan_get( scanner, pjsip_DIGIT_SPEC, &token);1161 pj_scan_get( scanner, &pjsip_DIGIT_SPEC, &token); 1049 1162 status_line->code = pj_strtoul(&token); 1050 pj_scan_get_until( scanner, pjsip_NEWLINE_OR_EOF_SPEC, &status_line->reason); 1163 pj_scan_get_until( scanner, &pjsip_NEWLINE_OR_EOF_SPEC, 1164 &status_line->reason); 1051 1165 pj_scan_get_newline( scanner ); 1052 1166 } … … 1057 1171 if (pj_scan_is_eof(scanner)) { 1058 1172 ; /* Do nothing. */ 1059 } else if (*scanner->cur rent== '&') {1173 } else if (*scanner->curptr == '&') { 1060 1174 pj_scan_get_char(scanner); 1061 1175 } else { … … 1074 1188 pj_scanner *scanner) 1075 1189 { 1076 pj_scan_get_until( scanner, pjsip_ARRAY_ELEMENTS, &hdr->values[0]);1190 pj_scan_get_until( scanner, &pjsip_ARRAY_ELEMENTS, &hdr->values[0]); 1077 1191 hdr->count++; 1078 1192 1079 while (*scanner->cur rent== ',') {1193 while (*scanner->curptr == ',') { 1080 1194 pj_scan_get_char(scanner); 1081 pj_scan_get_until( scanner, pjsip_ARRAY_ELEMENTS, &hdr->values[hdr->count]); 1195 pj_scan_get_until( scanner, &pjsip_ARRAY_ELEMENTS, 1196 &hdr->values[hdr->count]); 1082 1197 hdr->count++; 1083 1198 } … … 1089 1204 pj_scanner *scanner ) 1090 1205 { 1091 pj_scan_get_until( scanner, pjsip_NEWLINE_OR_EOF_SPEC, &hdr->hvalue);1206 pj_scan_get_until( scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &hdr->hvalue); 1092 1207 parse_hdr_end(scanner); 1093 1208 } … … 1098 1213 { 1099 1214 pj_str_t tmp; 1100 pj_scan_get_until( scanner, pjsip_NEWLINE_OR_EOF_SPEC, &tmp);1215 pj_scan_get_until( scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &tmp); 1101 1216 hdr->ivalue = pj_strtoul(&tmp); 1102 1217 parse_hdr_end(scanner); … … 1105 1220 1106 1221 /* Parse Accept header. */ 1107 static pjsip_accept_hdr* parse_hdr_accept( pj_scanner *scanner, 1108 pj_pool_t *pool) 1109 { 1110 pjsip_accept_hdr *accept = pjsip_accept_hdr_create(pool); 1111 parse_generic_array_hdr(accept, scanner); 1112 return accept; 1222 static pjsip_hdr* parse_hdr_accept(pjsip_parse_ctx *ctx) 1223 { 1224 pjsip_accept_hdr *accept = pjsip_accept_hdr_create(ctx->pool); 1225 parse_generic_array_hdr(accept, ctx->scanner); 1226 return (pjsip_hdr*)accept; 1113 1227 } 1114 1228 1115 1229 /* Parse Allow header. */ 1116 static pjsip_allow_hdr* parse_hdr_allow( pj_scanner *scanner, 1117 pj_pool_t *pool) 1118 { 1119 pjsip_allow_hdr *allow = pjsip_allow_hdr_create(pool); 1120 parse_generic_array_hdr(allow, scanner); 1121 return allow; 1230 static pjsip_hdr* parse_hdr_allow(pjsip_parse_ctx *ctx) 1231 { 1232 pjsip_allow_hdr *allow = pjsip_allow_hdr_create(ctx->pool); 1233 parse_generic_array_hdr(allow, ctx->scanner); 1234 return (pjsip_hdr*)allow; 1122 1235 } 1123 1236 1124 1237 /* Parse Call-ID header. */ 1125 static pjsip_cid_hdr* parse_hdr_call_id( pj_scanner *scanner, 1126 pj_pool_t *pool) 1127 { 1128 pjsip_cid_hdr *hdr = pjsip_cid_hdr_create(pool); 1129 pj_scan_get_until( scanner, pjsip_NEWLINE_OR_EOF_SPEC, &hdr->id); 1130 parse_hdr_end(scanner); 1131 return hdr; 1238 static pjsip_hdr* parse_hdr_call_id(pjsip_parse_ctx *ctx) 1239 { 1240 pjsip_cid_hdr *hdr = pjsip_cid_hdr_create(ctx->pool); 1241 pj_scan_get_until( ctx->scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &hdr->id); 1242 parse_hdr_end(ctx->scanner); 1243 1244 if (ctx->rdata) 1245 ctx->rdata->call_id = hdr->id; 1246 1247 return (pjsip_hdr*)hdr; 1132 1248 } 1133 1249 … … 1137 1253 pj_pool_t *pool) 1138 1254 { 1139 while ( *scanner->cur rent== ';' ) {1255 while ( *scanner->curptr == ';' ) { 1140 1256 pj_str_t pname, pvalue; 1141 1257 … … 1160 1276 1161 1277 /* Parse Contact header. */ 1162 PJ_DEF(pjsip_contact_hdr*) parse_hdr_contact( pj_scanner *scanner, 1163 pj_pool_t *pool) 1278 static pjsip_hdr* parse_hdr_contact( pjsip_parse_ctx *ctx ) 1164 1279 { 1165 1280 pjsip_contact_hdr *first = NULL; 1281 pj_scanner *scanner = ctx->scanner; 1166 1282 1167 1283 do { 1168 pjsip_contact_hdr *hdr = pjsip_contact_hdr_create( pool);1284 pjsip_contact_hdr *hdr = pjsip_contact_hdr_create(ctx->pool); 1169 1285 if (first == NULL) 1170 1286 first = hdr; … … 1172 1288 pj_list_insert_before(first, hdr); 1173 1289 1174 if (*scanner->cur rent== '*') {1290 if (*scanner->curptr == '*') { 1175 1291 pj_scan_get_char(scanner); 1176 1292 hdr->star = 1; … … 1178 1294 } else { 1179 1295 hdr->star = 0; 1180 hdr->uri = int_parse_uri_or_name_addr(scanner, pool, PJSIP_PARSE_URI_AS_NAMEADDR); 1181 1182 int_parse_contact_param(hdr, scanner, pool); 1183 } 1184 1185 if (*scanner->current != ',') 1296 hdr->uri = int_parse_uri_or_name_addr(scanner, ctx->pool, 1297 PJSIP_PARSE_URI_AS_NAMEADDR); 1298 1299 int_parse_contact_param(hdr, scanner, ctx->pool);