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_duration_t sa_next;
00106 su_time_t sa_now;
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 unsigned sa_udp_mtu;
00150
00152 unsigned sa_t1;
00154 unsigned sa_t2;
00156 unsigned sa_t4;
00157
00159 unsigned sa_t1x64;
00160
00162 unsigned sa_progress;
00163
00165 unsigned sa_timer_c;
00166
00168 unsigned sa_blacklist;
00169
00171 unsigned sa_drop_prob : 10;
00173 unsigned sa_is_a_uas : 1;
00175 unsigned sa_is_stateless : 1;
00177 unsigned sa_user_via:1;
00179 unsigned sa_extra_100:1;
00181 unsigned sa_pass_100:1;
00184 unsigned sa_timeout_408:1;
00186 unsigned sa_pass_408:1;
00188 unsigned sa_merge_482 : 1;
00190 unsigned sa_cancel_2543 : 1;
00192 unsigned sa_cancel_487 : 1;
00194 unsigned sa_tag_3261 : 1;
00196 unsigned sa_invite_100rel : 1;
00198 unsigned sa_timestamp : 1;
00199
00201 unsigned sa_tport_ip4 : 1;
00203 unsigned sa_tport_ip6 : 1;
00205 unsigned sa_tport_udp : 1;
00207 unsigned sa_tport_tcp : 1;
00209 unsigned sa_tport_sctp : 1;
00211 unsigned sa_tport_tls : 1;
00212
00214 unsigned sa_use_naptr : 1;
00216 unsigned sa_use_srv : 1;
00217
00219 unsigned sa_tport_threadpool : 1;
00220
00222 unsigned sa_rport:1;
00224 unsigned sa_server_rport:1;
00226 unsigned sa_tcp_rport:1;
00227
00229 unsigned sa_auto_comp:1;
00230
00232 unsigned sa_in_timer:1;
00233
00235 unsigned sa_use_timer_c:1;
00236
00237 unsigned :0;
00238
00240 unsigned sa_preload;
00241
00243 char const *sa_algorithm;
00245 char const *sa_sigcomp_options;
00246 char const* const *sa_sigcomp_option_list;
00247 char const *sa_sigcomp_option_free;
00248
00249 nta_compressor_t *sa_compressor;
00250
00252 enum nta_res_order_e sa_res_order;
00253
00256 sip_max_forwards_t sa_max_forwards[1];
00257
00258
00259 struct {
00260 usize_t as_recv_msg;
00261 usize_t as_recv_request;
00262 usize_t as_recv_response;
00263 usize_t as_bad_message;
00264 usize_t as_bad_request;
00265 usize_t as_bad_response;
00266 usize_t as_drop_request;
00267 usize_t as_drop_response;
00268 usize_t as_client_tr;
00269 usize_t as_server_tr;
00270 usize_t as_dialog_tr;
00271 usize_t as_acked_tr;
00272 usize_t as_canceled_tr;
00273 usize_t as_trless_request;
00274 usize_t as_trless_to_tr;
00275 usize_t as_trless_response;
00276 usize_t as_trless_200;
00277 usize_t as_merged_request;
00278 usize_t as_sent_msg;
00279 usize_t as_sent_request;
00280 usize_t as_sent_response;
00281 usize_t as_retry_request;
00282 usize_t as_retry_response;
00283 usize_t as_recv_retry;
00284 usize_t as_tout_request;
00285 usize_t as_tout_response;
00286 } sa_stats[1];
00287
00289 leg_htable_t sa_dialogs[1];
00291 nta_leg_t *sa_default_leg;
00293 leg_htable_t sa_defaults[1];
00295 outgoing_htable_t sa_outgoing[1];
00296 nta_outgoing_t *sa_default_outgoing;
00298 incoming_htable_t sa_incoming[1];
00299 nta_incoming_t *sa_default_incoming;
00300
00301
00302 struct {
00304 nta_outgoing_t *re_list;
00305 nta_outgoing_t **re_t1;
00306 size_t re_length;
00308 outgoing_queue_t delayed[1];
00309 outgoing_queue_t resolving[1];
00310
00311 outgoing_queue_t trying[1];
00312 outgoing_queue_t completed[1];
00313 outgoing_queue_t terminated[1];
00314
00315
00316 outgoing_queue_t inv_calling[1];
00317 outgoing_queue_t inv_proceeding[1];
00318 outgoing_queue_t inv_completed[1];
00319
00320
00321 outgoing_queue_t *free;
00322 } sa_out;
00323
00324
00325 struct {
00327 nta_incoming_t *re_list;
00328 nta_incoming_t **re_t1;
00329 size_t re_length;
00330
00331 incoming_queue_t proceeding[1];
00332 incoming_queue_t preliminary[1];
00333 incoming_queue_t completed[1];
00334 incoming_queue_t inv_completed[1];
00335 incoming_queue_t inv_confirmed[1];
00336 incoming_queue_t terminated[1];
00337 incoming_queue_t final_failed[1];
00338 } sa_in;
00339
00340
00341 su_clone_r sa_terminator;
00342 };
00343
00344 struct nta_leg_s
00345 {
00346 su_home_t leg_home[1];
00347 hash_value_t leg_hash;
00348 unsigned leg_dialog : 1;
00349 unsigned leg_stateless : 1;
00350 #ifdef NTA_STRICT_ROUTING
00351 unsigned leg_contact_set : 1;
00352 #else
00353 unsigned leg_loose_route : 1;
00354 #endif
00355 unsigned leg_local_is_to : 1;
00356 unsigned leg_tagged : 1;
00361 unsigned:0;
00362 nta_request_f *leg_callback;
00363 nta_leg_magic_t *leg_magic;
00364 nta_agent_t *leg_agent;
00369 url_t const *leg_url;
00370 char const *leg_method;
00372 uint32_t leg_seq;
00373 uint32_t leg_rseq;
00374 sip_call_id_t *leg_id;
00375 sip_from_t *leg_remote;
00376 sip_to_t *leg_local;
00378 sip_route_t *leg_route;
00379 sip_contact_t *leg_target;
00380 };
00381
00382 #define leg_has_id(leg) ((leg)->leg_id != NULL)
00383
00384 struct nta_incoming_s
00385 {
00386 su_home_t *irq_home;
00387 hash_value_t irq_hash;
00388 nta_agent_t *irq_agent;
00389 nta_ack_cancel_f *irq_callback;
00390 nta_incoming_magic_t *irq_magic;
00391
00392
00393 nta_incoming_t **irq_prev;
00394 nta_incoming_t *irq_next;
00395 incoming_queue_t *irq_queue;
00396
00397
00398 nta_incoming_t **irq_rprev;
00399 nta_incoming_t *irq_rnext;
00400
00401 sip_method_t irq_method;
00402 sip_request_t *irq_rq;
00403 sip_from_t *irq_from;
00404 sip_to_t *irq_to;
00405 char const *irq_tag;
00406 sip_cseq_t *irq_cseq;
00407 sip_call_id_t *irq_call_id;
00408 sip_via_t *irq_via;
00409 sip_record_route_t *irq_record_route;
00410 char const *irq_branch;
00411
00412 uint32_t irq_rseq;
00413
00414 sip_timestamp_t *irq_timestamp;
00415 su_time_t irq_received;
00416
00417 su_duration_t irq_timeout;
00418 su_duration_t irq_retry;
00419 unsigned short irq_interval;
00421 short irq_status;
00422
00423 unsigned irq_retries : 8;
00424 unsigned irq_default : 1;
00425 unsigned irq_canceled : 1;
00426 unsigned irq_completed : 1;
00427 unsigned irq_confirmed : 1;
00428 unsigned irq_terminated :1;
00429 unsigned irq_final_failed:1;
00430 unsigned irq_destroyed :1;
00431 unsigned irq_in_callback:1;
00432 unsigned irq_reliable_tp:1;
00433 unsigned irq_sigcomp_zap:1;
00434 unsigned irq_must_100rel:1;
00435 unsigned irq_tag_set:1;
00436 unsigned :0;
00437
00438 tp_name_t irq_tpn[1];
00439 tport_t *irq_tport;
00440 struct sigcomp_compartment *irq_cc;
00441 msg_t *irq_request;
00442 msg_t *irq_request2;
00443 msg_t *irq_response;
00444
00445 nta_reliable_t *irq_reliable;
00446 };
00447
00448 struct nta_reliable_s
00449 {
00450 nta_reliable_t *rel_next;
00451 nta_incoming_t *rel_irq;
00452 nta_prack_f *rel_callback;
00453 nta_reliable_magic_t *rel_magic;
00454 uint32_t rel_rseq;
00455 unsigned short rel_status;
00456 unsigned rel_pracked : 1;
00457 unsigned rel_precious : 1;
00458 msg_t *rel_response;
00459 msg_t *rel_unsent;
00460 };
00461
00462 typedef struct sipdns_resolver sipdns_resolver_t;
00463
00464 struct nta_outgoing_s
00465 {
00466 hash_value_t orq_hash;
00467 nta_agent_t *orq_agent;
00468 nta_response_f *orq_callback;
00469 nta_outgoing_magic_t *orq_magic;
00470
00471
00472 nta_outgoing_t **orq_prev;
00473 nta_outgoing_t *orq_next;
00474 outgoing_queue_t *orq_queue;
00475
00476
00477 nta_outgoing_t **orq_rprev;
00478 nta_outgoing_t *orq_rnext;
00479
00480 sip_method_t orq_method;
00481 char const *orq_method_name;
00482 url_t const *orq_url;
00484 sip_from_t const *orq_from;
00485 sip_to_t const *orq_to;
00486 char const *orq_tag;
00488 sip_cseq_t const *orq_cseq;
00489 sip_call_id_t const *orq_call_id;
00490
00491 msg_t *orq_request;
00492 msg_t *orq_response;
00493
00494 su_time_t orq_sent;
00495 unsigned orq_delay;
00497 su_duration_t orq_retry;
00498 su_duration_t orq_timeout;
00500 unsigned short orq_interval;
00502 unsigned short orq_status;
00503 unsigned char orq_retries;
00504 unsigned orq_default : 1;
00505 unsigned orq_inserted : 1;
00506 unsigned orq_resolved : 1;
00507 unsigned orq_prepared : 1;
00508 unsigned orq_canceled : 1;
00509 unsigned orq_terminated : 1;
00510 unsigned orq_destroyed : 1;
00511 unsigned orq_completed : 1;
00512 unsigned orq_delayed : 1;
00513 unsigned orq_stripped_uri : 1;
00514 unsigned orq_user_tport : 1;
00515 unsigned orq_try_tcp_instead : 1;
00516 unsigned orq_try_udp_instead : 1;
00517 unsigned orq_reliable : 1;
00518 unsigned orq_ack_error : 1;
00519
00520 unsigned orq_user_via : 1;
00521 unsigned orq_stateless : 1;
00522 unsigned orq_pass_100 : 1;
00523 unsigned orq_sigcomp_new:1;
00524 unsigned orq_sigcomp_zap:1;
00525 unsigned orq_must_100rel : 1;
00526 unsigned orq_timestamp : 1;
00527 unsigned orq_100rel:1;
00528 unsigned : 0;
00529
00530 #if HAVE_SOFIA_SRESOLV
00531 sipdns_resolver_t *orq_resolver;
00532 #endif
00533 enum nta_res_order_e orq_res_order;
00535 url_t *orq_route;
00536 tp_name_t orq_tpn[1];
00537 char const *orq_scheme;
00539 tport_t *orq_tport;
00540 struct sigcomp_compartment *orq_cc;
00541 tagi_t *orq_tags;
00542 int orq_pending;
00544 char const *orq_branch;
00545 char const *orq_via_branch;
00547 int *orq_status2b;
00549 nta_outgoing_t *orq_cancel;
00551 uint32_t orq_rseq;
00552 };
00553
00554
00555 typedef struct
00556 {
00557 int ncv_size;
00558 char const *ncv_name;
00559
00560 nta_compressor_t *(*ncv_init_agent)(nta_agent_t *sa,
00561 char const * const *options);
00562
00563 void (*ncv_deinit_agent)(nta_agent_t *sa, nta_compressor_t *);
00564
00565 struct sigcomp_compartment *(*ncv_compartment)(nta_agent_t *sa,
00566 tport_t *tport,
00567 nta_compressor_t *msc,
00568 tp_name_t const *tpn,
00569 char const * const *options,
00570 int new_if_needed);
00571
00572 int (*ncv_accept_compressed)(nta_agent_t *sa,
00573 nta_compressor_t *msc,
00574 tport_compressor_t *sc,
00575 msg_t *msg,
00576 struct sigcomp_compartment *cc);
00577
00578 int (*ncv_close_compressor)(nta_agent_t *sa,
00579 struct sigcomp_compartment *cc);
00580 int (*ncv_zap_compressor)(nta_agent_t *sa,
00581 struct sigcomp_compartment *cc);
00582
00583 struct sigcomp_compartment *(*ncv_compartment_ref)
00584 (struct sigcomp_compartment *);
00585
00586 void (*ncv_compartment_unref)(struct sigcomp_compartment *);
00587
00588 } nta_compressor_vtable_t;
00589
00590 extern nta_compressor_vtable_t *nta_compressor_vtable;
00591
00592 SOFIAPUBFUN nta_compressor_t *nta_agent_init_sigcomp(nta_agent_t *sa);
00593 SOFIAPUBFUN void nta_agent_deinit_sigcomp(nta_agent_t *sa);
00594
00595
00596
00597
00598 #define SU_LOG nta_log
00599
00600 #ifdef SU_DEBUG_H
00601 #error <su_debug.h> included directly.
00602 #endif
00603 #include <sofia-sip/su_debug.h>
00604 SOFIAPUBVAR su_log_t nta_log[];
00605
00606 SOFIA_END_DECLS
00607
00608 #endif