Logo Search packages:      
Sourcecode: wengophone version File versions  Download package

int osip_dialog_init_as_uac ( osip_dialog_t **  dialog,
osip_message_t response 

Allocate a osip_dialog_t element as a UAC.

  • NOTE1: Only INVITE transactions can create a dialog.
  • NOTE2: The dialog should be created when the first response is received. (except for a 100 Trying)
  • NOTE3: Remote UA should be compliant! If not (not tag in the to header?) the old mechanism is used to match the request but if 2 uncompliant UA both answer 200 OK for the same transaction, they won't be detected. This is a major BUG in the old rfc.
dialog The element to allocate.
response The response containing the informations.

Definition at line 355 of file osip_dialog.c.

References osip_message::call_id, osip_message::contacts, osip_message::cseq, osip_message::from, osip_uri_param::gvalue, MSG_IS_STATUS_2XX, osip_cseq::number, osip_call_id_to_str(), osip_contact_clone(), osip_from_clone(), osip_from_free(), osip_from_get_tag, osip_list_add(), osip_list_eol(), osip_list_get(), osip_list_init(), osip_list_special_free(), osip_record_route_clone, osip_record_route_free(), osip_to_clone(), osip_to_get_tag, osip_message::record_routes, and osip_message::to.

  int i;
  int pos;
  osip_generic_param_t *tag;

  *dialog = NULL;

  (*dialog) = (osip_dialog_t *) osip_malloc (sizeof (osip_dialog_t));
  if (*dialog == NULL)
    return -1;

  (*dialog)->type = CALLER;
  if (MSG_IS_STATUS_2XX (response))
    (*dialog)->state = DIALOG_CONFIRMED;
  else                        /* 1XX */
    (*dialog)->state = DIALOG_EARLY;

  i = osip_call_id_to_str (response->call_id, &((*dialog)->call_id));
  if (i != 0)
    goto diau_error_0;

  i = osip_from_get_tag (response->from, &tag);
  if (i != 0)
    goto diau_error_1;
  (*dialog)->local_tag = osip_strdup (tag->gvalue);

  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;
    (*dialog)->remote_tag = osip_strdup (tag->gvalue);

  (*dialog)->route_set = (osip_list_t *) osip_malloc (sizeof (osip_list_t));
  osip_list_init ((*dialog)->route_set);

  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)
      goto diau_error_2;
      osip_list_add ((*dialog)->route_set, rr2, -1);

  (*dialog)->local_cseq = osip_atoi (response->cseq->number);
  (*dialog)->remote_cseq = -1;

  i = osip_to_clone (response->to, &((*dialog)->remote_uri));
  if (i != 0)
    goto diau_error_3;

  i = osip_from_clone (response->from, &((*dialog)->local_uri));
  if (i != 0)
    goto diau_error_4;

    osip_contact_t *contact;

    if (!osip_list_eol (response->contacts, 0))
      contact = osip_list_get (response->contacts, 0);
      i = osip_contact_clone (contact, &((*dialog)->remote_contact_uri));
      if (i != 0)
        goto diau_error_5;
      (*dialog)->remote_contact_uri = NULL;
      OSIP_TRACE (osip_trace
                (__FILE__, __LINE__, OSIP_WARNING, NULL,
                 "Remote UA is not compliant: missing a contact in response!\n"));
  (*dialog)->secure = -1;     /* non secure */

  return 0;

  osip_from_free ((*dialog)->local_uri);
  osip_from_free ((*dialog)->remote_uri);
  osip_list_special_free ((*dialog)->route_set,
                    (void *(*)(void *)) &osip_record_route_free);
  osip_free ((*dialog)->remote_tag);
  osip_free ((*dialog)->local_tag);
  osip_free ((*dialog)->call_id);
  OSIP_TRACE (osip_trace
            (__FILE__, __LINE__, OSIP_ERROR, NULL,
             "Could not establish dialog!\n"));
  osip_free (*dialog);
  *dialog = NULL;
  return -1;

Generated by  Doxygen 1.6.0   Back to index