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