admin管理员组

文章数量:1530021

这个函数没有具体分析:

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