int _eXosip_dialog_init_as_uac (eXosip_dialog_t ** _jd, osip_message_t * _200Ok) { int i; eXosip_dialog_t *jd; *_jd = NULL; jd = (eXosip_dialog_t *) osip_malloc (sizeof (eXosip_dialog_t)); if (jd == NULL) return OSIP_NOMEM; memset (jd, 0, sizeof (eXosip_dialog_t)); jd->d_id = -1; /* not yet available to user */ if (MSG_IS_REQUEST (_200Ok)) { i = osip_dialog_init_as_uac_with_remote_request (&(jd->d_dialog), _200Ok, -1); } else { /* normal usage with response */ i = osip_dialog_init_as_uac (&(jd->d_dialog), _200Ok); } if (i != 0) { osip_free (jd); return i; } jd->d_count = 0; jd->d_session_timer_start = 0; jd->d_session_timer_length = 0; jd->d_refresher = -1; /* 0 -> me / 1 -> remote */ jd->d_timer = osip_getsystemtime (NULL); jd->d_200Ok = NULL; jd->d_ack = NULL; jd->next = NULL; jd->parent = NULL; jd->d_out_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_out_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_out_trs); jd->d_inc_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_inc_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd->d_out_trs); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_inc_trs); *_jd = jd; return OSIP_SUCCESS; }
int _eXosip_dialog_init_as_uas (eXosip_dialog_t ** _jd, osip_message_t * _invite, osip_message_t * _200Ok) { int i; eXosip_dialog_t *jd; *_jd = NULL; jd = (eXosip_dialog_t *) osip_malloc (sizeof (eXosip_dialog_t)); if (jd == NULL) return OSIP_NOMEM; memset (jd, 0, sizeof (eXosip_dialog_t)); jd->d_id = -1; /* not yet available to user */ i = osip_dialog_init_as_uas (&(jd->d_dialog), _invite, _200Ok); if (i != 0) { osip_free (jd); return i; } jd->d_count = 0; jd->d_session_timer_start = 0; jd->d_session_timer_length = 0; jd->d_session_timer_use_update = -1; jd->d_refresher = -1; /* 0 -> me / 1 -> remote */ jd->d_timer = osip_getsystemtime (NULL); jd->d_200Ok = NULL; jd->d_ack = NULL; jd->next = NULL; jd->parent = NULL; jd->d_out_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_out_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_out_trs); jd->d_inc_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_inc_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd->d_out_trs); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_inc_trs); jd->d_dialog->local_cseq = 1; *_jd = jd; return OSIP_SUCCESS; }
void GB_ResetConState(GB_CONNECT_STATE *gb_cons) { if (gb_cons == NULL) return; TRACE(SCI_TRACE_NORMAL,MOD_GB,"GB_ResetConState\n"); gb_cons->cur_state = GB_STATE_IDEL; gb_cons->connfd = -1; gb_cons->local_cseq = 1; gb_cons->bUnRegister = 0; if (gb_cons->wwwa) { osip_www_authenticate_free(gb_cons->wwwa); gb_cons->wwwa = NULL; } GB_reset_recv_buffer(gb_cons, 0); if(osip_list_size(&(gb_cons->record_node_list)) > 0) { GB_reset_Record_Node_list(gb_cons); } osip_list_init(&(gb_cons->record_node_list)); gb_cons->keepalive_timeout_cnt = 0; gb_cons->last_keepalivetime = 0; gb_cons->last_sendtime = 0; gb_cons->last_registertime = 0; return ; }
int osip_negotiation_remove_other_payloads (osip_negotiation_t *config) { osip_list_special_free (config->other_codec, (void *(*)(void *)) &__payload_free); config->other_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->other_codec); return 0; }
/* return -1 on error */ int osip_uri_init (osip_uri_t ** url) { *url = (osip_uri_t *) osip_malloc (sizeof (osip_uri_t)); if (*url == NULL) return -1; (*url)->scheme = NULL; (*url)->username = NULL; (*url)->password = NULL; (*url)->host = NULL; (*url)->port = NULL; osip_list_init (&(*url)->url_params); osip_list_init (&(*url)->url_headers); (*url)->string = NULL; return 0; }
int osip_negotiation_init (osip_negotiation_t ** config_out) { osip_negotiation_t *config; config = (osip_negotiation_t *) osip_malloc (sizeof (osip_negotiation_t)); if (config == NULL) return -1; config->o_username = NULL; config->o_session_id = NULL; config->o_session_version = NULL; config->o_nettype = NULL; config->o_addrtype = NULL; config->o_addr = NULL; config->c_nettype = NULL; config->c_addrtype = NULL; config->c_addr = NULL; config->c_addr_multicast_ttl = NULL; config->c_addr_multicast_int = NULL; /* supported codec for the SIP User Agent */ config->audio_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->audio_codec); config->video_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->video_codec); config->other_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->other_codec); config->fcn_set_info = NULL; config->fcn_set_uri = NULL; config->fcn_set_emails = NULL; config->fcn_set_phones = NULL; config->fcn_set_attributes = NULL; config->fcn_accept_audio_codec = NULL; config->fcn_accept_video_codec = NULL; config->fcn_accept_other_codec = NULL; *config_out = config; return 0; }
int eXosip_dialog_init_as_uac (eXosip_dialog_t ** _jd, osip_message_t * _200Ok) { int i; eXosip_dialog_t *jd; *_jd = NULL; jd = (eXosip_dialog_t *) osip_malloc (sizeof (eXosip_dialog_t)); memset (jd, 0, sizeof (eXosip_dialog_t)); jd->d_id = -1; /* not yet available to user */ jd->d_STATE = JD_EMPTY; if (MSG_IS_REQUEST (_200Ok)) { i = osip_dialog_init_as_uac_with_remote_request (&(jd->d_dialog), _200Ok, -1); } else { /* normal usage with response */ i = osip_dialog_init_as_uac (&(jd->d_dialog), _200Ok); } if (i != 0) { osip_free (jd); return -1; } jd->d_timer = time (NULL); jd->d_200Ok = NULL; jd->d_ack = NULL; jd->next = NULL; jd->parent = NULL; jd->d_out_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (jd->d_out_trs); jd->d_inc_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (jd->d_inc_trs); /* jd->d_bh = sdp_handler_new(); */ *_jd = jd; return 0; }
int sdp_time_descr_init (sdp_time_descr_t ** td) { *td = (sdp_time_descr_t *) osip_malloc (sizeof (sdp_time_descr_t)); if (*td == NULL) return -1; (*td)->t_start_time = NULL; (*td)->t_stop_time = NULL; (*td)->r_repeats = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init ((*td)->r_repeats); return 0; }
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 (dialog == NULL) return OSIP_BADPARAMETER; if (response == NULL) return OSIP_BADPARAMETER; 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 i; } if (dialog->state == DIALOG_EARLY && osip_list_size (&dialog->route_set) > 0) { osip_list_special_free (&dialog->route_set, (void (*)(void *)) &osip_record_route_free); osip_list_init (&dialog->route_set); } 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 i; osip_list_add (&dialog->route_set, rr2, 0); pos++; } } if (MSG_IS_STATUS_2XX (response)) dialog->state = DIALOG_CONFIRMED; return OSIP_SUCCESS; }
/* always use this method to initiate osip_fifo_t. */ void osip_fifo_init (osip_fifo_t * ff) { #ifdef OSIP_MT ff->qislocked = osip_mutex_init (); /*INIT SEMA TO BLOCK ON GET() WHEN QUEUE IS EMPTY */ ff->qisempty = osip_sem_init (0); #endif osip_list_init (&ff->queue); /* ff->nb_elt = 0; */ ff->state = osip_empty; }
int osip_accept_encoding_init(osip_accept_encoding_t ** accept_encoding) { *accept_encoding = (osip_accept_encoding_t *) osip_malloc(sizeof(osip_accept_encoding_t)); if (*accept_encoding == NULL) return OSIP_NOMEM; (*accept_encoding)->element = NULL; osip_list_init(&(*accept_encoding)->gen_params); return OSIP_SUCCESS; }
int osip_via_init (osip_via_t ** via) { *via = (osip_via_t *) osip_malloc (sizeof (osip_via_t)); if (*via == NULL) return -1; memset (*via, 0, sizeof (osip_via_t)); osip_list_init (&(*via)->via_params); return 0; }
int osip_call_info_init (osip_call_info_t ** call_info) { *call_info = (osip_call_info_t *) osip_malloc (sizeof (osip_call_info_t)); if (*call_info == NULL) return OSIP_NOMEM; (*call_info)->element = NULL; osip_list_init (&(*call_info)->gen_params); return OSIP_SUCCESS; }
int sdp_media_init (sdp_media_t ** media) { *media = (sdp_media_t *) osip_malloc (sizeof (sdp_media_t)); if (*media == NULL) return -1; (*media)->m_media = NULL; (*media)->m_port = NULL; (*media)->m_number_of_port = NULL; (*media)->m_proto = NULL; (*media)->m_payloads = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init ((*media)->m_payloads); (*media)->i_info = NULL; (*media)->c_connections = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init ((*media)->c_connections); (*media)->b_bandwidths = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init ((*media)->b_bandwidths); (*media)->a_attributes = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init ((*media)->a_attributes); (*media)->k_key = NULL; return 0; }
int osip_from_init (osip_from_t ** from) { *from = (osip_from_t *) osip_malloc (sizeof (osip_from_t)); if (*from == NULL) return -1; (*from)->displayname = NULL; (*from)->url = NULL; osip_list_init (&(*from)->gen_params); return 0; }
/* always use this method to initiate osip_fifo_t. */ void osip_fifo_init (osip_fifo_t * ff) { #ifdef OSIP_MT ff->qislocked = osip_mutex_init (); /*INIT SEMA TO BLOCK ON GET() WHEN QUEUE IS EMPTY */ ff->qisempty = osip_sem_init (0); #endif ff->queue = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (ff->queue); /* ff->nb_elt = 0; */ ff->etat = vide; }
int eXosip_dialog_init_as_uas (eXosip_dialog_t ** _jd, osip_message_t * _invite, osip_message_t * _200Ok) { int i; eXosip_dialog_t *jd; *_jd = NULL; jd = (eXosip_dialog_t *) osip_malloc (sizeof (eXosip_dialog_t)); memset (jd, 0, sizeof (eXosip_dialog_t)); jd->d_id = -1; /* not yet available to user */ jd->d_STATE = JD_EMPTY; i = osip_dialog_init_as_uas (&(jd->d_dialog), _invite, _200Ok); if (i != 0) { osip_free (jd); return -1; } jd->d_timer = time (NULL); jd->d_200Ok = NULL; jd->d_ack = NULL; jd->next = NULL; jd->parent = NULL; jd->d_out_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (jd->d_out_trs); jd->d_inc_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (jd->d_inc_trs); #ifdef SUPPORT_MSN /* bugguy MSN */ jd->d_dialog->local_cseq = 1; #endif /* jd->d_bh = sdp_handler_new(); */ *_jd = jd; return 0; }
int osip_content_type_init(osip_content_type_t ** content_type) { *content_type = (osip_content_type_t *) osip_malloc(sizeof(osip_content_type_t)); if (*content_type == NULL) return OSIP_NOMEM; (*content_type)->type = NULL; (*content_type)->subtype = NULL; osip_list_init(&(*content_type)->gen_params); return OSIP_SUCCESS; }
/* to be changed to sdp_message_init(sdp_message_t **dest) */ int sdp_message_init (sdp_message_t ** sdp) { (*sdp) = (sdp_message_t *) osip_malloc (sizeof (sdp_message_t)); if (*sdp == NULL) return -1; (*sdp)->v_version = NULL; (*sdp)->o_username = NULL; (*sdp)->o_sess_id = NULL; (*sdp)->o_sess_version = NULL; (*sdp)->o_nettype = NULL; (*sdp)->o_addrtype = NULL; (*sdp)->o_addr = NULL; (*sdp)->s_name = NULL; (*sdp)->i_info = NULL; (*sdp)->u_uri = NULL; (*sdp)->e_emails = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*sdp)->e_emails == NULL) return -1; osip_list_init ((*sdp)->e_emails); (*sdp)->p_phones = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*sdp)->p_phones == NULL) return -1; osip_list_init ((*sdp)->p_phones); (*sdp)->c_connection = NULL; (*sdp)->b_bandwidths = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*sdp)->b_bandwidths == NULL) return -1; osip_list_init ((*sdp)->b_bandwidths); (*sdp)->t_descrs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*sdp)->t_descrs == NULL) return -1; osip_list_init ((*sdp)->t_descrs); (*sdp)->z_adjustments = NULL; (*sdp)->k_key = NULL; (*sdp)->a_attributes = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*sdp)->a_attributes == NULL) return -1; osip_list_init ((*sdp)->a_attributes); (*sdp)->m_medias = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*sdp)->m_medias == NULL) return -1; osip_list_init ((*sdp)->m_medias); return 0; }
int osip_call_info_init (osip_call_info_t ** call_info) { *call_info = (osip_call_info_t *) osip_malloc (sizeof (osip_call_info_t)); if (*call_info == NULL) return -1; (*call_info)->element = NULL; (*call_info)->gen_params = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*call_info)->gen_params == NULL) { osip_free (*call_info); *call_info = NULL; return -1; } osip_list_init ((*call_info)->gen_params); return 0; }
int osip_body_init (osip_body_t ** body) { *body = (osip_body_t *) osip_malloc (sizeof (osip_body_t)); if (*body == NULL) return -1; (*body)->body = NULL; (*body)->content_type = NULL; (*body)->length = 0; (*body)->headers = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*body)->headers == NULL) { osip_free (*body); *body = NULL; return -1; } osip_list_init ((*body)->headers); return 0; }
int osip_accept_encoding_init (osip_accept_encoding_t ** accept_encoding) { *accept_encoding = (osip_accept_encoding_t *) osip_malloc (sizeof (osip_accept_encoding_t)); if (*accept_encoding == NULL) return -1; (*accept_encoding)->element = NULL; (*accept_encoding)->gen_params = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*accept_encoding)->gen_params == NULL) { osip_free (*accept_encoding); *accept_encoding = NULL; return -1; } osip_list_init ((*accept_encoding)->gen_params); return 0; }
int osip_content_type_init (osip_content_type_t ** content_type) { *content_type = (osip_content_type_t *) osip_malloc (sizeof (osip_content_type_t)); if (*content_type == NULL) return -1; (*content_type)->type = NULL; (*content_type)->subtype = NULL; (*content_type)->gen_params = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*content_type)->gen_params == NULL) { osip_free ((*content_type)->gen_params); *content_type = NULL; return -1; } osip_list_init ((*content_type)->gen_params); return 0; }
int osip_via_init (osip_via_t ** via) { *via = (osip_via_t *) osip_malloc (sizeof (osip_via_t)); if (*via == NULL) return -1; (*via)->version = NULL; (*via)->protocol = NULL; (*via)->host = NULL; (*via)->port = NULL; (*via)->comment = NULL; (*via)->via_params = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if ((*via)->via_params == NULL) { osip_free (*via); *via = NULL; return -1; } osip_list_init ((*via)->via_params); return 0; }
void __nict_load_fsm () { transition_t *transition; nict_fsm = (osip_statemachine_t *) osip_malloc (sizeof (osip_statemachine_t)); nict_fsm->transitions = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (nict_fsm->transitions); /* to avoid race conditions between timers and first request */ transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_PRE_TRYING; transition->type = SND_REQUEST; transition->method = (void (*)(void *, void *)) &nict_snd_request; osip_list_add (nict_fsm->transitions, transition, -1); /* transition = (transition_t *) osip_malloc(sizeof(transition_t)); transition->state = NICT_TRYING; transition->type = SND_REQUEST; transition->method = (void(*)(void *,void *))&nict_snd_request; osip_list_add(nict_fsm->transitions,transition,-1); */ transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_TRYING; transition->type = TIMEOUT_F; transition->method = (void (*)(void *, void *)) &osip_nict_timeout_f_event; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_TRYING; transition->type = TIMEOUT_E; transition->method = (void (*)(void *, void *)) &osip_nict_timeout_e_event; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_TRYING; transition->type = RCV_STATUS_1XX; transition->method = (void (*)(void *, void *)) &nict_rcv_1xx; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_TRYING; transition->type = RCV_STATUS_2XX; transition->method = (void (*)(void *, void *)) &nict_rcv_23456xx; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_TRYING; transition->type = RCV_STATUS_3456XX; transition->method = (void (*)(void *, void *)) &nict_rcv_23456xx; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_PROCEEDING; transition->type = TIMEOUT_F; transition->method = (void (*)(void *, void *)) &osip_nict_timeout_f_event; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_PROCEEDING; transition->type = TIMEOUT_E; transition->method = (void (*)(void *, void *)) &osip_nict_timeout_e_event; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_PROCEEDING; transition->type = RCV_STATUS_1XX; transition->method = (void (*)(void *, void *)) &nict_rcv_1xx; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_PROCEEDING; transition->type = RCV_STATUS_2XX; transition->method = (void (*)(void *, void *)) &nict_rcv_23456xx; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_PROCEEDING; transition->type = RCV_STATUS_3456XX; transition->method = (void (*)(void *, void *)) &nict_rcv_23456xx; osip_list_add (nict_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NICT_COMPLETED; transition->type = TIMEOUT_K; transition->method = (void (*)(void *, void *)) &osip_nict_timeout_k_event; osip_list_add (nict_fsm->transitions, transition, -1); /* these ccan be used to announce retransmission of 2xx and 3456xx For the state machine, it is completely useless... transition = (transition_t *) osip_malloc(sizeof(transition_t)); transition->state = NICT_COMPLETED; transition->type = RCV_STATUS_2XX; transition->method = (void(*)(void *,void *))&nict_rcv_23456xx2; osip_list_add(nict_fsm->transitions,transition,-1); transition = (transition_t *) osip_malloc(sizeof(transition_t)); transition->state = NICT_COMPLETED; transition->type = RCV_STATUS_3456XX; transition->method = (void(*)(void *,void *))&nict_rcv_23456xx2; osip_list_add(nict_fsm->transitions,transition,-1); */ }
static int __osip_dialog_init (osip_dialog_t ** dialog, osip_message_t * invite, osip_message_t * response, osip_from_t * local, osip_to_t * remote, osip_message_t * remote_msg) { int i; int pos; osip_generic_param_t *tag; *dialog = NULL; if (response == NULL) return OSIP_BADPARAMETER; if (response->cseq == NULL || local == NULL || remote == NULL) return OSIP_SYNTAXERROR; (*dialog) = (osip_dialog_t *) osip_malloc (sizeof (osip_dialog_t)); if (*dialog == NULL) return OSIP_NOMEM; memset (*dialog, 0, sizeof (osip_dialog_t)); (*dialog)->your_instance = NULL; 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) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_dialog_free (*dialog); *dialog = NULL; return i; } i = osip_to_get_tag (local, &tag); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_dialog_free (*dialog); *dialog = NULL; return i; } (*dialog)->local_tag = osip_strdup (tag->gvalue); i = osip_from_get_tag (remote, &tag); if (i == 0) (*dialog)->remote_tag = osip_strdup (tag->gvalue); /* VR-2785: remember line value */ if (invite) { osip_uri_param_t *line_param; i = osip_uri_param_get_byname (&invite->req_uri->url_params, "line", &line_param); if (i == 0 && line_param != NULL && line_param->gvalue != NULL) (*dialog)->line_param = osip_strdup (line_param->gvalue); } 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) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_dialog_free (*dialog); *dialog = NULL; return i; } if (invite == NULL) osip_list_add (&(*dialog)->route_set, rr2, 0); else osip_list_add (&(*dialog)->route_set, rr2, -1); pos++; } /* local_cseq is set to response->cseq->number for better handling of bad UA */ (*dialog)->local_cseq = osip_atoi (response->cseq->number); i = osip_from_clone (remote, &((*dialog)->remote_uri)); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_dialog_free (*dialog); *dialog = NULL; return i; } i = osip_to_clone (local, &((*dialog)->local_uri)); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_dialog_free (*dialog); *dialog = NULL; return i; } { osip_contact_t *contact; if (!osip_list_eol (&remote_msg->contacts, 0)) { contact = osip_list_get (&remote_msg->contacts, 0); i = osip_contact_clone (contact, &((*dialog)->remote_contact_uri)); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_dialog_free (*dialog); *dialog = NULL; return i; } } else { (*dialog)->remote_contact_uri = NULL; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "Remote UA is not compliant: missing a contact in remote message!\n")); } } (*dialog)->secure = -1; /* non secure */ return OSIP_SUCCESS; }
int osip_message_init (osip_message_t ** sip) { *sip = (osip_message_t *) osip_malloc (sizeof (osip_message_t)); if (*sip == NULL) return OSIP_NOMEM; memset (*sip, 0, sizeof (osip_message_t)); #ifndef MINISIZE osip_list_init (&(*sip)->accepts); osip_list_init (&(*sip)->accept_encodings); osip_list_init (&(*sip)->accept_languages); osip_list_init (&(*sip)->alert_infos); osip_list_init (&(*sip)->allows); osip_list_init (&(*sip)->authentication_infos); #endif osip_list_init (&(*sip)->authorizations); (*sip)->call_id = NULL; osip_list_init (&(*sip)->call_infos); osip_list_init (&(*sip)->contacts); #ifndef MINISIZE osip_list_init (&(*sip)->content_encodings); #endif (*sip)->content_length = NULL; (*sip)->content_type = NULL; (*sip)->cseq = NULL; #ifndef MINISIZE osip_list_init (&(*sip)->error_infos); #endif (*sip)->from = NULL; (*sip)->mime_version = NULL; osip_list_init (&(*sip)->proxy_authenticates); #ifndef MINISIZE osip_list_init (&(*sip)->proxy_authentication_infos); #endif osip_list_init (&(*sip)->proxy_authorizations); osip_list_init (&(*sip)->record_routes); osip_list_init (&(*sip)->routes); (*sip)->to = NULL; osip_list_init (&(*sip)->vias); osip_list_init (&(*sip)->www_authenticates); osip_list_init (&(*sip)->bodies); osip_list_init (&(*sip)->headers); (*sip)->message_property = 3; (*sip)->message = NULL; /* buffer to avoid calling osip_message_to_str many times (for retransmission) */ (*sip)->message_length = 0; (*sip)->application_data = NULL; return OSIP_SUCCESS; /* ok */ }
void __nist_load_fsm () { transition_t *transition; nist_fsm = (osip_statemachine_t *) osip_malloc (sizeof (osip_statemachine_t)); nist_fsm->transitions = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (nist_fsm->transitions); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_PRE_TRYING; transition->type = RCV_REQUEST; transition->method = (void (*)(void *, void *)) &nist_rcv_request; osip_list_add (nist_fsm->transitions, transition, -1); /* This can be used to announce request but is useless, as the transaction cannot send any response yet! transition = (transition_t *) osip_malloc(sizeof(transition_t)); transition->state = NIST_TRYING; transition->type = RCV_REQUEST; transition->method = (void(*)(void *,void *))&nist_rcv_request; osip_list_add(nist_fsm->transitions,transition,-1); */ transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_TRYING; transition->type = SND_STATUS_1XX; transition->method = (void (*)(void *, void *)) &nist_snd_1xx; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_TRYING; transition->type = SND_STATUS_2XX; transition->method = (void (*)(void *, void *)) &nist_snd_23456xx; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_TRYING; transition->type = SND_STATUS_3456XX; transition->method = (void (*)(void *, void *)) &nist_snd_23456xx; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_PROCEEDING; transition->type = SND_STATUS_1XX; transition->method = (void (*)(void *, void *)) &nist_snd_1xx; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_PROCEEDING; transition->type = SND_STATUS_2XX; transition->method = (void (*)(void *, void *)) &nist_snd_23456xx; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_PROCEEDING; transition->type = SND_STATUS_3456XX; transition->method = (void (*)(void *, void *)) &nist_snd_23456xx; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_PROCEEDING; transition->type = RCV_REQUEST; transition->method = (void (*)(void *, void *)) &nist_rcv_request; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_COMPLETED; transition->type = TIMEOUT_J; transition->method = (void (*)(void *, void *)) &osip_nist_timeout_j_event; osip_list_add (nist_fsm->transitions, transition, -1); transition = (transition_t *) osip_malloc (sizeof (transition_t)); transition->state = NIST_COMPLETED; transition->type = RCV_REQUEST; transition->method = (void (*)(void *, void *)) &nist_rcv_request; osip_list_add (nist_fsm->transitions, transition, -1); }
/* we don't have to compare remote_uri with from && local_uri with to. ----> we have both tag recognized, it's enough.. */ if (0 == strcmp (tag_param_remote->gvalue, dlg->remote_tag)) return 0; return -1; } int osip_dialog_init_as_uac (osip_dialog_t ** dialog, osip_message_t * response) { int i; int pos; osip_generic_param_t *tag; *dialog = NULL; 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")); return -1; } (*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; } else (*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); pos++; } (*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; } else { (*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; diau_error_5: osip_from_free ((*dialog)->local_uri); diau_error_4: osip_from_free ((*dialog)->remote_uri); diau_error_3: diau_error_2: osip_list_special_free ((*dialog)->route_set, (void *(*)(void *)) &osip_record_route_free); osip_free ((*dialog)->remote_tag); osip_free ((*dialog)->local_tag); diau_error_1: osip_free ((*dialog)->call_id); diau_error_0: OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_free (*dialog); *dialog = NULL; return -1; } #if 1 /* SIPIT13 */ int osip_dialog_init_as_uac_with_remote_request (osip_dialog_t ** dialog, osip_message_t *next_request, int local_cseq) { int i; osip_generic_param_t *tag; *dialog = NULL; i = osip_to_get_tag (next_request->from, &tag); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "Remote UA is not compliant: missing a tag in next request!\n")); return -1; } (*dialog) = (osip_dialog_t *) osip_malloc (sizeof (osip_dialog_t)); if (*dialog == NULL) return -1; (*dialog)->type = CALLER; #if 0 (*dialog)->state = DIALOG_CONFIRMED; #endif (*dialog)->state = DIALOG_EARLY; i = osip_call_id_to_str (next_request->call_id, &((*dialog)->call_id)); if (i != 0) goto diau_error_0; i = osip_from_get_tag (next_request->to, &tag); if (i != 0) goto diau_error_1; (*dialog)->local_tag = osip_strdup (tag->gvalue); i = osip_to_get_tag (next_request->from, &tag); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "Remote UA is not compliant: missing a tag in next request!\n")); (*dialog)->remote_tag = NULL; } else (*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); (*dialog)->local_cseq = local_cseq; /* -1 osip_atoi (xxx->cseq->number); */ (*dialog)->remote_cseq = osip_atoi (next_request->cseq->number); i = osip_to_clone (next_request->from, &((*dialog)->remote_uri)); if (i != 0) goto diau_error_3; i = osip_from_clone (next_request->to, &((*dialog)->local_uri)); if (i != 0) goto diau_error_4; (*dialog)->secure = -1; /* non secure */ return 0; diau_error_4: osip_from_free ((*dialog)->remote_uri); diau_error_3: osip_free ((*dialog)->remote_tag); osip_free ((*dialog)->local_tag); diau_error_1: osip_free ((*dialog)->call_id); diau_error_0: OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_free (*dialog); *dialog = NULL; return -1; }
int osip_dialog_init_as_uas (osip_dialog_t ** dialog, osip_message_t * invite, osip_message_t * response) { int i; int pos; osip_generic_param_t *tag; (*dialog) = (osip_dialog_t *) osip_malloc (sizeof (osip_dialog_t)); if (*dialog == NULL) return -1; (*dialog)->type = CALLEE; 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_to_get_tag (response->to, &tag); if (i != 0) goto diau_error_1; (*dialog)->local_tag = osip_strdup (tag->gvalue); i = osip_from_get_tag (response->from, &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); (*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); pos++; } /* local_cseq is set to response->cseq->number for better handling of bad UA */ (*dialog)->local_cseq = osip_atoi (response->cseq->number); (*dialog)->remote_cseq = osip_atoi (response->cseq->number); i = osip_from_clone (response->from, &((*dialog)->remote_uri)); if (i != 0) goto diau_error_3; i = osip_to_clone (response->to, &((*dialog)->local_uri)); if (i != 0) goto diau_error_4; { osip_contact_t *contact; if (!osip_list_eol (invite->contacts, 0)) { contact = osip_list_get (invite->contacts, 0); i = osip_contact_clone (contact, &((*dialog)->remote_contact_uri)); if (i != 0) goto diau_error_5; } else { (*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; diau_error_5: osip_from_free ((*dialog)->local_uri); diau_error_4: osip_from_free ((*dialog)->remote_uri); diau_error_3: diau_error_2: osip_list_special_free ((*dialog)->route_set, (void *(*)(void *)) &osip_record_route_free); osip_free ((*dialog)->remote_tag); osip_free ((*dialog)->local_tag); diau_error_1: osip_free ((*dialog)->call_id); diau_error_0: OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "Could not establish dialog!\n")); osip_free (*dialog); *dialog = NULL; return -1; }