Beispiel #1
0
/* this method can't be called unless the previous
   INVITE transaction is over. */
int
eXosip_call_build_initial_invite (osip_message_t ** invite,
                                  const char *to,
                                  const char *from,
                                  const char *route, const char *subject)
{
  int i;
  osip_to_t *_to = NULL;

  *invite = NULL;

  if (to != NULL && *to == '\0')
    return OSIP_BADPARAMETER;
  if (route != NULL && *route == '\0')
    route = NULL;
  if (subject != NULL && *subject == '\0')
    subject = NULL;

  i = osip_to_init (&_to);
  if (i != 0)
    return i;

  i = osip_to_parse (_to, to);
  if (i != 0)
    {
      osip_to_free (_to);
      return i;
    }

  i = generating_request_out_of_dialog (invite, "INVITE", to,
                                        eXosip.transport, from, route);
  osip_to_free (_to);
  if (i != 0)
    return i;
  _eXosip_dialog_add_contact (*invite, NULL);

  if (subject != NULL)
    osip_message_set_subject (*invite, subject);

  /* after this delay, we should send a CANCEL */
  osip_message_set_expires (*invite, "120");
  return OSIP_SUCCESS;
}
Beispiel #2
0
void
osip_message_free (osip_message_t * sip)
{
  if (sip == NULL)
    return;

  osip_free (sip->sip_method);
  osip_free (sip->sip_version);
  if (sip->req_uri != NULL)
    osip_uri_free (sip->req_uri);
  osip_free (sip->reason_phrase);

#ifndef MINISIZE
  osip_list_special_free (&sip->accepts, (void (*)(void *)) &osip_accept_free);
#endif
  osip_list_special_free (&sip->authorizations, (void (*)(void *)) &osip_authorization_free);
  if (sip->call_id != NULL)
    osip_call_id_free (sip->call_id);
#ifndef MINISIZE
  osip_list_special_free (&sip->accept_encodings, (void (*)(void *)) &osip_accept_encoding_free);
  osip_list_special_free (&sip->accept_languages, (void (*)(void *)) &osip_accept_language_free);
  osip_list_special_free (&sip->alert_infos, (void (*)(void *)) &osip_alert_info_free);
  osip_list_special_free (&sip->allows, (void (*)(void *)) &osip_allow_free);
  osip_list_special_free (&sip->authentication_infos, (void (*)(void *)) &osip_authentication_info_free);
  osip_list_special_free (&sip->content_encodings, (void (*)(void *)) &osip_content_encoding_free);
  osip_list_special_free (&sip->error_infos, (void (*)(void *)) &osip_error_info_free);
  osip_list_special_free (&sip->proxy_authentication_infos, (void (*)(void *))
                          &osip_proxy_authentication_info_free);
#endif
  osip_list_special_free (&sip->call_infos, (void (*)(void *)) &osip_call_info_free);
  osip_list_special_free (&sip->contacts, (void (*)(void *)) &osip_contact_free);
  if (sip->content_length != NULL)
    osip_content_length_free (sip->content_length);
  if (sip->content_type != NULL)
    osip_content_type_free (sip->content_type);
  if (sip->cseq != NULL)
    osip_cseq_free (sip->cseq);
  if (sip->from != NULL)
    osip_from_free (sip->from);
  if (sip->mime_version != NULL)
    osip_mime_version_free (sip->mime_version);
  osip_list_special_free (&sip->proxy_authenticates, (void (*)(void *)) &osip_proxy_authenticate_free);
  osip_list_special_free (&sip->proxy_authorizations, (void (*)(void *)) &osip_proxy_authorization_free);
  osip_list_special_free (&sip->record_routes, (void (*)(void *)) &osip_record_route_free);
  osip_list_special_free (&sip->routes, (void (*)(void *)) &osip_route_free);
  if (sip->to != NULL)
    osip_to_free (sip->to);
  osip_list_special_free (&sip->vias, (void (*)(void *)) &osip_via_free);
  osip_list_special_free (&sip->www_authenticates, (void (*)(void *)) &osip_www_authenticate_free);
  osip_list_special_free (&sip->headers, (void (*)(void *)) &osip_header_free);
  osip_list_special_free (&sip->bodies, (void (*)(void *)) &osip_body_free);
  osip_free (sip->message);
  osip_free (sip);
}
int
eXosip_subscribe_build_initial_request (struct eXosip_t *excontext, osip_message_t ** sub, const char *to, const char *from, const char *route, const char *event, int expires)
{
  char tmp[10];
  int i;
  osip_to_t *_to = NULL;

  *sub = NULL;
  if (to == NULL || *to == '\0')
    return OSIP_BADPARAMETER;
  if (from == NULL || *from == '\0')
    return OSIP_BADPARAMETER;
  if (event == NULL || *event == '\0')
    return OSIP_BADPARAMETER;
  if (route == NULL || *route == '\0')
    route = NULL;

  i = osip_to_init (&_to);
  if (i != 0)
    return i;

  i = osip_to_parse (_to, to);
  if (i != 0) {
    osip_to_free (_to);
    return i;
  }

  i = _eXosip_generating_request_out_of_dialog (excontext, sub, "SUBSCRIBE", to, excontext->transport, from, route);
  osip_to_free (_to);
  if (i != 0)
    return i;
  _eXosip_dialog_add_contact (excontext, *sub, NULL);

  snprintf (tmp, 10, "%i", expires);
  osip_message_set_expires (*sub, tmp);

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

  return OSIP_SUCCESS;
}
Beispiel #4
0
int
main (int argc, char **argv)
{
    FILE *tos_file;


    osip_to_t *to;
    char *a_to;
    char *dest;
    char *res;

    tos_file = fopen (argv[1], "r");
    if (tos_file == NULL)
    {
        fprintf (stdout, "Failed to open %s file.\nUsage: tto tos.txt\n", argv[1]);
        exit (0);
    }

    a_to = (char *) osip_malloc (200);
    res = fgets (a_to, 200, tos_file);    /* lines are under 200 */
    while (res != NULL)
    {

        int errcode;

        /* remove the last '\n' before parsing */
        strncpy (a_to + strlen (a_to) - 1, "\0", 1);

        if (0 != strncmp (a_to, "#", 1))
        {
            /* allocate & init to */
            osip_to_init (&to);
            printf ("=================================================\n");
            printf ("TO TO PARSE: |%s|\n", a_to);
            errcode = osip_to_parse (to, a_to);
            if (errcode != -1)
            {
                if (osip_to_to_str (to, &dest) != -1)
                {
                    printf ("result:      |%s|\n", dest);
                    osip_free (dest);
                }
            } else
                printf ("Bad to format: %s\n", a_to);
            osip_to_free (to);
            printf ("=================================================\n");
        }
        res = fgets (a_to, 200, tos_file);        /* lines are under 200 */
    }
    osip_free (a_to);
    return 0;
}
void
osip_dialog_free (osip_dialog_t * dialog)
{
  if (dialog == NULL)
    return;
  osip_contact_free (dialog->remote_contact_uri);
  osip_from_free (dialog->local_uri);
  osip_to_free (dialog->remote_uri);
  osip_list_special_free (&dialog->route_set, (void (*)(void *)) &osip_record_route_free);
  osip_free (dialog->line_param);
  osip_free (dialog->remote_tag);
  osip_free (dialog->local_tag);
  osip_free (dialog->call_id);
  osip_free (dialog);
}
Beispiel #6
0
/* returns -1 on error. */
int osip_message_set_to(osip_message_t * sip, const char *hvalue)
{
	int i;

	if (hvalue == NULL || hvalue[0] == '\0')
		return OSIP_SUCCESS;

	if (sip->to != NULL)
		return OSIP_SYNTAXERROR;
	i = osip_to_init(&(sip->to));
	if (i != 0)
		return i;
	sip->message_property = 2;
	i = osip_to_parse(sip->to, hvalue);
	if (i != 0) {
		osip_to_free(sip->to);
		sip->to = NULL;
		return i;
	}
	return OSIP_SUCCESS;
}
Beispiel #7
0
/* returns -1 on error. */
int
osip_message_set_to (osip_message_t * sip, const char *hvalue)
{
  int i;

  if (hvalue == NULL || hvalue[0] == '\0')
    return 0;

  if (sip->to != NULL)
    return -1;
  i = osip_to_init (&(sip->to));
  if (i != 0)
    return -1;
  sip->message_property = 2;
  i = osip_to_parse (sip->to, hvalue);
  if (i != 0)
    {
      osip_to_free (sip->to);
      sip->to = NULL;
      return -1;
    }
  return 0;
}
Beispiel #8
0
void
osip_message_free (osip_message_t * sip)
{
    int pos = 0;

    if (sip == NULL)
        return;

    osip_free (sip->sip_method);
    osip_free (sip->sip_version);
    if (sip->req_uri != NULL)
    {
        osip_uri_free (sip->req_uri);
    }
    osip_free (sip->reason_phrase);

    {
        osip_accept_t *accept;

        while (!osip_list_eol (&sip->accepts, pos))
        {
            accept = (osip_accept_t *) osip_list_get (&sip->accepts, pos);
            osip_list_remove (&sip->accepts, pos);
            osip_accept_free (accept);
        }
    }
    {
        osip_accept_encoding_t *accept_encoding;

        while (!osip_list_eol (&sip->accept_encodings, pos))
        {
            accept_encoding =
                (osip_accept_encoding_t *) osip_list_get (&sip->accept_encodings, pos);
            osip_list_remove (&sip->accept_encodings, pos);
            osip_accept_encoding_free (accept_encoding);
        }
    }
    {
        osip_accept_language_t *accept_language;

        while (!osip_list_eol (&sip->accept_languages, pos))
        {
            accept_language =
                (osip_accept_language_t *) osip_list_get (&sip->accept_languages, pos);
            osip_list_remove (&sip->accept_languages, pos);
            osip_accept_language_free (accept_language);
        }
    }
    {
        osip_alert_info_t *alert_info;

        while (!osip_list_eol (&sip->alert_infos, pos))
        {
            alert_info = (osip_alert_info_t *) osip_list_get (&sip->alert_infos, pos);
            osip_list_remove (&sip->alert_infos, pos);
            osip_alert_info_free (alert_info);
        }
    }
    {
        osip_allow_t *al;

        while (!osip_list_eol (&sip->allows, pos))
        {
            al = (osip_allow_t *) osip_list_get (&sip->allows, pos);
            osip_list_remove (&sip->allows, pos);
            osip_allow_free (al);
        }
    }
    {
        osip_authentication_info_t *al;

        while (!osip_list_eol (&sip->authentication_infos, pos))
        {
            al =
                (osip_authentication_info_t *) osip_list_get (&sip->
                        authentication_infos, pos);
            osip_list_remove (&sip->authentication_infos, pos);
            osip_authentication_info_free (al);
        }
    }
    {
        osip_authorization_t *al;

        while (!osip_list_eol (&sip->authorizations, pos))
        {
            al = (osip_authorization_t *) osip_list_get (&sip->authorizations, pos);
            osip_list_remove (&sip->authorizations, pos);
            osip_authorization_free (al);
        }
    }
    if (sip->call_id != NULL)
    {
        osip_call_id_free (sip->call_id);
    }
    {
        osip_call_info_t *call_info;

        while (!osip_list_eol (&sip->call_infos, pos))
        {
            call_info = (osip_call_info_t *) osip_list_get (&sip->call_infos, pos);
            osip_list_remove (&sip->call_infos, pos);
            osip_call_info_free (call_info);
        }
    }
    {
        osip_contact_t *contact;

        while (!osip_list_eol (&sip->contacts, pos))
        {
            contact = (osip_contact_t *) osip_list_get (&sip->contacts, pos);
            osip_list_remove (&sip->contacts, pos);
            osip_contact_free (contact);
        }
    }
    {
        osip_content_encoding_t *ce;

        while (!osip_list_eol (&sip->content_encodings, pos))
        {
            ce =
                (osip_content_encoding_t *) osip_list_get (&sip->content_encodings, pos);
            osip_list_remove (&sip->content_encodings, pos);
            osip_content_encoding_free (ce);
        }
    }
    if (sip->content_length != NULL)
    {
        osip_content_length_free (sip->content_length);
    }
    if (sip->content_type != NULL)
    {
        osip_content_type_free (sip->content_type);
    }
    if (sip->cseq != NULL)
    {
        osip_cseq_free (sip->cseq);
    }
    {
        osip_error_info_t *error_info;

        while (!osip_list_eol (&sip->error_infos, pos))
        {
            error_info = (osip_error_info_t *) osip_list_get (&sip->error_infos, pos);
            osip_list_remove (&sip->error_infos, pos);
            osip_error_info_free (error_info);
        }
    }
    if (sip->from != NULL)
    {
        osip_from_free (sip->from);
    }
    if (sip->mime_version != NULL)
    {
        osip_mime_version_free (sip->mime_version);
    }
    {
        osip_proxy_authenticate_t *al;

        while (!osip_list_eol (&sip->proxy_authenticates, pos))
        {
            al =
                (osip_proxy_authenticate_t *) osip_list_get (&sip->
                        proxy_authenticates, pos);
            osip_list_remove (&sip->proxy_authenticates, pos);
            osip_proxy_authenticate_free (al);
        }
    }
    {
        osip_proxy_authentication_info_t *al;

        while (!osip_list_eol (&sip->proxy_authentication_infos, pos))
        {
            al =
                (osip_proxy_authentication_info_t *) osip_list_get (&sip->
                        proxy_authentication_infos,
                        pos);
            osip_list_remove (&sip->proxy_authentication_infos, pos);
            osip_proxy_authentication_info_free (al);
        }
    }
    {
        osip_proxy_authorization_t *proxy_authorization;

        while (!osip_list_eol (&sip->proxy_authorizations, pos))
        {
            proxy_authorization =
                (osip_proxy_authorization_t *) osip_list_get (&sip->
                        proxy_authorizations, pos);
            osip_list_remove (&sip->proxy_authorizations, pos);
            osip_proxy_authorization_free (proxy_authorization);
        }
    }
    {
        osip_record_route_t *record_route;

        while (!osip_list_eol (&sip->record_routes, pos))
        {
            record_route =
                (osip_record_route_t *) osip_list_get (&sip->record_routes, pos);
            osip_list_remove (&sip->record_routes, pos);
            osip_record_route_free (record_route);
        }
    }
    {
        osip_route_t *route;

        while (!osip_list_eol (&sip->routes, pos))
        {
            route = (osip_route_t *) osip_list_get (&sip->routes, pos);
            osip_list_remove (&sip->routes, pos);
            osip_route_free (route);
        }
    }
    if (sip->to != NULL)
    {
        osip_to_free (sip->to);
    }
    {
        osip_via_t *via;

        while (!osip_list_eol (&sip->vias, pos))
        {
            via = (osip_via_t *) osip_list_get (&sip->vias, pos);
            osip_list_remove (&sip->vias, pos);
            osip_via_free (via);
        }
    }
    {
        osip_www_authenticate_t *al;

        while (!osip_list_eol (&sip->www_authenticates, pos))
        {
            al =
                (osip_www_authenticate_t *) osip_list_get (&sip->www_authenticates, pos);
            osip_list_remove (&sip->www_authenticates, pos);
            osip_www_authenticate_free (al);
        }
    }

    {
        osip_header_t *header;

        while (!osip_list_eol (&sip->headers, pos))
        {
            header = (osip_header_t *) osip_list_get (&sip->headers, pos);
            osip_list_remove (&sip->headers, pos);
            osip_header_free (header);
        }
    }

    {
        osip_body_t *body;

        while (!osip_list_eol (&sip->bodies, pos))
        {
            body = (osip_body_t *) osip_list_get (&sip->bodies, pos);
            osip_list_remove (&sip->bodies, pos);
            osip_body_free (body);
        }
    }
    osip_free (sip->message);
    osip_free (sip);
}