admin管理员组文章数量:1565360
这个函数没有具体分析:
int
_eXosip_dialog_add_contact (osip_message_t * request, osip_message_t * answer)
{
osip_via_t *via;
osip_from_t *a_from;
char *contact = NULL;
char locip[65];
char firewall_ip[65];
char firewall_port[10];
int len;
if (eXosip.eXtl == NULL)
return OSIP_NO_NETWORK;
if (request == NULL)
return OSIP_BADPARAMETER;
if (eXosip.eXtl->tl_get_masquerade_contact != NULL)
{
eXosip.eXtl->tl_get_masquerade_contact (firewall_ip, sizeof (firewall_ip),
firewall_port,
sizeof (firewall_port));
}
/* search for topmost Via which indicate the transport protocol */
via = (osip_via_t *) osip_list_get (&request->vias, 0);
if (via == NULL || via->protocol == NULL)
{
OSIP_TRACE (osip_trace
(__FILE__, __LINE__, OSIP_ERROR, NULL,
"eXosip: missing via header\n"));
return OSIP_SYNTAXERROR;
}
if (answer == NULL)
a_from = request->from;
else
a_from = answer->to;
if (a_from == NULL || a_from->url == NULL)
return OSIP_SYNTAXERROR;
/*guess the local ip since req uri is known */
memset (locip, '\0', sizeof (locip));
if (a_from->url->username != NULL)
len =
2 + 4 + strlen (a_from->url->username) + 1 + 100 + 6 + 10 +
strlen (eXosip.transport);
else
len = 2 + 4 + 100 + 6 + 10 + strlen (eXosip.transport);
contact = (char *) osip_malloc (len + 1);
if (contact == NULL)
return OSIP_NOMEM;
if (firewall_ip[0] != '\0')
{
char *c_address = request->req_uri->host;
struct addrinfo *addrinfo;
struct __eXosip_sockaddr addr;
int i;
i =
eXosip_get_addrinfo (&addrinfo, request->req_uri->host, 5060, IPPROTO_TCP);
if (i == 0)
{
memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen);
eXosip_freeaddrinfo (addrinfo);
c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr);
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
"eXosip: here is the resolved destination host=%s\n",
c_address));
}
if (eXosip_is_public_address (c_address))
{
memcpy (locip, firewall_ip, sizeof (locip));
}
}
if (locip[0] == '\0')
{
eXosip_guess_ip_for_via (eXosip.eXtl->proto_family, locip, 49);
if (locip[0] == '\0')
{
OSIP_TRACE (osip_trace
(__FILE__, __LINE__, OSIP_ERROR, NULL,
"eXosip: no default interface defined\n"));
return OSIP_NO_NETWORK;
}
}
if (eXosip.eXtl->proto_family == AF_INET6)
{
if (a_from->url->username != NULL)
snprintf (contact, len, "", a_from->url->username,
locip, firewall_port);
else
snprintf (contact, len - strlen (eXosip.transport) - 10, "",
locip, firewall_port);
} else
{
if (a_from->url->username != NULL)
snprintf (contact, len, "", a_from->url->username,
locip, firewall_port);
else
snprintf (contact, len - strlen (eXosip.transport) - 10, "",
locip, firewall_port);
}
if (osip_strcasecmp (eXosip.transport, "UDP") != 0)
{
contact[strlen (contact) - 1] = '\0';
strcat (contact, ";transport=");
strcat (contact, eXosip.transport);
strcat (contact, ">");
}
osip_message_set_contact (request, contact);
osip_free (contact);
return OSIP_SUCCESS;
//添加contact字段
osip_contact_t*contact=NULL;
osip_message_get_contact(je->request,0,&contact);
osip_contact_t*contactfill=NULL;
osip_contact_clone(contact,&contactfill);
osip_contact_set_displayname(contactfill,osip_strdup("123"));
osip_list_add(&answer->contacts,contactfill,-1);
}
本文标签: 字段函数ContactAddeXosipdialogaddcontact
版权声明:本文标题:add contact层对比_int _eXosip_dialog_add_contact函数添加contact字段 | 学步园 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1726639849a1079520.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论