/*
The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Aymeric MOIZARD jack@atosc.org
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <osip2/internal.h>
#include <osip2/osip.h>
#include "fsm.h"
#include "xixt.h"
#ifdef OSIP_MT
static struct osip_mutex *ict_fastmutex;
static struct osip_mutex *ist_fastmutex;
static struct osip_mutex *nict_fastmutex;
static struct osip_mutex *nist_fastmutex;
#endif
#include <osip2/osip_dialog.h>
#ifdef OSIP_MT
static struct osip_mutex *ixt_fastmutex;
#endif
static int __osip_global_init (void);
static void __osip_global_free (void);
static int increase_ref_count (void);
static void decrease_ref_count (void);
static int
__osip_global_init ()
{
/* load the fsm configuration */
#ifndef MINISIZE
__ict_load_fsm ();
__ist_load_fsm ();
__nict_load_fsm ();
__nist_load_fsm ();
#endif
/* load the parser configuration */
parser_init ();
#ifdef OSIP_MT
ict_fastmutex = osip_mutex_init ();
ist_fastmutex = osip_mutex_init ();
nict_fastmutex = osip_mutex_init ();
nist_fastmutex = osip_mutex_init ();
ixt_fastmutex = osip_mutex_init ();
#endif
return OSIP_SUCCESS;
}
static void
__osip_global_free ()
{
#ifndef MINISIZE
__ict_unload_fsm ();
__ist_unload_fsm ();
__nict_unload_fsm ();
__nist_unload_fsm ();
#endif
#ifdef OSIP_MT
osip_mutex_destroy (ict_fastmutex);
osip_mutex_destroy (ist_fastmutex);
osip_mutex_destroy (nict_fastmutex);
osip_mutex_destroy (nist_fastmutex);
osip_mutex_destroy (ixt_fastmutex);
#endif
}
void
osip_response_get_destination (osip_message_t * response, char **address,
int *portnum)
{
osip_via_t *via;
char *host = NULL;
int port = 0;
via = (osip_via_t *) osip_list_get (&response->vias, 0);
if (via)
{
osip_generic_param_t *maddr;
osip_generic_param_t *received;
osip_generic_param_t *rport;
osip_via_param_get_byname (via, "maddr", &maddr);
osip_via_param_get_byname (via, "received", &received);
osip_via_param_get_byname (via, "rport", &rport);
/* 1: user should not use the provided information
(host and port) if they are using a reliable
transport. Instead, they should use the already
open socket attached to this transaction. */
/* 2: check maddr and multicast usage */
if (maddr != NULL)
host = maddr->gvalue;
/* we should check if this is a multicast address and use
set the "ttl" in this case. (this must be done in the
UDP message (not at the SIP layer) */
else if (received != NULL)
host = received->gvalue;
else
host = via->host;
if (rport == NULL || rport->gvalue == NULL)
{
if (via->port != NULL)
port = osip_atoi (via->port);
else
port = 5060;
} else
port = osip_atoi (rport->gvalue);
}
*portnum = port;
if (host != NULL)
*address = osip_strdup (host);
else
*address = NULL;
}
int
osip_ixt_lock (osip_t * osip)
{
#ifdef OSIP_MT
return osip_mutex_lock (ixt_fastmutex);
#else
return OSIP_SUCCESS;
#endif
}
int
osip_ixt_unlock (osip_t * osip)
{
#ifdef OSIP_MT
return osip_mutex_unlock (ixt_fastmutex);
#else
return OSIP_SUCCESS;
#endif
}
/* these are for transactions that would need retransmission not handled by state machines */
void
osip_add_ixt (osip_t * osip, ixt_t * ixt)
{
/* add in list osip_t->ixt */
osip_ixt_lock (osip);
osip_list_add (&osip->ixt_retransmissions, (void *) ixt, 0);
osip_ixt_unlock (osip);
}
void
osip_remove_ixt (osip_t * osip, ixt_t * ixt)
{
int i;
int found = 0;
ixt_t *tmp;
/* add in list osip_t->ixt */
osip_ixt_lock (osip);
for (i = 0; !osip_list_eol (&osip->ixt_retransmissions, i); i++)
{
tmp = (ixt_t *) osip_list_get (&osip->ixt_retransmissions, i);
if (tmp == ixt)
{
osip_list_remove (&osip->ixt_retransmissions, i);
found = 1;
break;
}
}
osip_ixt_unlock (osip);
}
int
ixt_init (ixt_t ** ixt)
{
ixt_t *pixt;
*ixt = pixt = (ixt_t *) osip_malloc (sizeof (ixt_t));
if (pixt == NULL)
return OSIP_NOMEM;
pixt->dialog = NULL;
pixt->msg2xx = NULL;
pixt->ack = NULL;
pixt->interval = DEFAULT_T1;
osip_gettimeofday(&pixt->start, NULL);
add_gettimeofday(&pixt->start, pixt->interval+10);
pixt->counter = 10;
pixt->dest = NULL;
pixt->port = 5060;
pixt->sock = -1;
return OSIP_SUCCESS;
}
void
ixt_free (ixt_t * ixt)
{
osip_message_free (ixt->ack);
osip_message_free (ixt->msg2xx);
osip_free (ixt->dest);
osip_free (ixt);
}
/* usefull for UAs */
void
osip_start_200ok_retransmissions (osip_t * osip, osip_dialog_t * dialog,
osip_message_t * msg200ok, int sock)
{
ixt_t *ixt;
ixt_init (&ixt);
ixt->dialog = dialog;
osip_message_clone (msg200ok, &ixt->msg2xx);
ixt->sock = sock;
osip_response_get_destination (msg200ok, &ixt->dest, &ixt->port);
osip_add_ixt (osip, ixt);
}
void
osip_start_ack_retransmissions (osip_t * osip, osip_dialog_t * dialog,
osip_message_t * ack, char *dest, int port,
int sock)
{
int i;
ixt_t *ixt;
i = ixt_init (&ixt);
if (i != 0)
return;
ixt->dialog = dialog;
osip_message_clone (ack, &ixt->ack);
ixt->dest = osip_strdup (dest);
ixt->port = port;
ixt->sock = sock;
osip_add_ixt (osip, ixt);
}
/* we stop the 200ok when receiving the corresponding ack */
struct osip_dialog *
osip_stop_200ok_retransmissions (osip_t * osip, osip_message_t * ack)
{
osip_dialog_t *dialog = NULL;
int i;
ixt_t *ixt;
osip_ixt_lock (osip);
for (i = 0; !osip_list_eol (&osip->ixt_retransmissions, i); i++)
{
ixt = (ixt_t *) osip_list_get (&osip->ixt_retransmissions, i);
if (osip_dialog_match_as_uas (ixt->dialog, ack) == 0)
{
osip_list_remove (&osip->ixt_retransmissions, i);
dialog = ixt->dialog;
ixt_free (ixt);
break;
}
}
osip_ixt_unlock (osip);
return dialog;
}
/* when a dialog is destroyed by the application,
it is safer to remove all ixt that are related to it */
void
osip_stop_retransmissions_from_dialog (osip_t * osip, osip_dialog_t * dialog)
{
int i;
ixt_t *ixt;
osip_ixt_lock (osip);
for (i = 0; !osip_list_eol (&osip->ixt_retransmissions, i); i++)
{
ixt = (ixt_t *) osip_list_get (&osip->ixt_retransmissions, i);
if (ixt->dialog == dialog)
{
osip_list_remove (&osip->ixt_retransmissions, i);
ixt_free (ixt);
i--;
}
}
osip_ixt_unlock (osip);
}
void
ixt_retransmit (osip_t * osip, ixt_t * ixt, struct timeval *current)
{
if (osip_timercmp(current, &ixt->start, >))
{
ixt->interval = ixt->interval * 2;
if (ixt->interval > 4000)
ixt->interval = 4000;
add_gettimeofday (&ixt->start, ixt->interval);
if (ixt->ack != NULL)
osip->cb_send_message (NULL, ixt->ack, ixt->dest, ixt->port, ixt->sock);
else if (ixt->msg2xx != NULL)
osip->cb_send_message (NULL, ixt->msg2xx, ixt->dest, ixt->port, ixt->sock);
ixt->counter--;
}
}
void
osip_retransmissions_exe
没有合适的资源?快使用搜索试试~ 我知道了~
oosip2_osippai.rar_exosip_exosip lib
共148个文件
obj:56个
c:56个
manifest:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 200 浏览量
2022-09-24
04:38:54
上传
评论
收藏 1.44MB RAR 举报
温馨提示
oisp和exosip,是sip协议的开源库.内含VC22008的编译工程,以及编译好的lib文件,可以直接使用。
资源推荐
资源详情
资源评论
收起资源包目录
oosip2_osippai.rar_exosip_exosip lib (148个子文件)
osip.c 57KB
sdp_message.c 56KB
osip_message_parse.c 35KB
osip_port.c 30KB
osip_transaction.c 25KB
osip_message_to_str.c 25KB
osip_uri.c 25KB
osip_www_authenticate.c 19KB
sdp_accessor.c 19KB
osip_authorization.c 19KB
port_sema.c 17KB
osip_from.c 17KB
ict_fsm.c 16KB
osip_dialog.c 16KB
osip_message.c 15KB
nict_fsm.c 13KB
osip_via.c 12KB
osip_body.c 12KB
ist_fsm.c 12KB
osip_authentication_info.c 11KB
nist_fsm.c 11KB
osip_md5c.c 11KB
osip_header.c 8KB
osip_parser_cfg.c 8KB
port_condv.c 8KB
osip_content_type.c 7KB
port_thread.c 7KB
osip_list.c 7KB
osip_accept_encoding.c 6KB
osip_call_id.c 6KB
osip_call_info.c 6KB
osip_cseq.c 6KB
osip_event.c 5KB
ict.c 5KB
nict.c 5KB
port_fifo.c 5KB
osip_record_route.c 5KB
osip_content_length.c 4KB
osip_contact.c 4KB
osip_accept.c 4KB
ist.c 4KB
osip_route.c 3KB
osip_to.c 3KB
osip_proxy_authentication_info.c 3KB
nist.c 3KB
osip_proxy_authenticate.c 2KB
osip_time.c 2KB
osip_proxy_authorization.c 2KB
fsm_misc.c 2KB
osip_content_encoding.c 2KB
osip_accept_language.c 2KB
osip_mime_version.c 2KB
osip_error_info.c 2KB
osip_alert_info.c 2KB
osip_allow.c 2KB
osip_content_disposition.c 2KB
osipparser2.def 15KB
osip2.def 3KB
mt.dep 63B
mt.dep 63B
osip2.dll 190KB
osipparser2.dll 185KB
xixt.h 11KB
fsm.h 6KB
parser.h 2KB
BuildLog.htm 16KB
BuildLog.htm 7KB
vc90.idb 299KB
vc90.idb 171KB
osip2.ilk 521KB
osipparser2.ilk 505KB
osipparser2.lib 926KB
osipparser2.lib 926KB
osip2.lib 349KB
osip2.dll.embed.manifest 663B
osipparser2.dll.embed.manifest 663B
osip2.dll.intermediate.manifest 621B
osipparser2.dll.intermediate.manifest 621B
sdp_message.obj 72KB
osip.obj 70KB
osip_message_parse.obj 53KB
sdp_accessor.obj 50KB
osip_port.obj 49KB
osip_uri.obj 47KB
osip_message_to_str.obj 42KB
osip_authorization.obj 40KB
osip_transaction.obj 37KB
osip_www_authenticate.obj 36KB
osip_from.obj 31KB
osip_via.obj 30KB
ict_fsm.obj 28KB
osip_message.obj 26KB
osip_body.obj 26KB
osip_authentication_info.obj 26KB
osip_dialog.obj 26KB
nict_fsm.obj 23KB
ist_fsm.obj 23KB
osip_parser_cfg.obj 22KB
osip_header.obj 22KB
nist_fsm.obj 21KB
共 148 条
- 1
- 2
资源评论
alvarocfc
- 粉丝: 105
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功