/*
eXosip - This is the eXtended osip library.
Copyright (C) 2002,2003,2004,2005,2006,2007 Aymeric MOIZARD - jack@atosc.org
eXosip is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
eXosip 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef ENABLE_MPATROL
#include <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip2/eXosip.h>
#ifndef WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef __APPLE_CC__
#include <unistd.h>
#endif
#else
#include <windows.h>
#endif
extern eXosip_t eXosip;
extern int ipv6_enable;
/* Private functions */
static void eXosip_send_default_answer (eXosip_dialog_t * jd,
osip_transaction_t * transaction,
osip_event_t * evt,
int status,
char *reason_phrase,
char *warning, int line);
static void eXosip_process_bye (eXosip_call_t * jc, eXosip_dialog_t * jd,
osip_transaction_t * transaction,
osip_event_t * evt);
static void eXosip_process_ack (eXosip_call_t * jc, eXosip_dialog_t * jd,
osip_event_t * evt);
static void eXosip_process_prack (eXosip_call_t * jc, eXosip_dialog_t * jd,
osip_transaction_t * transaction,
osip_event_t * evt);
static int cancel_match_invite (osip_transaction_t * invite,
osip_message_t * cancel);
static void eXosip_process_cancel (osip_transaction_t * transaction,
osip_event_t * evt);
static void eXosip_process_reinvite (eXosip_call_t * jc,
eXosip_dialog_t * jd,
osip_transaction_t *
transaction, osip_event_t * evt);
static void eXosip_process_new_invite (osip_transaction_t * transaction,
osip_event_t * evt);
#ifndef MINISIZE
static void eXosip_process_new_subscribe (osip_transaction_t * transaction,
osip_event_t * evt);
static void eXosip_process_subscribe_within_call (eXosip_notify_t * jn,
eXosip_dialog_t * jd,
osip_transaction_t *
transaction, osip_event_t * evt);
static void eXosip_process_notify_within_dialog (eXosip_subscribe_t * js,
eXosip_dialog_t * jd,
osip_transaction_t *
transaction, osip_event_t * evt);
static int eXosip_match_notify_for_subscribe (eXosip_subscribe_t * js,
osip_message_t * notify);
#endif
static void eXosip_process_message_within_dialog (eXosip_call_t * jc,
eXosip_dialog_t * jd,
osip_transaction_t *
transaction, osip_event_t * evt);
static void eXosip_process_newrequest (osip_event_t * evt, int socket);
static void eXosip_process_response_out_of_transaction (osip_event_t * evt);
static int eXosip_pendingosip_transaction_exist (eXosip_call_t * jc,
eXosip_dialog_t * jd);
static int eXosip_release_finished_calls (eXosip_call_t * jc,
eXosip_dialog_t * jd);
static int eXosip_release_aborted_calls (eXosip_call_t * jc, eXosip_dialog_t * jd);
static int eXosip_release_finished_transactions (eXosip_call_t *jc, eXosip_dialog_t * jd);
#ifndef MINISIZE
static int eXosip_release_finished_transactions_for_subscription (eXosip_dialog_t *jd);
#endif
static void
eXosip_send_default_answer (eXosip_dialog_t * jd,
osip_transaction_t * transaction,
osip_event_t * evt,
int status,
char *reason_phrase, char *warning, int line)
{
osip_event_t *evt_answer;
osip_message_t *answer;
int i;
/* osip_list_add(eXosip.j_transactions, transaction, 0); */
osip_transaction_set_your_instance (transaction, NULL);
/* THIS METHOD DOES NOT ACCEPT STATUS CODE BETWEEN 101 and 299 */
if (status > 100 && status < 299 && MSG_IS_INVITE (evt->sip))
return;
if (jd != NULL)
i = _eXosip_build_response_default (&answer, jd->d_dialog, status, evt->sip);
else
i = _eXosip_build_response_default (&answer, NULL, status, evt->sip);
if (i != 0 || answer == NULL)
{
return;
}
if (reason_phrase != NULL)
{
char *_reason;
_reason = osip_message_get_reason_phrase (answer);
if (_reason != NULL)
osip_free (_reason);
_reason = osip_strdup (reason_phrase);
osip_message_set_reason_phrase (answer, _reason);
}
osip_message_set_content_length (answer, "0");
if (status == 500)
osip_message_set_retry_after (answer, "10");
evt_answer = osip_new_outgoing_sipmessage (answer);
evt_answer->transactionid = transaction->transactionid;
osip_transaction_add_event (transaction, evt_answer);
__eXosip_wakeup ();
}
static void
eXosip_process_bye (eXosip_call_t * jc, eXosip_dialog_t * jd,
osip_transaction_t * transaction, osip_event_t * evt)
{
osip_event_t *evt_answer;
osip_message_t *answer;
int i;
#ifndef MINISIZE
osip_transaction_set_your_instance (transaction,
__eXosip_new_jinfo (jc, NULL /*jd */ ,
NULL, NULL));
#else
osip_transaction_set_your_instance (transaction,
__eXosip_new_jinfo (jc, NULL /*jd */));
#endif
i = _eXosip_build_response_default (&answer, jd->d_dialog, 200, evt->sip);
if (i != 0)
{
osip_list_add (eXosip.j_transactions, transaction, 0);
return;
}
osip_message_set_content_length (answer, "0");
evt_answer = osip_new_outgoing_sipmessage (answer);
evt_answer->transactionid = transaction->transactionid;
osip_list_add (jd->d_inc_trs, transaction, 0);
/* Release the eXosip_dialog */
osip_dialog_free (jd->d_dialog);
jd->d_dialog = NULL;
osip_transaction_add_event (transaction, evt_answer);
osip_nist_execute (eXosip.j_osip);
report_call_event (EXOSIP_CALL_MESSAGE_NEW, jc, jd, transaction);
report_call_event (EXOSIP_CALL_CLOSED, jc, jd, transaction);
eXosip_update (); /* AMD 30/09/05 */
__eXosip_wakeup ();
}
static void
eXosip_process_ack (eXosip_call_t * jc, eXosip_dialog_t * jd, osip_event_t * evt)
{
/* TODO: We should find the matching transaction for this ACK
and also add the ACK in the event. */
eXosip_event_t *je;
int i;
je = eXosip_event_init_for_call (EXOSIP_CALL_ACK, jc, jd, NULL);
if (je != NULL)
{
osip_transaction_t *tr;
tr= eXosip_find_last_inc_invite(jc, jd);
if (tr!=NULL)
{
je->tid = tr->transactionid;
}
/* fill request and answer */
if (tr->orig_request != NULL)
{
i = osip_message_clone (tr->orig_request, &je->request);
if (i != 0)
{
OSIP_TRACE (osip_trace (__FILE__, __LINE__,
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
osip协议栈应用实例 (275个子文件)
libpthreadGCE2.a 88KB
libpthreadGC2.a 88KB
Makefile.am 1KB
Makefile.am 834B
Makefile.am 255B
Makefile.am 190B
Makefile.am 181B
Makefile.am 30B
ANNOUNCE 14KB
README.Borland 3KB
demo.bsc 2.04MB
BUGS 6KB
udp.c 72KB
jcallback.c 63KB
osip.c 56KB
sdp_message.c 53KB
eXcall_api.c 39KB
eXosip.c 37KB
eXtl_tls.c 36KB
osip_message_parse.c 33KB
eXutils.c 33KB
eXtl_dtls.c 28KB
jrequest.c 27KB
osip_port.c 27KB
eXconf.c 25KB
osip_message_to_str.c 25KB
osip_transaction.c 24KB
osip_uri.c 24KB
eXinsubscription_api.c 19KB
eXtl_tcp.c 18KB
sdp_accessor.c 18KB
jauth.c 18KB
osip_authorization.c 18KB
osip_www_authenticate.c 18KB
eXtl_udp.c 16KB
osip_from.c 16KB
ict_fsm.c 15KB
port_sema.c 15KB
osip_dialog.c 14KB
osip_message.c 14KB
jevents.c 14KB
nict_fsm.c 13KB
jresponse.c 13KB
ist_fsm.c 12KB
osip_body.c 12KB
osip_via.c 11KB
osip_authentication_info.c 11KB
nist_fsm.c 11KB
eXsubscription_api.c 11KB
osip_md5c.c 11KB
sdp_offans.c 9KB
osip_parser_cfg.c 8KB
eXregister_api.c 8KB
osip_header.c 8KB
port_condv.c 7KB
osip_content_type.c 7KB
misc.c 7KB
port_thread.c 7KB
inet_ntop.c 7KB
osip_list.c 7KB
osip_accept_encoding.c 6KB
jpipe.c 6KB
eXoptions_api.c 6KB
eXmessage_api.c 6KB
osip_call_id.c 6KB
osip_event.c 5KB
osip_call_info.c 5KB
ict.c 5KB
jdialog.c 5KB
nict.c 5KB
osip_cseq.c 5KB
demo.c 5KB
port_fifo.c 5KB
eXpublish_api.c 5KB
osip_record_route.c 4KB
jnotify.c 4KB
jreg.c 4KB
jsubscribe.c 4KB
eXtransport.c 4KB
osip_contact.c 4KB
osip_accept.c 4KB
osip_content_length.c 4KB
ist.c 4KB
jpublish.c 3KB
jcall.c 3KB
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
eXrefer_api.c 2KB
osip_mime_version.c 2KB
osip_error_info.c 2KB
osip_alert_info.c 2KB
osip_allow.c 2KB
共 275 条
- 1
- 2
- 3
资源评论
- sf_suifeng2014-11-05下载下来调试到现在都没有编译通过,楼主长传的时候给个说明是最好了,
- holylark2011-10-27这个实例还不错,对理解ua的工作原理有帮助,要是有更详细的说明就更好了
- haao0032012-09-28没有详细的说明
- guduandejiaoyin69192013-06-26代码写的有点乱
- geforceati2013-12-26说明太少了,如果更多详细说明就好了
zhqxm1983
- 粉丝: 7
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功