00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef NTA_INTERNAL_H
00026
00027 #define NTA_INTERNAL_H
00028
00038
00039 #define SRES_CONTEXT_T nta_outgoing_t
00040
00041
00042 #define TP_AGENT_T nta_agent_t
00043 #define TP_MAGIC_T sip_via_t
00044 #define TP_CLIENT_T nta_outgoing_t
00045
00046 #include <sofia-sip/nta.h>
00047 #include <sofia-sip/nta_tport.h>
00048 #include <sofia-sip/tport.h>
00049
00050 #if HAVE_SOFIA_SRESOLV
00051 #include <sofia-sip/sresolv.h>
00052 #endif
00053
00054 #include <sofia-sip/htable.h>
00055
00056 #if HAVE_SMIME
00057 #include "smimec.h"
00058 #endif
00059
00060 SOFIA_BEGIN_DECLS
00061
00063 #define NTA_INTERNAL_MSG (1<<15)
00064
00066 enum nta_res_order_e
00067 {
00068 nta_res_ip6_ip4,
00069 nta_res_ip4_ip6,
00070 nta_res_ip6_only,
00071 nta_res_ip4_only
00072 };
00073
00074 HTABLE_DECLARE_WITH(leg_htable, lht, nta_leg_t, size_t, hash_value_t);
00075 HTABLE_DECLARE_WITH(outgoing_htable, oht, nta_outgoing_t, size_t, hash_value_t);
00076 HTABLE_DECLARE_WITH(incoming_htable, iht, nta_incoming_t, size_t, hash_value_t);
00077
00078 typedef struct outgoing_queue_t {
00079 nta_outgoing_t **q_tail;
00080 nta_outgoing_t *q_head;
00081 size_t q_length;
00082 unsigned q_timeout;
00083 } outgoing_queue_t;
00084
00085 typedef struct incoming_queue_t {
00086 nta_incoming_t **q_tail;
00087 nta_incoming_t *q_head;
00088 size_t q_length;
00089 unsigned q_timeout;
00090 } incoming_queue_t;
00091
00092 typedef struct nta_compressor nta_compressor_t;
00093
00094 struct nta_agent_s
00095 {
00096 su_home_t sa_home[1];
00097 su_root_t *sa_root;
00098 su_timer_t *sa_timer;
00099 nta_agent_magic_t *sa_magic;
00100 nta_message_f *sa_callback;
00101
00102 nta_update_magic_t *sa_update_magic;
00103 nta_update_tport_f *sa_update_tport;
00104
00105 su_time_t sa_now;
00106 uint32_t sa_next;
00107 uint32_t sa_millisec;
00109 uint32_t sa_nw_updates;
00110
00111 uint32_t sa_flags;
00112 msg_mclass_t const *sa_mclass;
00113
00114 sip_contact_t *sa_contact;
00115 sip_via_t *sa_vias;
00116 sip_via_t *sa_public_vias;
00117 sip_contact_t *sa_aliases;
00119 uint64_t sa_branch;
00120 uint64_t sa_tags;
00122 char const *sa_2543_tag;
00124 #if HAVE_SOFIA_SRESOLV
00125 sres_resolver_t *sa_resolver;
00126 #endif
00127
00128 tport_t *sa_tports;
00129
00130
00131 url_t *sa_default_proxy;
00132
00133 #if HAVE_SMIME
00134 sm_object_t *sa_smime;
00135 #else
00136 void *sa_smime;
00137 #endif
00138
00139
00141 unsigned sa_bad_req_mask;
00143 unsigned sa_bad_resp_mask;
00144
00146 size_t sa_maxsize;
00147
00149 size_t sa_max_proceeding;
00150
00152 unsigned sa_udp_mtu;
00153
00155 unsigned sa_t1;
00157 unsigned sa_t2;
00159 unsigned sa_t4;
00160
00162 unsigned sa_t1x64;
00163
00165 unsigned sa_progress;
00166
00168 unsigned sa_timer_c;
00169
00171 unsigned sa_graylist;
00173 unsigned sa_blacklist;
00174
00176 unsigned sa_drop_prob : 10;
00178 unsigned sa_is_a_uas : 1;
00180 unsigned sa_is_stateless : 1;
00182 unsigned sa_user_via:1;
00184 unsigned sa_extra_100:1;
00186 unsigned sa_pass_100:1;
00189 unsigned sa_timeout_408:1;
00191 unsigned sa_pass_408:1;
00193 unsigned sa_merge_482 : 1;
00195 unsigned sa_cancel_2543 : 1;
00197 unsigned sa_cancel_487 : 1;
00199 unsigned sa_tag_3261 : 1;
00201 unsigned sa_invite_100rel : 1;
00203 unsigned sa_timestamp : 1;
00204
00206 unsigned sa_tport_ip4 : 1;
00208 unsigned sa_tport_ip6 : 1;
00210 unsigned sa_tport_udp : 1;
00212 unsigned sa_tport_tcp : 1;
00214 unsigned sa_tport_sctp : 1;
00216 unsigned sa_tport_tls : 1;
00217
00219 unsigned sa_use_naptr : 1;
00221 unsigned sa_use_srv : 1;
00222
00224 unsigned sa_tport_threadpool : 1;
00225
00227 unsigned sa_rport:1;
00229 unsigned sa_server_rport:2;
00231 unsigned sa_tcp_rport:1;
00232
00234 unsigned sa_auto_comp:1;
00235
00237 unsigned sa_in_timer:1;
00238
00240 unsigned sa_use_timer_c:1;
00241
00242 unsigned :0;
00243
00245 unsigned sa_preload;
00246
00248 char const *sa_algorithm;
00250 char const *sa_sigcomp_options;
00251 char const* const *sa_sigcomp_option_list;
00252 char const *sa_sigcomp_option_free;
00253
00254 nta_compressor_t *sa_compressor;
00255
00257 enum nta_res_order_e sa_res_order;
00258
00261 sip_max_forwards_t sa_max_forwards[1];
00262
00263
00264 struct {
00265 usize_t as_recv_msg;
00266 usize_t as_recv_request;
00267 usize_t as_recv_response;
00268 usize_t as_bad_message;
00269 usize_t as_bad_request;
00270 usize_t as_bad_response;
00271 usize_t as_drop_request;
00272 usize_t as_drop_response;
00273 usize_t as_client_tr;
00274 usize_t as_server_tr;
00275 usize_t as_dialog_tr;
00276 usize_t as_acked_tr;
00277 usize_t as_canceled_tr;
00278 usize_t as_trless_request;
00279 usize_t as_trless_to_tr;
00280 usize_t as_trless_response;
00281 usize_t as_trless_200;
00282 usize_t as_merged_request;
00283 usize_t as_sent_msg;
00284 usize_t as_sent_request;
00285 usize_t as_sent_response;
00286 usize_t as_retry_request;
00287 usize_t as_retry_response;
00288 usize_t as_recv_retry;
00289 usize_t as_tout_request;
00290 usize_t as_tout_response;
00291 } sa_stats[1];
00292
00294 leg_htable_t sa_dialogs[1];
00296 nta_leg_t *sa_default_leg;
00298 leg_htable_t sa_defaults[1];
00300 outgoing_htable_t sa_outgoing[1];
00301 nta_outgoing_t *sa_default_outgoing;
00303 incoming_htable_t sa_incoming[1];
00304 nta_incoming_t *sa_default_incoming;
00305
00306
00307 struct {
00309 nta_outgoing_t *re_list;
00310 nta_outgoing_t **re_t1;
00311 size_t re_length;
00313 outgoing_queue_t delayed[1];
00314 outgoing_queue_t resolving[1];
00315
00316 outgoing_queue_t trying[1];
00317 outgoing_queue_t completed[1];
00318 outgoing_queue_t terminated[1];
00319
00320
00321 outgoing_queue_t inv_calling[1];
00322 outgoing_queue_t inv_proceeding[1];
00323 outgoing_queue_t inv_completed[1];
00324
00325
00326 outgoing_queue_t *free;
00327 } sa_out;
00328
00329
00330 struct {
00332 nta_incoming_t *re_list;
00333 nta_incoming_t **re_t1;
00334 size_t re_length;
00335
00336 incoming_queue_t proceeding[1];
00337 incoming_queue_t preliminary[1];
00338 incoming_queue_t completed[1];
00339 incoming_queue_t inv_completed[1];
00340 incoming_queue_t inv_confirmed[1];
00341 incoming_queue_t terminated[1];
00342 incoming_queue_t final_failed[1];
00343 } sa_in;
00344
00345
00346 su_clone_r sa_terminator;
00347 };
00348
00349 struct nta_leg_s
00350 {
00351 su_home_t leg_home[1];
00352 hash_value_t leg_hash;
00353 unsigned leg_dialog : 1;
00354 unsigned leg_stateless : 1;
00355 #ifdef NTA_STRICT_ROUTING
00356 unsigned leg_contact_set : 1;
00357 #else
00358 unsigned leg_loose_route : 1;
00359 #endif
00360 unsigned leg_local_is_to : 1;
00361 unsigned leg_tagged : 1;
00366 unsigned:0;
00367 nta_request_f *leg_callback;
00368 nta_leg_magic_t *leg_magic;
00369 nta_agent_t *leg_agent;
00374 url_t const *leg_url;
00375 char const *leg_method;
00377 uint32_t leg_seq;
00378 uint32_t leg_rseq;
00379 sip_call_id_t *leg_id;
00380 sip_from_t *leg_remote;
00381 sip_to_t *leg_local;
00383 sip_route_t *leg_route;
00384 sip_contact_t *leg_target;
00385 };
00386
00387 #define leg_has_id(leg) ((leg)->leg_id != NULL)
00388
00389 struct nta_incoming_s
00390 {
00391 su_home_t *irq_home;
00392 hash_value_t irq_hash;
00393 nta_agent_t *irq_agent;
00394 nta_ack_cancel_f *irq_callback;
00395 nta_incoming_magic_t *irq_magic;
00396
00397
00398 nta_incoming_t **irq_prev;
00399 nta_incoming_t *irq_next;
00400 incoming_queue_t *irq_queue;
00401
00402
00403 nta_incoming_t **irq_rprev;
00404 nta_incoming_t *irq_rnext;
00405
00406 sip_method_t irq_method;
00407 sip_request_t *irq_rq;
00408 sip_from_t *irq_from;
00409 sip_to_t *irq_to;
00410 char const *irq_tag;
00411 sip_cseq_t *irq_cseq;
00412 sip_call_id_t *irq_call_id;
00413 sip_via_t *irq_via;
00414 sip_record_route_t *irq_record_route;
00415 char const *irq_branch;
00416
00417 uint32_t irq_rseq;
00418
00419 sip_timestamp_t *irq_timestamp;
00420 su_time_t irq_received;
00421
00422 uint32_t irq_timeout;
00423 uint32_t irq_retry;
00424 unsigned short irq_interval;
00426 short irq_status;
00427
00428 unsigned irq_retries : 8;
00429 unsigned irq_default : 1;
00430 unsigned irq_canceled : 1;
00431 unsigned irq_completed : 1;
00432 unsigned irq_confirmed : 1;
00433 unsigned irq_terminated :1;
00434 unsigned irq_final_failed:1;
00435 unsigned irq_destroyed :1;
00436 unsigned irq_in_callback:1;
00437 unsigned irq_reliable_tp:1;
00438 unsigned irq_sigcomp_zap:1;
00439 unsigned irq_must_100rel:1;
00440 unsigned irq_tag_set:1;
00441 unsigned :0;
00442
00443 tp_name_t irq_tpn[1];
00444 tport_t *irq_tport;
00445 struct sigcomp_compartment *irq_cc;
00446 msg_t *irq_request;
00447 msg_t *irq_request2;
00448 msg_t *irq_response;
00449
00450 nta_reliable_t *irq_reliable;
00451 };
00452
00453 struct nta_reliable_s
00454 {
00455 nta_reliable_t *rel_next;
00456 nta_incoming_t *rel_irq;
00457 nta_prack_f *rel_callback;
00458 nta_reliable_magic_t *rel_magic;
00459 uint32_t rel_rseq;
00460 unsigned short rel_status;
00461 unsigned rel_pracked : 1;
00462 unsigned rel_precious : 1;
00463 msg_t *rel_response;
00464 msg_t *rel_unsent;
00465 };
00466
00467 typedef struct sipdns_resolver sipdns_resolver_t;
00468
00469 struct nta_outgoing_s
00470 {
00471 hash_value_t orq_hash;
00472 nta_agent_t *orq_agent;
00473 nta_response_f *orq_callback;
00474 nta_outgoing_magic_t *orq_magic;
00475
00476
00477 nta_outgoing_t **orq_prev;
00478 nta_outgoing_t *orq_next;
00479 outgoing_queue_t *orq_queue;
00480
00481
00482 nta_outgoing_t **orq_rprev;
00483 nta_outgoing_t *orq_rnext;
00484
00485 sip_method_t orq_method;
00486 char const *orq_method_name;
00487 url_t const *orq_url;
00489 sip_from_t const *orq_from;
00490 sip_to_t const *orq_to;
00491 char const *orq_tag;
00493 sip_cseq_t const *orq_cseq;
00494 sip_call_id_t const *orq_call_id;
00495
00496 msg_t *orq_request;
00497 msg_t *orq_response;
00498
00499 su_time_t orq_sent;
00500 unsigned orq_delay;
00502 uint32_t orq_retry;
00503 uint32_t orq_timeout;
00505 unsigned short orq_interval;
00507 unsigned short orq_status;
00508 unsigned char orq_retries;
00509 unsigned orq_default : 1;
00510 unsigned orq_inserted : 1;
00511 unsigned orq_resolved : 1;
00512 unsigned orq_prepared : 1;
00513 unsigned orq_canceled : 1;
00514 unsigned orq_terminated : 1;
00515 unsigned orq_destroyed : 1;
00516 unsigned orq_completed : 1;
00517 unsigned orq_delayed : 1;
00518 unsigned orq_stripped_uri : 1;
00519 unsigned orq_user_tport : 1;
00520 unsigned orq_try_tcp_instead : 1;
00521 unsigned orq_try_udp_instead : 1;
00522 unsigned orq_reliable : 1;
00523 unsigned orq_ack_error : 1;
00524
00525 unsigned orq_user_via : 1;
00526 unsigned orq_stateless : 1;
00527 unsigned orq_pass_100 : 1;
00528 unsigned orq_sigcomp_new:1;
00529 unsigned orq_sigcomp_zap:1;
00530 unsigned orq_must_100rel : 1;
00531 unsigned orq_timestamp : 1;
00532 unsigned orq_100rel:1;
00533 unsigned : 0;
00534
00535 #if HAVE_SOFIA_SRESOLV
00536 sipdns_resolver_t *orq_resolver;
00537 #endif
00538 enum nta_res_order_e orq_res_order;
00540 url_t *orq_route;
00541 tp_name_t orq_tpn[1];
00542 char const *orq_scheme;
00544 tport_t *orq_tport;
00545 struct sigcomp_compartment *orq_cc;
00546 tagi_t *orq_tags;
00547 int orq_pending;
00549 char const *orq_branch;
00550 char const *orq_via_branch;
00552 int *orq_status2b;
00554 nta_outgoing_t *orq_cancel;
00556 uint32_t orq_rseq;
00557 };
00558
00559
00560 typedef struct
00561 {
00562 int ncv_size;
00563 char const *ncv_name;
00564
00565 nta_compressor_t *(*ncv_init_agent)(nta_agent_t *sa,
00566 char const * const *options);
00567
00568 void (*ncv_deinit_agent)(nta_agent_t *sa, nta_compressor_t *);
00569
00570 struct sigcomp_compartment *(*ncv_compartment)(nta_agent_t *sa,
00571 tport_t *tport,
00572 nta_compressor_t *msc,
00573 tp_name_t const *tpn,
00574 char const * const *options,
00575 int new_if_needed);
00576
00577 int (*ncv_accept_compressed)(nta_agent_t *sa,
00578 nta_compressor_t *msc,
00579 tport_compressor_t *sc,
00580 msg_t *msg,
00581 struct sigcomp_compartment *cc);
00582
00583 int (*ncv_close_compressor)(nta_agent_t *sa,
00584 struct sigcomp_compartment *cc);
00585 int (*ncv_zap_compressor)(nta_agent_t *sa,
00586 struct sigcomp_compartment *cc);
00587
00588 struct sigcomp_compartment *(*ncv_compartment_ref)
00589 (struct sigcomp_compartment *);
00590
00591 void (*ncv_compartment_unref)(struct sigcomp_compartment *);
00592
00593 } nta_compressor_vtable_t;
00594
00595 extern nta_compressor_vtable_t *nta_compressor_vtable;
00596
00597 SOFIAPUBFUN nta_compressor_t *nta_agent_init_sigcomp(nta_agent_t *sa);
00598 SOFIAPUBFUN void nta_agent_deinit_sigcomp(nta_agent_t *sa);
00599
00600
00601
00602
00603 #define SU_LOG nta_log
00604
00605 #ifdef SU_DEBUG_H
00606 #error <su_debug.h> included directly.
00607 #endif
00608 #include <sofia-sip/su_debug.h>
00609 SOFIAPUBVAR su_log_t nta_log[];
00610
00611 SOFIA_END_DECLS
00612
00613 #endif