⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ict_fsm.c

📁 libosip2-3.0.3最新版本
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  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"#ifndef MINISIZEosip_statemachine_t *ict_fsm;osip_statemachine_t *__ict_get_fsm (){  return ict_fsm;}void__ict_unload_fsm (){  transition_t *transition;  osip_statemachine_t *statemachine = __ict_get_fsm ();  for (transition = statemachine->transitions; transition != NULL; transition = statemachine->transitions)    {      REMOVE_ELEMENT(statemachine->transitions, transition);      osip_free (transition);    }  osip_free (statemachine->transitions);  osip_free (statemachine);}void__ict_load_fsm (){  transition_t *transition;  ict_fsm = (osip_statemachine_t *) osip_malloc (sizeof (osip_statemachine_t));  ict_fsm->transitions = NULL;  /* a new state is needed because a race can happen between     the timer and the timeout event!     One day to find out this bug  ;-)   */  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_PRE_CALLING;  transition->type = SND_REQINVITE;  transition->method = (void (*)(void *, void *)) &ict_snd_invite;  ADD_ELEMENT (ict_fsm->transitions, transition);  /*     transition         = (transition_t *) osip_malloc(sizeof(transition_t));     transition->state  = ICT_CALLING;     transition->type   = SND_REQINVITE;     transition->method = (void(*)(void *,void *))&ict_snd_invite;     osip_list_add(ict_fsm->transitions,transition,-1);   */  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_CALLING;  transition->type = TIMEOUT_A;  transition->method = (void (*)(void *, void *)) &osip_ict_timeout_a_event;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_CALLING;  transition->type = TIMEOUT_B;  transition->method = (void (*)(void *, void *)) &osip_ict_timeout_b_event;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_CALLING;  transition->type = RCV_STATUS_1XX;  transition->method = (void (*)(void *, void *)) &ict_rcv_1xx;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_CALLING;  transition->type = RCV_STATUS_2XX;  transition->method = (void (*)(void *, void *)) &ict_rcv_2xx;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_CALLING;  transition->type = RCV_STATUS_3456XX;  transition->method = (void (*)(void *, void *)) &ict_rcv_3456xx;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_PROCEEDING;  transition->type = RCV_STATUS_1XX;  transition->method = (void (*)(void *, void *)) &ict_rcv_1xx;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_PROCEEDING;  transition->type = RCV_STATUS_2XX;  transition->method = (void (*)(void *, void *)) &ict_rcv_2xx;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_PROCEEDING;  transition->type = RCV_STATUS_3456XX;  transition->method = (void (*)(void *, void *)) &ict_rcv_3456xx;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_COMPLETED;  transition->type = RCV_STATUS_3456XX;  transition->method = (void (*)(void *, void *)) &ict_retransmit_ack;  ADD_ELEMENT (ict_fsm->transitions, transition);  transition = (transition_t *) osip_malloc (sizeof (transition_t));  transition->state = ICT_COMPLETED;  transition->type = TIMEOUT_D;  transition->method = (void (*)(void *, void *)) &osip_ict_timeout_d_event;  ADD_ELEMENT (ict_fsm->transitions, transition);}#elsetransition_t ict_transition[11] =  {    {      ICT_PRE_CALLING,      SND_REQINVITE,      (void (*)(void *, void *)) &ict_snd_invite,      &ict_transition[1], NULL    }    ,    {      ICT_CALLING,      TIMEOUT_A,      (void (*)(void *, void *)) &osip_ict_timeout_a_event,      &ict_transition[2], NULL    }    ,    {      ICT_CALLING,      TIMEOUT_B,      (void (*)(void *, void *)) &osip_ict_timeout_b_event,      &ict_transition[3], NULL    }    ,    { ICT_CALLING,      RCV_STATUS_1XX,      (void (*)(void *, void *)) &ict_rcv_1xx,      &ict_transition[4], NULL    }    ,    { ICT_CALLING,      RCV_STATUS_2XX,      (void (*)(void *, void *)) &ict_rcv_2xx,      &ict_transition[5], NULL    }    ,    { ICT_CALLING,      RCV_STATUS_3456XX,      (void (*)(void *, void *)) &ict_rcv_3456xx,      &ict_transition[6], NULL    }    ,    { ICT_PROCEEDING,      RCV_STATUS_1XX,      (void (*)(void *, void *)) &ict_rcv_1xx,      &ict_transition[7], NULL    }    ,    { ICT_PROCEEDING,      RCV_STATUS_2XX,      (void (*)(void *, void *)) &ict_rcv_2xx,      &ict_transition[8], NULL    }    ,    { ICT_PROCEEDING,      RCV_STATUS_3456XX,      (void (*)(void *, void *)) &ict_rcv_3456xx,      &ict_transition[9], NULL    }    ,    { ICT_COMPLETED,      RCV_STATUS_3456XX,      (void (*)(void *, void *)) &ict_retransmit_ack,      &ict_transition[10], NULL    }    ,    { ICT_COMPLETED,      TIMEOUT_D,      (void (*)(void *, void *)) &osip_ict_timeout_d_event,      NULL, NULL    }  };osip_statemachine_t ict_fsm = { ict_transition };#endifstatic voidict_handle_transport_error (osip_transaction_t * ict, int err){  __osip_transport_error_callback (OSIP_ICT_TRANSPORT_ERROR, ict, err);  __osip_transaction_set_state (ict, ICT_TERMINATED);  __osip_kill_transaction_callback (OSIP_ICT_KILL_TRANSACTION, ict);  /* TODO: MUST BE DELETED NOW */}voidict_snd_invite (osip_transaction_t * ict, osip_event_t * evt){  int i;  osip_t *osip = (osip_t *) ict->config;  /* Here we have ict->orig_request == NULL */  ict->orig_request = evt->sip;  i = osip->cb_send_message (ict, evt->sip, ict->ict_context->destination,                             ict->ict_context->port, ict->out_socket);  if (i == 0)    {      __osip_message_callback (OSIP_ICT_INVITE_SENT, ict, ict->orig_request);      __osip_transaction_set_state (ict, ICT_CALLING);  } else    {      ict_handle_transport_error (ict, i);    }}voidosip_ict_timeout_a_event (osip_transaction_t * ict, osip_event_t * evt){  osip_t *osip = (osip_t *) ict->config;  int i;  /* reset timer */  ict->ict_context->timer_a_length = ict->ict_context->timer_a_length * 2;  osip_gettimeofday (&ict->ict_context->timer_a_start, NULL);  add_gettimeofday (&ict->ict_context->timer_a_start,                    ict->ict_context->timer_a_length);  /* retransmit REQUEST */  i =    osip->cb_send_message (ict, ict->orig_request,                           ict->ict_context->destination,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -