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

TPORT_DLL tport_t* tport_primary_by_name ( tport_t const *  tp,
tp_name_t const *  tpn 
)

Get transport by interface identifier and protocol name.

Get transport by protocol name.

Definition at line 4127 of file tport.c.

References tp_name_t::tpn_comp, tp_name_t::tpn_host, tp_name_t::tpn_ident, tp_name_t::tpn_proto, tport_canonize_comp(), tport_has_ip4(), tport_has_ip6(), and tport_primary_by_name().

Referenced by tport_by_name(), tport_primary_by_name(), and tport_tsend().

{
  char const *ident = tpn->tpn_ident;
  char const *proto = tpn->tpn_proto;
  char const *comp = tpn->tpn_comp;
  int family = 0;

  tport_primary_t const *self, *nocomp = NULL;

  self = tp ? tp->tp_master->mr_primaries : NULL;

  if (ident && strcmp(ident, tpn_any) == 0)
    ident = NULL;

  if (tpn->tpn_host == NULL)
    family = 0;
#if SU_HAVE_IN6
  else if (host_is_ip6_address(tpn->tpn_host))
    family = AF_INET6;
#endif
  else if (host_is_ip4_address(tpn->tpn_host))
    family = AF_INET;
  else 
    family = 0;

  if (proto && strcmp(proto, tpn_any) == 0)
    proto = NULL;

  if (!ident && !proto && !family && !comp)
    return (tport_t *)self;         /* Anything goes */

  comp = tport_canonize_comp(comp);

  for (; self; self = self->pri_next) {
    tp = self->pri_primary;

    if (ident && strcmp(ident, tp->tp_ident))
      continue;
    if (family) {
      if (family == AF_INET && !tport_has_ip4(tp))
      continue;
#if SU_HAVE_IN6
      if (family == AF_INET6 && !tport_has_ip6(tp))
      continue;
#endif
    }
    if (proto && strcasecmp(proto, tp->tp_protoname))
      continue;
    
    if (comp && comp != tp->tp_name->tpn_comp) {
      if (tp->tp_name->tpn_comp == NULL && nocomp == NULL)
      nocomp = self;
      continue;
    }

    break;
  }

  if (self)
    return (tport_t *)self;
  else
    return (tport_t *)nocomp;
}


Generated by  Doxygen 1.6.0   Back to index