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