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