Logo Search packages:      
Sourcecode: sofia-sip version File versions

TPORT_DLL tport_t* tport_tcreate ( tp_stack_t stack,
tp_stack_class_t const *  tpac,
su_root_t root,
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Create first primary transport.

Create the master transport.

TPTAG_LOG(), TPTAG_DUMP(), tags used with tport_set_params(), especially TPTAG_QUEUESIZE().

Definition at line 436 of file tport.c.

References SU_DEBUG_7, su_home_clone(), su_root_task(), su_seterrno(), su_timer_create(), su_timer_set(), ta_args, ta_end, ta_start, ta_tags, tp_name_t::tpn_canon, tp_name_t::tpn_host, tp_name_t::tpn_port, tp_name_t::tpn_proto, tport_init_stun_server(), tport_open_log(), TPORT_QUEUESIZE, tport_set_params(), tport_tcreate(), tport_params_t::tpp_idle, tport_params_t::tpp_mtu, tport_params_t::tpp_qsize, tport_params_t::tpp_sdwn_error, tport_params_t::tpp_sigcomp_lifetime, tport_params_t::tpp_stun_server, tport_params_t::tpp_thrprqsize, tport_params_t::tpp_timeout, and tport_params_t::tpp_tos.

Referenced by server_create(), and tport_tcreate().

{
  tport_master_t *mr;
  tp_name_t *tpn;
  tport_params_t *tpp;
  unsigned tick;
  ta_list ta;

  if (!stack || !tpac || !root) {
    su_seterrno(EINVAL);
    return NULL;
  }

  mr = su_home_clone(NULL, sizeof *mr);
  if (!mr)
    return NULL;

  SU_DEBUG_7(("%s(): %p\n", "tport_create", (void *)mr));

  mr->mr_stack = stack;
  mr->mr_tpac = tpac;
  mr->mr_root = root;

  mr->mr_master->tp_master = mr;
  mr->mr_master->tp_params = tpp = mr->mr_params;

  mr->mr_master->tp_reusable = 1;
  tpp->tpp_mtu = UINT_MAX;
  tpp->tpp_thrprqsize = THRP_PENDING;
  tpp->tpp_qsize = TPORT_QUEUESIZE;
  tpp->tpp_sdwn_error = 1;
  tpp->tpp_idle = UINT_MAX;
  tpp->tpp_timeout = UINT_MAX;
  tpp->tpp_sigcomp_lifetime = UINT_MAX;
  tpp->tpp_stun_server = 1;
  tpp->tpp_tos = -1;                  /* set invalid, valid values are 0-255 */

  tpn = mr->mr_master->tp_name;
  tpn->tpn_proto = "*";
  tpn->tpn_host = "*";
  tpn->tpn_canon = "*";
  tpn->tpn_port = "*";

  ta_start(ta, tag, value);

  tport_set_params(mr->mr_master, ta_tags(ta));
  tport_open_log(mr, ta_args(ta));

  tick = 5000; /* For testing, usually 30000 is enough */  
  if (tpp->tpp_idle < 4 * tick)
    tick = tpp->tpp_idle / 4;
  if (tpp->tpp_timeout < 4 * tick)
    tick = tpp->tpp_timeout / 4;
  if (tick < 200)
    tick = 200;

#if HAVE_SOFIA_STUN
  tport_init_stun_server(mr, ta_args(ta));
#endif

  mr->mr_timer = su_timer_create(su_root_task(root), tick);
  su_timer_set(mr->mr_timer, tport_tick, mr);

  ta_end(ta);

  return mr->mr_master;
}


Generated by  Doxygen 1.6.0   Back to index