コード例 #1
0
ファイル: osip_dialog.c プロジェクト: smx-smx/dsl-n55u
int
osip_dialog_update_route_set_as_uac (osip_dialog_t * dialog, osip_message_t * response)
{
    /* only the remote target URI is updated here... */
    osip_contact_t *contact;
    int i;

    if (osip_list_eol (response->contacts, 0))
    {   /* no contact header in response? */
        OSIP_TRACE (osip_trace
                    (__FILE__, __LINE__, OSIP_WARNING, NULL,
                     "missing a contact in response!\n"));
    }
    else
    {
        /* I personally think it's a bad idea to keep the old
        value in case the new one is broken... */
        if (dialog->remote_contact_uri != NULL)
        {
            osip_contact_free (dialog->remote_contact_uri);
        }
        dialog->remote_contact_uri = NULL;
        contact = osip_list_get (response->contacts, 0);
        i = osip_contact_clone (contact, &(dialog->remote_contact_uri));
        if (i != 0)
            return -1;
    }

    if (dialog->state == DIALOG_EARLY && osip_list_size (dialog->route_set) == 0)
    {   /* update the route set */
        int pos = 0;

        while (!osip_list_eol (response->record_routes, pos))
        {
            osip_record_route_t *rr;
            osip_record_route_t *rr2;

            rr = (osip_record_route_t *) osip_list_get (response->record_routes, pos);
            i = osip_record_route_clone (rr, &rr2);
            if (i != 0)
                return -1;
            osip_list_add (dialog->route_set, rr2, -1);
            pos++;
        }
    }

    if (MSG_IS_STATUS_2XX (response))
        dialog->state = DIALOG_CONFIRMED;
    return 0;
}
コード例 #2
0
static int
_eXosip_redirect (eXosip_event_t * je)
{
  switch (je->type)
    {
      case EXOSIP_CALL_REDIRECTED:
        return _eXosip_redirect_invite (je);

      case EXOSIP_CALL_MESSAGE_REDIRECTED:
      case EXOSIP_MESSAGE_REDIRECTED:
      case EXOSIP_SUBSCRIPTION_REDIRECTED:
        OSIP_TRACE (osip_trace
                    (__FILE__, __LINE__, OSIP_ERROR, NULL,
                     "eXosip: not implemented\n"));
        return -1;

      default:
        OSIP_TRACE (osip_trace
                    (__FILE__, __LINE__, OSIP_ERROR, NULL,
                     "eXosip: Can't redirect event %d\n", je->type));
        return -1;
    }
}
コード例 #3
0
ファイル: pplpipe.c プロジェクト: gozfree/src
PPL_DECLARE (ppl_pipe_t *) ppl_pipe ()
{
	ppl_pipe_t *my_pipe;
	int i;

	my_pipe = (ppl_pipe_t *) osip_malloc (sizeof (ppl_pipe_t));
	if (my_pipe==NULL)
	{
		OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL,
			"Failed to allocate pipe!\n"));
		return NULL;
	}

	i = CreatePipe(my_pipe->pipes[0], my_pipe->pipes[1], NULL, 0);
	if (i!=0)
	{
	  OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL,
				  "Failed to create pipe!\n"));
      osip_free (my_pipe);
	  return NULL;
	}
	return my_pipe;
}
コード例 #4
0
static int
__osip_message_startline_to_str (osip_message_t * sip, char **dest)
{

  if (sip->sip_method != NULL)
    return __osip_message_startline_to_strreq (sip, dest);
  if (sip->status_code != 0)
    return __osip_message_startline_to_strresp (sip, dest);

  OSIP_TRACE (osip_trace
              (__FILE__, __LINE__, TRACE_LEVEL1, NULL,
               "ERROR method has no value or status code is 0!\n"));
  return -1;                    /* should never come here */
}
コード例 #5
0
ファイル: jreg.c プロジェクト: tws67/bayonne-base-windows
void
eXosip_reg_free (eXosip_reg_t * jreg)
{

  osip_free (jreg->r_aor);
  osip_free (jreg->r_contact);
  osip_free (jreg->r_registrar);

  if (jreg->r_last_tr != NULL)
    {
	  if (jreg->r_last_tr!=NULL && jreg->r_last_tr->orig_request!=NULL
		  && jreg->r_last_tr->orig_request->call_id!=NULL
		  && jreg->r_last_tr->orig_request->call_id->number!=NULL)
		  _eXosip_delete_nonce(jreg->r_last_tr->orig_request->call_id->number);

      if (jreg->r_last_tr->state == IST_TERMINATED ||
          jreg->r_last_tr->state == ICT_TERMINATED ||
          jreg->r_last_tr->state == NICT_TERMINATED ||
          jreg->r_last_tr->state == NIST_TERMINATED)
        {
          OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                  "Release a terminated transaction\n"));
          __eXosip_delete_jinfo (jreg->r_last_tr);
          if (jreg->r_last_tr != NULL)
            osip_list_add (eXosip.j_transactions, jreg->r_last_tr, 0);
      } else
        {
          OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                  "Release a non-terminated transaction\n"));
          __eXosip_delete_jinfo (jreg->r_last_tr);
          if (jreg->r_last_tr != NULL)
            osip_list_add (eXosip.j_transactions, jreg->r_last_tr, 0);
        }
    }

  osip_free (jreg);
}
コード例 #6
0
int
__osip_find_next_crlf (const char *start_of_header, const char **end_of_header)
{
  const char *soh = start_of_header;

  *end_of_header = NULL;        /* AMD fix */

  while (('\r' != *soh) && ('\n' != *soh)) {
    if (*soh)
      soh++;
    else {
      OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Final CRLF is missing\n"));
      return OSIP_SYNTAXERROR;
    }
  }

  if (('\r' == soh[0]) && ('\n' == soh[1]))
    /* case 1: CRLF is the separator
       case 2 or 3: CR or LF is the separator */
    soh = soh + 1;


  /* VERIFY if TMP is the end of header or LWS.            */
  /* LWS are extra SP, HT, CR and LF contained in headers. */
  if ((' ' == soh[1]) || ('\t' == soh[1])) {
    /* From now on, incoming message that potentially
       contains LWS must be processed with
       -> void osip_util_replace_all_lws(char *)
       This is because the parser methods does not
       support detection of LWS inside. */
    OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_BUG, NULL, "Message that contains LWS must be processed with osip_util_replace_all_lws(char *tmp) before being parsed.\n"));
    return -2;
  }

  *end_of_header = soh + 1;
  return OSIP_SUCCESS;
}
コード例 #7
0
int
msg_set_header (sip_t * sip, char *hname, char *hvalue)
{
  int my_index;

  if (hname == NULL)
    return -1;
  stolowercase (hname);

  /* some headers are analysed completely      */
  /* this method is used for selective parsing */
  my_index = parser_isknownheader (hname);
  if (my_index >= 0)		/* ok */
    {
      int ret;

      ret = parser_callmethod (my_index, sip, hvalue);
      if (ret == -1)
	{
	  OSIP_TRACE (osip_trace
		      (__FILE__, __LINE__, OSIP_ERROR, NULL,
		       "Could not set header: \"%s\" %s\n", hname, hvalue));
	  return -1;
	}
      return 0;
    }
  /* unknownheader */
  if (msg_setheader (sip, hname, hvalue) == -1)
    {
      OSIP_TRACE (osip_trace
		  (__FILE__, __LINE__, OSIP_ERROR, NULL,
		   "Could not set unknown header\n"));
      return -1;
    }

  return 0;
}
コード例 #8
0
ファイル: ist.c プロジェクト: Christof0113/rtsp-tools
int
__osip_ist_init (osip_ist_t ** ist, osip_t * osip, osip_message_t * invite)
{
  int i;

  OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "allocating IST context\n"));

  *ist = (osip_ist_t *) osip_malloc (sizeof (osip_ist_t));
  if (*ist == NULL)
    return OSIP_NOMEM;
  memset (*ist, 0, sizeof (osip_ist_t));
  /* for INVITE retransmissions */
  {
    osip_via_t *via;
    char *proto;

    i = osip_message_get_via (invite, 0, &via); /* get top via */
    if (i < 0) {
      osip_free (*ist);
      *ist = NULL;
      return i;
    }
    proto = via_get_protocol (via);
    if (proto == NULL) {
      osip_free (*ist);
      *ist = NULL;
      return OSIP_UNDEFINED_ERROR;
    }

    if (osip_strcasecmp (proto, "TCP") != 0 && osip_strcasecmp (proto, "TLS") != 0 && osip_strcasecmp (proto, "SCTP") != 0) {   /* for other reliable protocol than TCP, the timer
                                                                                                                                   must be desactived by the external application */
      (*ist)->timer_g_length = DEFAULT_T1;
      (*ist)->timer_i_length = DEFAULT_T4;
      (*ist)->timer_g_start.tv_sec = -1;        /* not started */
      (*ist)->timer_i_start.tv_sec = -1;        /* not started */
    }
    else {                      /* reliable protocol is used: */
      (*ist)->timer_g_length = -1;      /* A is not ACTIVE */
      (*ist)->timer_i_length = 0;       /* MUST do the transition immediatly */
      (*ist)->timer_g_start.tv_sec = -1;        /* not started */
      (*ist)->timer_i_start.tv_sec = -1;        /* not started */
    }
  }

  (*ist)->timer_h_length = 64 * DEFAULT_T1;
  (*ist)->timer_h_start.tv_sec = -1;    /* not started */

  return OSIP_SUCCESS;
}
コード例 #9
0
static int
_eXosip_retry_publish_with_auth (eXosip_event_t * je)
{
  eXosip_pub_t *jp = NULL;

  if (_eXosip_pub_find_by_tid (&jp, je->tid) < 0)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: publish transaction not found\n"));
      return -1;
    }

  return _eXosip_retry_with_auth (NULL, &jp->p_last_tr, NULL);
}
コード例 #10
0
static int
startline_parseresp (startline_t * dest, char *buf, char **headers)
{
  char *statuscode;
  char *reasonphrase;

  dest->rquri = NULL;
  dest->sipmethod = NULL;

  *headers = buf;

  statuscode = strchr (buf, ' ');	/* search for first SPACE */
  if (statuscode == NULL)
    return -1;
  dest->sipversion = (char *) smalloc (statuscode - (*headers) + 1);
  sstrncpy (dest->sipversion, *headers, statuscode - (*headers));

  reasonphrase = strchr (statuscode + 1, ' ');
  dest->statuscode = (char *) smalloc (reasonphrase - statuscode);
  sstrncpy (dest->statuscode, statuscode + 1, reasonphrase - statuscode - 1);

  {
    char *hp = reasonphrase;

    while ((*hp != '\r') && (*hp != '\n'))
      {
	if (*hp)
	  hp++;
	else
	  {
	    OSIP_TRACE (osip_trace
			(__FILE__, __LINE__, OSIP_ERROR, NULL,
			 "No crlf found\n"));
	    return -1;
	  }
      }
    dest->reasonphrase = (char *) smalloc (hp - reasonphrase);
    sstrncpy (dest->reasonphrase, reasonphrase + 1, hp - reasonphrase - 1);

    hp++;
    if ((*hp) && ('\r' == hp[-1]) && ('\n' == hp[0]))
      hp++;
    (*headers) = hp;
  }
  return 0;
}
コード例 #11
0
ファイル: port_thread.c プロジェクト: Nymphetaminer/dsl-n55u
struct osip_thread *
osip_thread_create (int stacksize, void *(*func) (void *), void *arg)
{
  int i;
  osip_thread_t *thread = (osip_thread_t *) osip_malloc (sizeof (osip_thread_t));
  if (thread==NULL) return NULL;

  i = pthread_create (thread, NULL, func, (void *) arg);
  if (i != 0)
    {
      OSIP_TRACE (osip_trace
		  (__FILE__, __LINE__, OSIP_ERROR, NULL,
		   "Error while creating a new thread\n"));
      return NULL;
    }
  return (struct osip_thread*)thread;
}
コード例 #12
0
ファイル: eXpublish_api.c プロジェクト: Distrotech/exosip
int
eXosip_build_publish (struct eXosip_t *excontext, osip_message_t ** message, const char *to, const char *from, const char *route, const char *event, const char *expires, const char *ctype, const char *body)
{
  int i;

  *message = NULL;

  if (to == NULL || to[0] == '\0')
    return OSIP_BADPARAMETER;
  if (from == NULL || from[0] == '\0')
    return OSIP_BADPARAMETER;
  if (event == NULL || event[0] == '\0')
    return OSIP_BADPARAMETER;
  if (ctype == NULL || ctype[0] == '\0') {
    if (body != NULL && body[0] != '\0')
      return OSIP_BADPARAMETER;
  }
  else {
    if (body == NULL || body[0] == '\0')
      return OSIP_BADPARAMETER;
  }

  i = _eXosip_generating_publish (excontext, message, to, from, route);
  if (i != 0) {
    OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot send message (cannot build PUBLISH)! "));
    return i;
  }

  if (body != NULL && body[0] != '\0' && ctype != NULL && ctype[0] != '\0') {
    osip_message_set_content_type (*message, ctype);
    osip_message_set_body (*message, body, strlen (body));
    /*
       osip_message_set_header (*message, "Content-Disposition",
       "render;handling=required");
     */
  }
  if (expires != NULL && expires[0] != '\0')
    osip_message_set_expires (*message, expires);
  else
    osip_message_set_expires (*message, "3600");

  osip_message_set_header (*message, "Event", event);

  return OSIP_SUCCESS;
}
コード例 #13
0
ファイル: misc.c プロジェクト: HunterChen/exosip
int
_eXosip_remove_transaction_from_call (osip_transaction_t * tr, eXosip_call_t * jc)
{
  osip_transaction_t *inc_tr;
  osip_transaction_t *out_tr;
  eXosip_dialog_t *jd;
  int pos = 0;

  if (jc->c_inc_tr == tr) {
    jc->c_inc_tr = NULL;        /* can be NULL */
    return OSIP_SUCCESS;
  }

  for (jd = jc->c_dialogs; jd != NULL; jd = jd->next) {
    pos = 0;
    while (!osip_list_eol (jd->d_inc_trs, pos)) {
      inc_tr = osip_list_get (jd->d_inc_trs, pos);
      if (inc_tr == tr) {
        osip_list_remove (jd->d_inc_trs, pos);
        return OSIP_SUCCESS;
      }
      pos++;
    }
  }

  if (jc->c_out_tr == tr) {
    jc->c_out_tr = NULL;        /* can be NULL */
    return OSIP_SUCCESS;
  }

  for (jd = jc->c_dialogs; jd != NULL; jd = jd->next) {
    pos = 0;
    while (!osip_list_eol (jd->d_out_trs, pos)) {
      out_tr = osip_list_get (jd->d_out_trs, pos);
      if (out_tr == tr) {
        osip_list_remove (jd->d_out_trs, pos);
        return OSIP_SUCCESS;
      }
      pos++;
    }
  }

  OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "eXosip: No information.\n"));
  return OSIP_NOTFOUND;
}
コード例 #14
0
ファイル: osip_dialog.c プロジェクト: smx-smx/dsl-n55u
int
osip_dialog_update_tag_as_uac (osip_dialog_t * dialog, osip_message_t * response)
{
    osip_generic_param_t *tag;
    int i;

    i = osip_to_get_tag (response->to, &tag);
    if (i != 0)
    {
        OSIP_TRACE (osip_trace
                    (__FILE__, __LINE__, OSIP_WARNING, NULL,
                     "Remote UA is not compliant: missing a tag in response!\n"));
        dialog->remote_tag = NULL;
    }
    else
        dialog->remote_tag = osip_strdup (tag->gvalue);
    return 0;
}
コード例 #15
0
ファイル: main.c プロジェクト: usamaaftab80/multi-p2p
int main()
{
	int i,result;
	fd_set readfds;
	struct timeval tv;
	printf("Initializing OSIP\n");
	TRACE_INITIALIZE(END_TRACE_LEVEL,NULL);
	if(networkInit() < 0){
		printf("ERROR Initializing NETWORK\n");
		return -1;
	}
	i=osip_init(&osip);
	if (i!=0)
		return -1;
	printf("Setting Callbacks\n");
	setCallbacks(osip);
	printf("Entering Main loop 1\n");
	OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"Check OSIP_TRACE init\n"));
	bSipRegister("This is Test Cookie");
	while(1){
		FD_ZERO(&readfds);
		FD_SET(sipSock,&readfds);
		tv.tv_sec = 0;
		tv.tv_usec = 100000;
		result = select(FD_SETSIZE,&readfds,0,0,&tv);
		if(result < 0){
			perror("main: select error");
			exit(1);
		}
		if(FD_ISSET(sipSock,&readfds)){
			printf("main: Received SIP message\n");
			processSipMsg();
		}
		osip_ict_execute(osip);
		osip_ist_execute(osip);
		osip_nict_execute(osip);
		osip_nist_execute(osip);
		osip_timers_ict_execute(osip);
		osip_timers_ist_execute(osip);
		osip_timers_nict_execute(osip);
		osip_timers_nist_execute(osip);
	}
	return 0;
}
コード例 #16
0
ファイル: port_fifo.c プロジェクト: Nymphetaminer/dsl-n55u
void *
osip_fifo_tryget (osip_fifo_t * ff)
{
  void *el;

#ifdef OSIP_MT
  if (0 != osip_sem_trywait (ff->qisempty))
    {				/* no elements... */
      return NULL;
    }
  osip_mutex_lock (ff->qislocked);
#else
  if (ff->etat == vide)
    return NULL;
#endif

  if (ff->etat != vide)
    {
      el = osip_list_get (ff->queue, 0);
      osip_list_remove (ff->queue, 0);
      /* ff->nb_elt--; */
    }
#ifdef OSIP_MT
  else
    {				/* this case MUST never happen... */
      OSIP_TRACE (osip_trace
		  (__FILE__, __LINE__, OSIP_INFO4, NULL,
		   "no element in fifo.\n"));
      osip_mutex_unlock (ff->qislocked);
      return 0;
    }
#endif

  /* if (ff->nb_elt <= 0) */
  if (osip_list_size (ff->queue) <= 0)
    ff->etat = vide;
  else
    ff->etat = ok;

#ifdef OSIP_MT
  osip_mutex_unlock (ff->qislocked);
#endif
  return el;
}
コード例 #17
0
int
eXosip_register_build_register (int rid, int expires, osip_message_t ** reg)
{
  eXosip_reg_t *jr;
  int i;

  *reg = NULL;

  if (rid <= 0)
    return OSIP_BADPARAMETER;

  jr = eXosip_reg_find (rid);
  if (jr == NULL)
    return OSIP_NOTFOUND;
  jr->r_reg_period = expires;
  if (jr->r_reg_period == 0)
    {
    } /* unregistration */
  else if (jr->r_reg_period > 3600)
    jr->r_reg_period = 3600;
  else if (jr->r_reg_period < 100)      /* too low */
    jr->r_reg_period = 100;

  if (jr->r_last_tr != NULL)
    {
      if (jr->r_last_tr->state != NICT_TERMINATED
          && jr->r_last_tr->state != NICT_COMPLETED)
        {
          return OSIP_WRONG_STATE;
        }
    }

  i = _eXosip_register_build_register (jr, reg);
  if (i != 0)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: cannot build REGISTER!"));
      *reg = NULL;
      return i;
    }
  return OSIP_SUCCESS;
}
コード例 #18
0
ファイル: nist.c プロジェクト: tws67/bayonne-base-windows
int
__osip_nist_init (osip_nist_t ** nist, osip_t * osip, osip_message_t * invite)
{
  int i;

  OSIP_TRACE (osip_trace
              (__FILE__, __LINE__, OSIP_INFO2, NULL, "allocating NIST context\n"));

  *nist = (osip_nist_t *) osip_malloc (sizeof (osip_nist_t));
  if (*nist == NULL)
    return -1;
  memset (*nist, 0, sizeof (osip_nist_t));
  /* for INVITE retransmissions */
  {
    osip_via_t *via;
    char *proto;

    i = osip_message_get_via (invite, 0, &via); /* get top via */
    if (i != 0)
      goto ii_error_1;
    proto = via_get_protocol (via);
    if (proto == NULL)
      goto ii_error_1;

    if (osip_strcasecmp (proto, "TCP") != 0
        && osip_strcasecmp (proto, "TLS") != 0
        && osip_strcasecmp (proto, "SCTP") != 0)
      {
        (*nist)->timer_j_length = 64 * DEFAULT_T1;
        (*nist)->timer_j_start.tv_sec = -1;     /* not started */
    } else
      {                         /* reliable protocol is used: */
        (*nist)->timer_j_length = 0;    /* MUST do the transition immediatly */
        (*nist)->timer_j_start.tv_sec = -1;     /* not started */
      }
  }

  return 0;

ii_error_1:
  osip_free (*nist);
  return -1;
}
コード例 #19
0
ファイル: sdp_offans.c プロジェクト: HunterChen/exosip
sdp_message_t *
eXosip_get_local_sdp_from_tid (struct eXosip_t * excontext, int tid)
{
  eXosip_dialog_t *jd = NULL;
  eXosip_call_t *jc = NULL;
  osip_transaction_t *tr = NULL;

  if (tid > 0) {
    _eXosip_call_transaction_find (excontext, tid, &jc, &jd, &tr);
  }
  if (jc == NULL) {
    OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: No call here?\n"));
    return NULL;
  }
  if (tr == NULL)
    return NULL;

  return _eXosip_get_local_sdp (tr);
}
コード例 #20
0
int
eXosip_register_build_register (int rid, int expires, osip_message_t ** reg)
{
    eXosip_reg_t *jr;
    int i;

    *reg = NULL;
    jr = eXosip_reg_find (rid);
    if (jr == NULL)
    {
        /* fprintf(stderr, "eXosip: no registration info saved!\n"); */
        return -1;
    }
    jr->r_reg_period = expires;
    if (jr->r_reg_period == 0)
    {
    } /* unregistration */
    else if (jr->r_reg_period > 3600)
        jr->r_reg_period = 3600;
    else if (jr->r_reg_period < 100)      /* too low */
        jr->r_reg_period = 100;

    if (jr->r_last_tr != NULL)
    {
        if (jr->r_last_tr->state != NICT_TERMINATED
                && jr->r_last_tr->state != NICT_COMPLETED)
        {
            /* fprintf(stderr, "eXosip: a registration is already pending!\n"); */
            return -1;
        }
    }

    i = _eXosip_register_build_register (jr, reg);
    if (i != 0)
    {
        OSIP_TRACE (osip_trace
                    (__FILE__, __LINE__, OSIP_ERROR, NULL,
                     "eXosip: cannot build REGISTER!"));
        *reg = NULL;
        return i;
    }
    return 0;
}
コード例 #21
0
static int
_eXosip_retry_notify_with_auth (eXosip_event_t * je)
{
  /* TODO untested */
  eXosip_dialog_t *jd = NULL;
  eXosip_notify_t *jn = NULL;
  osip_transaction_t *tr=NULL;

  if (_eXosip_insubscription_transaction_find (je->tid, &jn, &jd, &tr) < 0)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: notify dialog not found\n"));
      return -1;
    }

  return _eXosip_insubscription_send_request_with_credential (jn, jd, tr);

}
コード例 #22
0
void
eXosip_retransmit_lost200ok()
{
	eXosip_call_t *jc;
	eXosip_dialog_t *jd;
	time_t now;

	now = time (NULL);

	for (jc = eXosip.j_calls; jc != NULL; jc = jc->next)
	{
		if (jc->c_id >= 1 && jc->c_dialogs != NULL)
		{
			for (jd = jc->c_dialogs; jd != NULL; jd = jd->next)
			{
				if (jd->d_id >=1 && jd->d_dialog != NULL && jd->d_200Ok!=NULL)
				{
					if (jd->d_count==5)
					{
						OSIP_TRACE (osip_trace
									(__FILE__, __LINE__, OSIP_ERROR, NULL,
									"eXosip: no ACK received during 20s: dropping call\n"));
						/* hard for users to detect than I sent this BYE... */
						jd->d_count=0;
						osip_message_free(jd->d_200Ok);
						jd->d_200Ok=NULL;
						eXosip_call_terminate(jc->c_id, jd->d_id);
					}
					else if (jd->d_timer<now)
					{
						/* a dialog exist: retransmit lost 200ok */
						jd->d_timer = time (NULL) + 4;
						jd->d_count++;
						jd = jc->c_dialogs;
						/* TU retransmission */
						cb_snd_message (NULL, jd->d_200Ok, NULL,0, -1);
					}
				}
			}
		}
	}
	return;
}
コード例 #23
0
static int
_eXosip_redirect_invite (eXosip_event_t * je)
{
  eXosip_dialog_t *jd = NULL;
  eXosip_call_t *jc = NULL;
  osip_transaction_t *tr=NULL;

  _eXosip_call_transaction_find (je->tid, &jc,
				 &jd, &tr);
  if (jc==NULL)
    {
      OSIP_TRACE (osip_trace
		  (__FILE__, __LINE__, OSIP_ERROR, NULL,
		   "eXosip: call dialog not found\n"));
      return -1;
    }
  
  return _eXosip_call_retry_request (jc, jd, tr);
}
コード例 #24
0
ファイル: eXtl_udp.c プロジェクト: github188/Sip-MCU
static int
udp_tl_keepalive (void)
{
  char buf[6] = "Ping.";
  eXosip_reg_t *jr;
  for (jr = eXosip.j_reg; jr != NULL; jr = jr->next)
    {
      if (jr->len > 0)
        {
          if (sendto (udp_socket, (const void *) buf, 6, 0,
                      (struct sockaddr *) &(jr->addr), jr->len) > 0)
            {
              OSIP_TRACE (osip_trace
                          (__FILE__, __LINE__, OSIP_INFO1, NULL,
                           "eXosip: Keep Alive sent on UDP!\n"));
            }
        }
    }
  return OSIP_SUCCESS;
}
コード例 #25
0
ファイル: sdp_offans.c プロジェクト: HunterChen/exosip
sdp_message_t *
eXosip_get_remote_sdp (struct eXosip_t * excontext, int jid)
{
  eXosip_dialog_t *jd = NULL;
  eXosip_call_t *jc = NULL;
  osip_transaction_t *invite_tr = NULL;

  if (jid > 0) {
    _eXosip_call_dialog_find (excontext, jid, &jc, &jd);
  }
  if (jc == NULL) {
    OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: No call here?\n"));
    return NULL;
  }
  invite_tr = _eXosip_find_last_invite (jc, jd);
  if (invite_tr == NULL)
    return NULL;

  return _eXosip_get_remote_sdp (invite_tr);
}
コード例 #26
0
int
eXosip_subscribe_remove (struct eXosip_t *excontext, int did)
{
  eXosip_dialog_t *jd = NULL;
  eXosip_subscribe_t *js = NULL;

  if (did <= 0)
    return OSIP_BADPARAMETER;

  if (did > 0) {
    _eXosip_subscribe_dialog_find (excontext, did, &js, &jd);
  }
  if (js == NULL) {
    OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: No outgoing subscription here?\n"));
    return OSIP_NOTFOUND;
  }
  REMOVE_ELEMENT (excontext->j_subscribes, js);
  _eXosip_subscribe_free (excontext, js);
  return OSIP_SUCCESS;
}
コード例 #27
0
static int
dtls_tl_keepalive(void)
{
  char buf[4] = "jaK";
  eXosip_reg_t *jr;
  for (jr = eXosip.j_reg; jr != NULL; jr = jr->next)
    {
      if (jr->len > 0)
        {
          if (sendto (dtls_socket, (const void *) buf, 4, 0,
                      (struct sockaddr *) &(jr->addr), jr->len) > 0)
            {
              OSIP_TRACE (osip_trace
                          (__FILE__, __LINE__, OSIP_INFO1, NULL,
                           "eXosip: Keep Alive sent on DTLS!\n"));
            }
        }
    }
  return 0;
}
コード例 #28
0
ファイル: jpipe.c プロジェクト: Distrotech/exosip
jpipe_t *
jpipe ()
{
  jpipe_t *my_pipe = (jpipe_t *) osip_malloc (sizeof (jpipe_t));

  if (my_pipe == NULL)
    return NULL;

  if (0 != pipe (my_pipe->pipes)) {
    osip_free (my_pipe);
    return NULL;
  }

  if (fcntl (my_pipe->pipes[1], F_SETFL, O_NONBLOCK) == -1) {
    /* failed for some reason... */
    OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "cannot set O_NONBLOCK to the pipe[1]!\n"));
  }

  return my_pipe;
}
コード例 #29
0
static int
eXosip_retry_with_auth (eXosip_event_t * je)
{
  if (!je || !je->request || !je->response)
    return -1;

  if (je->rid>0)
    {
      return _eXosip_retry_register_with_auth (je);
    }
  else if (je->cid>0)
    {
      return _eXosip_retry_invite_with_auth (je);
    }
#ifndef MINISIZE
  else if (je->sid>0)
    {
      return _eXosip_retry_subscribe_with_auth (je);
    }
  else if (je->nid>0)
    {
      return _eXosip_retry_notify_with_auth (je);
    }
  else if (MSG_IS_PUBLISH (je->request))
    return _eXosip_retry_publish_with_auth (je);
#endif
  else
    {
      osip_transaction_t *tr=NULL;
      eXosip_transaction_find(je->tid, &tr);
      if (tr!=NULL)
	{
	  return _eXosip_retry_with_auth (NULL, &tr, NULL);
	}
    }

  OSIP_TRACE (osip_trace
	      (__FILE__, __LINE__, OSIP_ERROR, NULL,
	       "eXosip: Can't retry event %d with auth\n", je->type));
  return -1;
}
コード例 #30
0
static void
packet_print (struct rtp *session, rtp_packet * p)
{
  call_t *ca = (call_t *) rtp_get_userdata (session);

#ifdef USE_PCM
  char data_in_dec[1280];
#endif
  fprintf (stderr, "Received data (payload %d timestamp %06d size %d)\n",
           p->pt, p->ts, p->data_len);
  if (ca == NULL)
    {
      fprintf (stderr, "No call for current session\n");
      return;
    }
#ifdef USE_PCM

  if (p->pt == 8)               /* A-Law */
    alaw_dec (p->data, data_in_dec, p->data_len);
  if (p->pt == 0)               /* Mu-Law */
    mulaw_dec (p->data, data_in_dec, p->data_len);

  write (ca->fd, data_in_dec, p->data_len * 2);

#else
  write (ca->fd, p->data, p->data_len);
  OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL,
                          "received %i data written to the audio driver\n",
                          p->data_len));
#endif

  /*Unless filtering is enabled we are likely to see
     out packets if sending to a multicast group. */
  /*
     if (p->ssrc == rtp_my_ssrc(session)) {
     fprintf(stderr, "that I just sent.\n");
     } else {
     fprintf(stderr, "from SSRC 0x%08x\n", p->ssrc); 
     } 
   */
}