Ejemplo n.º 1
0
void
eXosip_subscribe_free (eXosip_subscribe_t * js)
{
  /* ... */

  eXosip_dialog_t *jd;

  if (js->s_inc_tr != NULL && js->s_inc_tr->orig_request != NULL
      && js->s_inc_tr->orig_request->call_id != NULL
      && js->s_inc_tr->orig_request->call_id->number != NULL)
    _eXosip_delete_nonce (js->s_inc_tr->orig_request->call_id->number);
  else if (js->s_out_tr != NULL && js->s_out_tr->orig_request != NULL
           && js->s_out_tr->orig_request->call_id != NULL
           && js->s_out_tr->orig_request->call_id->number != NULL)
    _eXosip_delete_nonce (js->s_out_tr->orig_request->call_id->number);

  for (jd = js->s_dialogs; jd != NULL; jd = js->s_dialogs)
    {
      REMOVE_ELEMENT (js->s_dialogs, jd);
      eXosip_dialog_free (jd);
    }

  __eXosip_delete_jinfo (js->s_inc_tr);
  __eXosip_delete_jinfo (js->s_out_tr);
  if (js->s_inc_tr != NULL)
    osip_list_add (&eXosip.j_transactions, js->s_inc_tr, 0);
  if (js->s_out_tr != NULL)
    osip_list_add (&eXosip.j_transactions, js->s_out_tr, 0);

  osip_free (js);
}
Ejemplo n.º 2
0
void
eXosip_call_free(eXosip_call_t *jc)
{
  /* ... */

  eXosip_dialog_t *jd;

  for (jd = jc->c_dialogs; jd!=NULL; jd=jc->c_dialogs)
    {
      REMOVE_ELEMENT(jc->c_dialogs, jd);
      eXosip_dialog_free(jd);
    }

  __eXosip_delete_jinfo(jc->c_inc_tr);
  __eXosip_delete_jinfo(jc->c_out_tr);
  if (jc->c_inc_tr!=NULL)
    osip_list_add_nodup(eXosip.j_transactions, jc->c_inc_tr, 0);
  if (jc->c_out_tr!=NULL)
    osip_list_add_nodup(eXosip.j_transactions, jc->c_out_tr, 0);

  __eXosip_delete_jinfo(jc->c_inc_options_tr);
  __eXosip_delete_jinfo(jc->c_out_options_tr);
  if (jc->c_inc_options_tr!=NULL)
    osip_list_add_nodup(eXosip.j_transactions, jc->c_inc_options_tr, 0);
  if (jc->c_out_options_tr!=NULL)
    osip_list_add_nodup(eXosip.j_transactions, jc->c_out_options_tr, 0);
  

  osip_negotiation_ctx_free(jc->c_ctx);
  osip_free(jc);

}
Ejemplo n.º 3
0
void
eXosip_notify_free (eXosip_notify_t * jn)
{
  /* ... */

  eXosip_dialog_t *jd;

  for (jd = jn->n_dialogs; jd != NULL; jd = jn->n_dialogs)
    {
      REMOVE_ELEMENT (jn->n_dialogs, jd);
      eXosip_dialog_free (jd);
    }

  __eXosip_delete_jinfo (jn->n_inc_tr);
  __eXosip_delete_jinfo (jn->n_out_tr);
  if (jn->n_inc_tr != NULL)
    osip_list_add (eXosip.j_transactions, jn->n_inc_tr, 0);
  if (jn->n_out_tr != NULL)
    osip_list_add (eXosip.j_transactions, jn->n_out_tr, 0);
  osip_free (jn);
}
Ejemplo n.º 4
0
void
eXosip_subscribe_free(eXosip_subscribe_t *js)
{
  /* ... */

  eXosip_dialog_t *jd;

  for (jd = js->s_dialogs; jd!=NULL; jd=js->s_dialogs)
    {
      REMOVE_ELEMENT(js->s_dialogs, jd);
      eXosip_dialog_free(jd);
    }

  __eXosip_delete_jinfo(js->s_inc_tr);
  __eXosip_delete_jinfo(js->s_out_tr);
  if (js->s_inc_tr!=NULL)
    osip_list_add(eXosip.j_transactions, js->s_inc_tr, 0);
  if (js->s_out_tr!=NULL)
    osip_list_add(eXosip.j_transactions, js->s_out_tr, 0);

  osip_free(js);
}
Ejemplo n.º 5
0
int
_eXosip_call_retry_request (eXosip_call_t * jc,
                            eXosip_dialog_t * jd, osip_transaction_t * out_tr)
{
  osip_transaction_t *tr = NULL;
  osip_message_t *msg = NULL;
  osip_event_t *sipevent;

  int cseq;
  osip_via_t *via;
  osip_contact_t *co;
  int pos;
  int i;
  int protocol = IPPROTO_UDP;

  if (jc == NULL)
    return OSIP_BADPARAMETER;
  if (jd != NULL)
    {
      if (jd->d_out_trs == NULL)
        return OSIP_BADPARAMETER;
    }
  if (out_tr == NULL
      || out_tr->orig_request == NULL || out_tr->last_response == NULL)
    return OSIP_BADPARAMETER;

  i = osip_message_clone (out_tr->orig_request, &msg);
  if (i != 0)
    {
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: could not clone msg for authentication\n"));
      return i;
    }

  via = (osip_via_t *) osip_list_get (&msg->vias, 0);
  if (via == NULL || msg->cseq == NULL || msg->cseq->number == NULL)
    {
      osip_message_free (msg);
      OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_ERROR, NULL,
                   "eXosip: missing via or cseq header\n"));
      return OSIP_SYNTAXERROR;
    }

  if (MSG_IS_STATUS_3XX (out_tr->last_response))
    {
      co = NULL;
      pos = 0;
      while (!osip_list_eol (&out_tr->last_response->contacts, pos))
        {
          co =
            (osip_contact_t *) osip_list_get (&out_tr->last_response->contacts,
                                              pos);
          if (co != NULL && co->url != NULL)
            {
              /* check tranport? Only allow UDP, right now */
              osip_uri_param_t *u_param;
              int pos2;

              u_param = NULL;
              pos2 = 0;
              while (!osip_list_eol (&co->url->url_params, pos2))
                {
                  u_param =
                    (osip_uri_param_t *) osip_list_get (&co->url->url_params,
                                                        pos2);
                  if (u_param == NULL || u_param->gname == NULL
                      || u_param->gvalue == NULL)
                    {
                      u_param = NULL;
                      /* skip */
                  } else if (0 == osip_strcasecmp (u_param->gname, "transport"))
                    {
                      if (0 == osip_strcasecmp (u_param->gvalue, "udp"))
                        {
                          u_param = NULL;
                          protocol = IPPROTO_UDP;
                          break;        /* ok */
                      } else if (0 == osip_strcasecmp (u_param->gvalue, "tcp"))
                        {
                          protocol = IPPROTO_TCP;
                          u_param = NULL;
                        }
                      break;
                    }
                  pos2++;
                }

              if (u_param == NULL || u_param->gname == NULL
                  || u_param->gvalue == NULL)
                {
                  break;        /* default is udp! */
                }
            }
          pos++;
          co = NULL;
        }

      if (co == NULL || co->url == NULL)
        {
          osip_message_free (msg);
          OSIP_TRACE (osip_trace
                      (__FILE__, __LINE__, OSIP_ERROR, NULL,
                       "eXosip: contact header\n"));
          return OSIP_SYNTAXERROR;
        }

      /* TODO:
         remove extra parameter from new request-uri
         check usual parameter like "transport"
       */

      if (msg->req_uri != NULL && msg->req_uri->host != NULL
          && co->url->host != NULL
          && 0 == osip_strcasecmp (co->url->host, msg->req_uri->host))
        {
          osip_uri_param_t *maddr_param = NULL;
          osip_uri_uparam_get_byname (co->url, "maddr", &maddr_param);
          if (maddr_param != NULL && maddr_param->gvalue != NULL)
            {
              /* This is a redirect server, the route should probably be removed? */
              osip_route_t *route = NULL;
              osip_generic_param_t *tag = NULL;
              osip_message_get_route (msg, 0, &route);
              if (route != NULL)
                {
                  osip_to_get_tag (msg->to, &tag);
                  if (tag == NULL && route != NULL && route->url != NULL)
                    {
                      osip_list_remove (&msg->routes, 0);
                      osip_route_free (route);
                    }
                }
            }
        }

      /* replace request-uri with NEW contact address */
      osip_uri_free (msg->req_uri);
      msg->req_uri = NULL;
      osip_uri_clone (co->url, &msg->req_uri);

      /* support for diversions headers/draft! */
      {
        int count = 0;
        pos = 0;
        while (!osip_list_eol (&out_tr->last_response->headers, pos))
          {
            osip_header_t *copy = NULL;
            osip_header_t *head =
              osip_list_get (&out_tr->last_response->headers, pos);
            if (head != NULL && 0 == osip_strcasecmp (head->hname, "diversion"))
              {
                i = osip_header_clone (head, &copy);
                if (i == 0)
                  {
                    osip_list_add (&msg->headers, copy, count);
                    count++;
                  }
              }
            pos++;
          }
      }

    }
  /* remove all previous authentication headers */
  osip_list_special_free (&msg->authorizations,
                          (void *(*)(void *)) &osip_authorization_free);
  osip_list_special_free (&msg->proxy_authorizations,
                          (void *(*)(void *)) &osip_proxy_authorization_free);

  /* increment cseq */
  cseq = atoi (msg->cseq->number);
  osip_free (msg->cseq->number);
  msg->cseq->number = strdup_printf ("%i", cseq + 1);
  if (jd != NULL && jd->d_dialog != NULL)
    {
      jd->d_dialog->local_cseq++;
    }

  i = eXosip_update_top_via (msg);
  if (i != 0)
    {
      osip_message_free (msg);
      return i;
    }

  if (out_tr->last_response->status_code == 401
      || out_tr->last_response->status_code == 407)
    eXosip_add_authentication_information (msg, out_tr->last_response);
  else
    eXosip_add_authentication_information (msg, NULL);
  osip_message_force_update (msg);

  if (0 != osip_strcasecmp (msg->sip_method, "INVITE"))
    {
      i = _eXosip_transaction_init (&tr, NICT, eXosip.j_osip, msg);
  } else
    {
      i = _eXosip_transaction_init (&tr, ICT, eXosip.j_osip, msg);
    }

  if (i != 0)
    {
      osip_message_free (msg);
      return i;
    }

  if (out_tr == jc->c_out_tr)
    {
      /* replace with the new tr */
      osip_list_add (&eXosip.j_transactions, jc->c_out_tr, 0);
      jc->c_out_tr = tr;

      /* fix dialog issue */
      if (jd != NULL)
        {
          REMOVE_ELEMENT (jc->c_dialogs, jd);
          eXosip_dialog_free (jd);
          jd = NULL;
        }
  } else
    {
      /* add the new tr for the current dialog */
      osip_list_add (jd->d_out_trs, tr, 0);
    }

  sipevent = osip_new_outgoing_sipmessage (msg);

#ifndef MINISIZE
  osip_transaction_set_your_instance (tr, __eXosip_new_jinfo (jc, jd, NULL, NULL));
#else
  osip_transaction_set_your_instance (tr, __eXosip_new_jinfo (jc, jd));
#endif
  osip_transaction_add_event (tr, sipevent);

  eXosip_update ();             /* fixed? */
  __eXosip_wakeup ();
  return OSIP_SUCCESS;
}