1 /* $Id$ */ 2 /* 3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 #ifndef __PJSIP_SIP_ENDPOINT_H__ 21 #define __PJSIP_SIP_ENDPOINT_H__ 22 23 /** 24 * @file sip_endpoint.h 25 * @brief SIP Endpoint. 26 */ 27 28 #include <pjsip/sip_transport.h> 29 #include <pjsip/sip_resolve.h> 30 31 /** 32 * @defgroup PJSIP_CORE_CORE At the Very Core 33 * @ingroup PJSIP_CORE 34 * @brief The very core of PJSIP. 35 */ 36 37 PJ_BEGIN_DECL 38 39 /** 40 * @defgroup PJSIP_ENDPT Endpoint 41 * @ingroup PJSIP_CORE_CORE 42 * @brief The master, owner of all objects 43 * 44 * SIP Endpoint instance (pjsip_endpoint) can be viewed as the master/owner of 45 * all SIP objects in an application. It performs the following roles: 46 * - it manages the allocation/deallocation of memory pools for all objects. 47 * - it manages listeners and transports, and how they are used by 48 * transactions. 49 * - it receives incoming messages from transport layer and automatically 50 * dispatches them to the correct transaction (or create a new one). 51 * - it has a single instance of timer management (timer heap). 52 * - it manages modules, which is the primary means of extending the library. 53 * - it provides single polling function for all objects and distributes 54 * events. 55 * - it automatically handles incoming requests which can not be handled by 56 * existing modules (such as when incoming request has unsupported method). 57 * - and so on.. 58 * 59 * Application should only instantiate one SIP endpoint instance for every 60 * process. 61 * 62 * @{ 63 */ 64 65 66 /** 67 * Type of callback to register to pjsip_endpt_atexit(). 68 */ 69 typedef void (*pjsip_endpt_exit_callback)(pjsip_endpoint *endpt); 70 71 72 /** 73 * Create an instance of SIP endpoint from the specified pool factory. 74 * The pool factory reference then will be kept by the endpoint, so that 75 * future memory allocations by SIP components will be taken from the same 76 * pool factory. 77 * 78 * @param pf Pool factory that will be used for the lifetime of 79 * endpoint. 80 * @param name Optional name to be specified for the endpoint. 81 * If this parameter is NULL, then the name will use 82 * local host name. 83 * @param endpt Pointer to receive endpoint instance. 84 * 85 * @return PJ_SUCCESS on success. 86 */ 87 PJ_DECL(pj_status_t) pjsip_endpt_create(pj_pool_factory *pf, 88 const char *name, 89 pjsip_endpoint **endpt); 90 91 /** 92 * Destroy endpoint instance. Application must make sure that all pending 93 * transactions have been terminated properly, because this function does not 94 * check for the presence of pending transactions. 95 * 96 * @param endpt The SIP endpoint to be destroyed. 97 */ 98 PJ_DECL(void) pjsip_endpt_destroy(pjsip_endpoint *endpt); 99 100 /** 101 * Get endpoint name. 102 * 103 * @param endpt The SIP endpoint instance. 104 * 105 * @return Endpoint name, as was registered during endpoint 106 * creation. The string is NULL terminated. 107 */ 108 PJ_DECL(const pj_str_t*) pjsip_endpt_name(const pjsip_endpoint *endpt); 109 110 /** 111 * Poll for events. Application must call this function periodically to ensure 112 * that all events from both transports and timer heap are handled in timely 113 * manner. This function, like all other endpoint functions, is thread safe, 114 * and application may have more than one thread concurrently calling this function. 115 * 116 * @param endpt The endpoint. 117 * @param max_timeout Maximum time to wait for events, or NULL to wait forever 118 * until event is received. 119 * 120 * @return PJ_SUCCESS on success. 121 */ 122 PJ_DECL(pj_status_t) pjsip_endpt_handle_events( pjsip_endpoint *endpt, 123 const pj_time_val *max_timeout); 124 125 126 /** 127 * Handle events with additional info about number of events that 128 * have been handled. 129 * 130 * @param endpt The endpoint. 131 * @param max_timeout Maximum time to wait for events, or NULL to wait forever 132 * until event is received. 133 * @param count Optional argument to receive the number of events that 134 * have been handled by the function. 135 * 136 * @return PJ_SUCCESS on success. 137 */ 138 PJ_DECL(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt, 139 const pj_time_val *max_timeout, 140 unsigned *count); 141 142 /** 143 * Schedule timer to endpoint's timer heap. Application must poll the endpoint 144 * periodically (by calling #pjsip_endpt_handle_events) to ensure that the 145 * timer events are handled in timely manner. When the timeout for the timer 146 * has elapsed, the callback specified in the entry argument will be called. 147 * This function, like all other endpoint functions, is thread safe. 148 * 149 * @param endpt The endpoint. 150 * @param entry The timer entry. 151 * @param delay The relative delay of the timer. 152 * @return PJ_OK (zero) if successfull. 153 */ 154 #if PJ_TIMER_DEBUG 155 #define pjsip_endpt_schedule_timer(ept,ent,d) \ 156 pjsip_endpt_schedule_timer_dbg(ept, ent, d, \ 157 __FILE__, __LINE__) 158 159 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_dbg(pjsip_endpoint *endpt, 160 pj_timer_entry *entry, 161 const pj_time_val *delay, 162 const char *src_file, 163 int src_line); 164 #else 165 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt, 166 pj_timer_entry *entry, 167 const pj_time_val *delay ); 168 #endif 169 170 /** 171 * Schedule timer to endpoint's timer heap with group lock. Application must 172 * poll the endpoint periodically (by calling #pjsip_endpt_handle_events) to 173 * ensure that the timer events are handled in timely manner. When the 174 * timeout for the timer has elapsed, the callback specified in the entry 175 * argument will be called. This function, like all other endpoint functions, 176 * is thread safe. 177 * 178 * @param endpt The endpoint. 179 * @param entry The timer entry. 180 * @param delay The relative delay of the timer. 181 * @param id_val The value to be set to the "id" field of the timer entry 182 * once the timer is scheduled. 183 * @param grp_lock The group lock. 184 * @return PJ_OK (zero) if successfull. 185 */ 186 #if PJ_TIMER_DEBUG 187 #define pjsip_endpt_schedule_timer_w_grp_lock(ept,ent,d,id,gl) \ 188 pjsip_endpt_schedule_timer_w_grp_lock_dbg(ept,ent,d,id,gl,\ 189 __FILE__, __LINE__) 190 191 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock_dbg( 192 pjsip_endpoint *endpt, 193 pj_timer_entry *entry, 194 const pj_time_val *delay, 195 int id_val, 196 pj_grp_lock_t *grp_lock, 197 const char *src_file, 198 int src_line); 199 #else 200 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock( 201 pjsip_endpoint *endpt, 202 pj_timer_entry *entry, 203 const pj_time_val *delay, 204 int id_val, 205 pj_grp_lock_t *grp_lock ); 206 #endif 207 208 /** 209 * Cancel the previously registered timer. 210 * This function, like all other endpoint functions, is thread safe. 211 * 212 * @param endpt The endpoint. 213 * @param entry The timer entry previously registered. 214 */ 215 PJ_DECL(void) pjsip_endpt_cancel_timer( pjsip_endpoint *endpt, 216 pj_timer_entry *entry ); 217 218 /** 219 * Get the timer heap instance of the SIP endpoint. 220 * 221 * @param endpt The endpoint. 222 * 223 * @return The timer heap instance. 224 */ 225 PJ_DECL(pj_timer_heap_t*) pjsip_endpt_get_timer_heap(pjsip_endpoint *endpt); 226 227 228 /** 229 * Register new module to the endpoint. 230 * The endpoint will then call the load and start function in the module to 231 * properly initialize the module, and assign a unique module ID for the 232 * module. 233 * 234 * @param endpt The endpoint. 235 * @param module The module to be registered. 236 * 237 * @return PJ_SUCCESS on success. 238 */ 239 PJ_DECL(pj_status_t) pjsip_endpt_register_module( pjsip_endpoint *endpt, 240 pjsip_module *module ); 241 242 /** 243 * Unregister a module from the endpoint. 244 * The endpoint will then call the stop and unload function in the module to 245 * properly shutdown the module. 246 * 247 * @param endpt The endpoint. 248 * @param module The module to be registered. 249 * 250 * @return PJ_SUCCESS on success. 251 */ 252 PJ_DECL(pj_status_t) pjsip_endpt_unregister_module( pjsip_endpoint *endpt, 253 pjsip_module *module ); 254 255 /** 256 * This describes additional parameters to pjsip_endpt_process_rx_data() 257 * function. Application MUST call pjsip_process_rdata_param_default() to 258 * initialize this structure. 259 */ 260 typedef struct pjsip_process_rdata_param 261 { 262 /** 263 * Specify the minimum priority number of the modules that are allowed 264 * to process the message. Default is zero to allow all modules to 265 * process the message. 266 */ 267 unsigned start_prio; 268 269 /** 270 * Specify the pointer of the module where processing will start. 271 * The default is NULL, meaning processing will start from the start 272 * of the module list. 273 */ 274 void *start_mod; 275 276 /** 277 * Set to N, then processing will start at Nth module after start 278 * module (where start module can be an explicit module as specified 279 * by \a start_mod or the start of module list when \a start_mod is 280 * NULL). For example, if set to 1, then processing will start from 281 * the next module after start module. Default is zero. 282 */ 283 unsigned idx_after_start; 284 285 /** 286 * Print nothing to log. Default is PJ_FALSE. 287 */ 288 pj_bool_t silent; 289 290 } pjsip_process_rdata_param; 291 292 /** 293 * Initialize with default. 294 * 295 * @param p The param. 296 */ 297 PJ_DECL(void) pjsip_process_rdata_param_default(pjsip_process_rdata_param *p); 298 299 /** 300 * Manually distribute the specified pjsip_rx_data to registered modules. 301 * Normally application does not need to call this function because received 302 * messages will be given to endpoint automatically by transports. 303 * 304 * Application can use this function when it has postponed the processing of 305 * an incoming message, for example to perform long operations such as 306 * database operation or to consult other servers to decide what to do with 307 * the message. In this case, application clones the original rdata, return 308 * from the callback, and perform the long operation. Upon completing the 309 * long operation, it resumes pjsip's module processing by calling this 310 * function, and then free the cloned rdata. 311 * 312 * @param endpt The endpoint instance. 313 * @param rdata The rdata to be distributed. 314 * @param p Optional pointer to param to specify from which module 315 * the processing should start. 316 * @param p_handled Optional pointer to receive last return value of 317 * module's \a on_rx_request() or \a on_rx_response() 318 * callback. 319 * 320 * @return PJ_SUCCESS on success. 321 */ 322 PJ_DECL(pj_status_t) pjsip_endpt_process_rx_data(pjsip_endpoint *endpt, 323 pjsip_rx_data *rdata, 324 pjsip_process_rdata_param *p, 325 pj_bool_t *p_handled); 326 327 /** 328 * Create pool from the endpoint. All SIP components should allocate their 329 * memory pool by calling this function, to make sure that the pools are 330 * allocated from the same pool factory. This function, like all other endpoint 331 * functions, is thread safe. 332 * 333 * @param endpt The SIP endpoint. 334 * @param pool_name Name to be assigned to the pool. 335 * @param initial The initial size of the pool. 336 * @param increment The resize size. 337 * @return Memory pool, or NULL on failure. 338 * 339 * @see pj_pool_create 340 */ 341 PJ_DECL(pj_pool_t*) pjsip_endpt_create_pool( pjsip_endpoint *endpt, 342 const char *pool_name, 343 pj_size_t initial, 344 pj_size_t increment ); 345 346 /** 347 * Return back pool to endpoint to be released back to the pool factory. 348 * This function, like all other endpoint functions, is thread safe. 349 * 350 * @param endpt The endpoint. 351 * @param pool The pool to be destroyed. 352 */ 353 PJ_DECL(void) pjsip_endpt_release_pool( pjsip_endpoint *endpt, 354 pj_pool_t *pool ); 355 356 /** 357 * Find transaction in endpoint's transaction table by the transaction's key. 358 * This function normally is only used by modules. The key for a transaction 359 * can be created by calling #pjsip_tsx_create_key. 360 * 361 * @param endpt The endpoint instance. 362 * @param key Transaction key, as created with #pjsip_tsx_create_key. 363 * 364 * @return The transaction, or NULL if it's not found. 365 */ 366 PJ_DECL(pjsip_transaction*) pjsip_endpt_find_tsx( pjsip_endpoint *endpt, 367 const pj_str_t *key ); 368 369 /** 370 * Register the transaction to the endpoint's transaction table. 371 * This function should only be used internally by the stack. 372 * 373 * @param endpt The SIP endpoint. 374 * @param tsx The transaction. 375 */ 376 PJ_DECL(void) pjsip_endpt_register_tsx( pjsip_endpoint *endpt, 377 pjsip_transaction *tsx); 378 379 /** 380 * Forcefull destroy the transaction. This function should only be used 381 * internally by the stack. 382 * 383 * @param endpt The endpoint. 384 * @param tsx The transaction to destroy. 385 */ 386 PJ_DECL(void) pjsip_endpt_destroy_tsx( pjsip_endpoint *endpt, 387 pjsip_transaction *tsx); 388 389 /** 390 * Create a new transmit data buffer. 391 * This function, like all other endpoint functions, is thread safe. 392 * 393 * @param endpt The endpoint. 394 * @param p_tdata Pointer to receive transmit data buffer. 395 * 396 * @return PJ_SUCCESS or the appropriate error code. 397 */ 398 PJ_DECL(pj_status_t) pjsip_endpt_create_tdata( pjsip_endpoint *endpt, 399 pjsip_tx_data **p_tdata); 400 401 /** 402 * Create the DNS resolver instance. Application creates the DNS 403 * resolver instance, set the nameserver to be used by the DNS 404 * resolver, then set the DNS resolver to be used by the endpoint 405 * by calling #pjsip_endpt_set_resolver(). 406 * 407 * @param endpt The SIP endpoint instance. 408 * @param p_resv Pointer to receive the DNS resolver instance. 409 * 410 * @return PJ_SUCCESS on success, or the appropriate error 411 * code. 412 */ 413 PJ_DECL(pj_status_t) pjsip_endpt_create_resolver(pjsip_endpoint *endpt, 414 pj_dns_resolver **p_resv); 415 416 /** 417 * Set DNS resolver to be used by the SIP resolver. Application can set 418 * the resolver instance to NULL to disable DNS resolution (perhaps 419 * temporarily). When DNS resolver is disabled, the endpoint will resolve 420 * hostnames with the normal pj_gethostbyname() function. 421 * 422 * @param endpt The SIP endpoint instance. 423 * @param resv The resolver instance to be used by the SIP 424 * endpoint. 425 * 426 * @return PJ_SUCCESS on success, or the appropriate error 427 * code. 428 */ 429 PJ_DECL(pj_status_t) pjsip_endpt_set_resolver(pjsip_endpoint *endpt, 430 pj_dns_resolver *resv); 431 432 /** 433 * Set the DNS external resolver implementation to use in the SIP resolver. 434 * 435 * Note that naturally when implementing its own resolver, application would not 436 * need the internal resolver, hence this function will also destroy the 437 * PJLIB-UTIL DNS resolver if any (e.g: set using #pjsip_endpt_set_resolver()). 438 * Application that needs it, still be able create its own instance. 439 * 440 * @param res The SIP resolver engine. 441 * @param ext_res The external resolver implementation callback. This argument 442 * can be NULL to reset the whole external implementation. 443 * However, it is prohibited to reset individual callback. 444 * 445 * @return PJ_SUCCESS on success, or the appropriate error code. 446 */ 447 PJ_DECL(pj_status_t) pjsip_endpt_set_ext_resolver(pjsip_endpoint *endpt, 448 pjsip_ext_resolver *ext_res); 449 450 /** 451 * Get the DNS resolver being used by the SIP resolver. 452 * 453 * @param endpt The SIP endpoint instance. 454 * 455 * @return The DNS resolver instance currently being used 456 * by the SIP endpoint. 457 */ 458 PJ_DECL(pj_dns_resolver*) pjsip_endpt_get_resolver(pjsip_endpoint *endpt); 459 460 /** 461 * Asynchronously resolve a SIP target host or domain according to rule 462 * specified in RFC 3263 (Locating SIP Servers). When the resolving operation 463 * has completed, the callback will be called. 464 * 465 * @param endpt The endpoint instance. 466 * @param pool The pool to allocate resolver job. 467 * @param target The target specification to be resolved. 468 * @param token A user defined token to be passed back to callback function. 469 * @param cb The callback function. 470 */ 471 PJ_DECL(void) pjsip_endpt_resolve( pjsip_endpoint *endpt, 472 pj_pool_t *pool, 473 pjsip_host_info *target, 474 void *token, 475 pjsip_resolver_callback *cb); 476 477 /** 478 * Get transport manager instance. 479 * 480 * @param endpt The endpoint. 481 * 482 * @return Transport manager instance. 483 */ 484 PJ_DECL(pjsip_tpmgr*) pjsip_endpt_get_tpmgr(pjsip_endpoint *endpt); 485 486 /** 487 * Get ioqueue instance. 488 * 489 * @param endpt The endpoint. 490 * 491 * @return The ioqueue. 492 */ 493 PJ_DECL(pj_ioqueue_t*) pjsip_endpt_get_ioqueue(pjsip_endpoint *endpt); 494 495 /** 496 * Find a SIP transport suitable for sending SIP message to the specified 497 * address. If transport selector ("sel") is set, then the function will 498 * check if the transport selected is suitable to send requests to the 499 * specified address. 500 * 501 * @see pjsip_tpmgr_acquire_transport 502 * 503 * @param endpt The SIP endpoint instance. 504 * @param type The type of transport to be acquired. 505 * @param remote The remote address to send message to. 506 * @param addr_len Length of the remote address. 507 * @param sel Optional pointer to transport selector instance which is 508 * used to find explicit transport, if required. 509 * @param p_tp Pointer to receive the transport instance, if one is found. 510 * 511 * @return PJ_SUCCESS on success, or the appropriate error code. 512 */ 513 PJ_DECL(pj_status_t) 514 pjsip_endpt_acquire_transport( pjsip_endpoint *endpt, 515 pjsip_transport_type_e type, 516 const pj_sockaddr_t *remote, 517 int addr_len, 518 const pjsip_tpselector *sel, 519 pjsip_transport **p_tp); 520 521 522 /** 523 * Find a SIP transport suitable for sending SIP message to the specified 524 * address by also considering the outgoing SIP message data. If transport 525 * selector ("sel") is set, then the function will check if the transport 526 * selected is suitable to send requests to the specified address. 527 * 528 * @see pjsip_tpmgr_acquire_transport 529 * 530 * @param endpt The SIP endpoint instance. 531 * @param type The type of transport to be acquired. 532 * @param remote The remote address to send message to. 533 * @param addr_len Length of the remote address. 534 * @param sel Optional pointer to transport selector instance which is 535 * used to find explicit transport, if required. 536 * @param tdata Optional pointer to SIP message data to be sent. 537 * @param p_tp Pointer to receive the transport instance, if one is found. 538 * 539 * @return PJ_SUCCESS on success, or the appropriate error code. 540 */ 541 PJ_DECL(pj_status_t) 542 pjsip_endpt_acquire_transport2(pjsip_endpoint *endpt, 543 pjsip_transport_type_e type, 544 const pj_sockaddr_t *remote, 545 int addr_len, 546 const pjsip_tpselector *sel, 547 pjsip_tx_data *tdata, 548 pjsip_transport **p_tp); 549 550 551 /***************************************************************************** 552 * 553 * Capabilities Management 554 * 555 * Modules may implement new capabilities to the stack. These capabilities 556 * are indicated by the appropriate SIP header fields, such as Accept, 557 * Accept-Encoding, Accept-Language, Allow, Supported, etc. 558 * 559 * When a module provides new capabilities to the stack, it registers these 560 * capabilities to the endpoint by supplying new tags (strings) to the 561 * appropriate header fields. Application (or other modules) can then query 562 * these header fields to get the list of supported capabilities, and may 563 * include these headers in the outgoing message. 564 ***************************************************************************** 565 */ 566 567 /** 568 * Get the value of the specified capability header field. 569 * 570 * @param endpt The endpoint. 571 * @param htype The header type to be retrieved, which value may be: 572 * - PJSIP_H_ACCEPT 573 * - PJSIP_H_ALLOW 574 * - PJSIP_H_SUPPORTED 575 * @param hname If htype specifies PJSIP_H_OTHER, then the header name 576 * must be supplied in this argument. Otherwise the value 577 * must be set to NULL. 578 * 579 * @return The appropriate header, or NULL if the header is not 580 * available. 581 */ 582 PJ_DECL(const pjsip_hdr*) pjsip_endpt_get_capability( pjsip_endpoint *endpt, 583 int htype, 584 const pj_str_t *hname); 585 586 587 /** 588 * Check if we have the specified capability. 589 * 590 * @param endpt The endpoint. 591 * @param htype The header type to be retrieved, which value may be: 592 * - PJSIP_H_ACCEPT 593 * - PJSIP_H_ALLOW 594 * - PJSIP_H_SUPPORTED 595 * @param hname If htype specifies PJSIP_H_OTHER, then the header name 596 * must be supplied in this argument. Otherwise the value 597 * must be set to NULL. 598 * @param token The capability token to check. For example, if \a htype 599 * is PJSIP_H_ALLOW, then \a token specifies the method 600 * names; if \a htype is PJSIP_H_SUPPORTED, then \a token 601 * specifies the extension names such as "100rel". 602 * 603 * @return PJ_TRUE if the specified capability is supported, 604 * otherwise PJ_FALSE.. 605 */ 606 PJ_DECL(pj_bool_t) pjsip_endpt_has_capability( pjsip_endpoint *endpt, 607 int htype, 608 const pj_str_t *hname, 609 const pj_str_t *token); 610 611 612 /** 613 * Add or register new capabilities as indicated by the tags to the 614 * appropriate header fields in the endpoint. 615 * 616 * @param endpt The endpoint. 617 * @param mod The module which registers the capability. 618 * @param htype The header type to be set, which value may be: 619 * - PJSIP_H_ACCEPT 620 * - PJSIP_H_ALLOW 621 * - PJSIP_H_SUPPORTED 622 * @param hname If htype specifies PJSIP_H_OTHER, then the header name 623 * must be supplied in this argument. Otherwise the value 624 * must be set to NULL. 625 * @param count The number of tags in the array. The value must not 626 * be greater than PJSIP_GENERIC_ARRAY_MAX_COUNT. 627 * @param tags Array of tags describing the capabilities or extensions 628 * to be added to the appropriate header. 629 * 630 * @return PJ_SUCCESS on success. 631 */ 632 PJ_DECL(pj_status_t) pjsip_endpt_add_capability( pjsip_endpoint *endpt, 633 pjsip_module *mod, 634 int htype, 635 const pj_str_t *hname, 636 unsigned count, 637 const pj_str_t tags[]); 638 639 /** 640 * Get list of additional headers to be put in outgoing request message. 641 * Currently only Max-Forwards are defined. 642 * 643 * @param e The endpoint. 644 * 645 * @return List of headers. 646 */ 647 PJ_DECL(const pjsip_hdr*) pjsip_endpt_get_request_headers(pjsip_endpoint *e); 648 649 650 /** 651 * Dump endpoint status to the log. This will print the status to the log 652 * with log level 3. 653 * 654 * @param endpt The endpoint. 655 * @param detail If non zero, then it will dump a detailed output. 656 * BEWARE that this option may crash the system because 657 * it tries to access all memory pools. 658 */ 659 PJ_DECL(void) pjsip_endpt_dump( pjsip_endpoint *endpt, pj_bool_t detail ); 660 661 662 /** 663 * Register cleanup function to be called by SIP endpoint when 664 * #pjsip_endpt_destroy() is called. Note that application should not 665 * use or access any endpoint resource (such as pool, ioqueue, timer heap) 666 * from within the callback as such resource may have been released when 667 * the callback function is invoked. 668 * 669 * @param endpt The SIP endpoint. 670 * @param func The function to be registered. 671 * 672 * @return PJ_SUCCESS on success. 673 */ 674 PJ_DECL(pj_status_t) pjsip_endpt_atexit(pjsip_endpoint *endpt, 675 pjsip_endpt_exit_callback func); 676 677 678 /** 679 * @} 680 */ 681 682 683 /** 684 * Log an error. 685 */ 686 PJ_DECL(void) pjsip_endpt_log_error( pjsip_endpoint *endpt, 687 const char *sender, 688 pj_status_t error_code, 689 const char *format, 690 ... ); 691 692 #define PJSIP_ENDPT_LOG_ERROR(expr) \ 693 pjsip_endpt_log_error expr 694 695 #define PJSIP_ENDPT_TRACE(tracing,expr) \ 696 do { \ 697 if ((tracing)) \ 698 PJ_LOG(4,expr); \ 699 } while (0) 700 701 /* 702 * Internal functions. 703 */ 704 /* 705 * Receive transaction events from transactions and put in the event queue 706 * to be processed later. 707 */ 708 void pjsip_endpt_send_tsx_event( pjsip_endpoint *endpt, pjsip_event *evt ); 709 710 PJ_END_DECL 711 712 #endif /* __PJSIP_SIP_ENDPOINT_H__ */ 713 714