void Node::TransferUserInfoToSucc(ChordId node) { uinfo_t *cur=user_info_list; uinfo_t *red_cur=red_user_info_list; char * succ= (char *)osip_malloc(4 + strlen(node.GetAddress()) +1) ; sprintf (succ, "sip:%s", node.GetAddress()); const char *registrar=succ ; //转移该节点负责的用户信息 while(cur != NULL) { uinfo_t *tmp=cur; cur=tmp->next; SndUserRegisterRequest(USER_REGISTRATION,tmp,registrar,3600); REMOVE_ELEMENT(user_info_list,tmp); delete tmp; } //转移该节点负责的冗余用户信息 while(red_cur != NULL) { uinfo_t *tmp2=red_cur; red_cur=tmp2->next; SndUserRegisterRequest(RED_REGISTER,tmp2,registrar,3600); REMOVE_ELEMENT(red_user_info_list,tmp2); delete tmp2; } if(succ) osip_free(succ) ; }
//--------------------------------------------------------------------- void Node::TransferUserInfoToPred(ChordId node) { uinfo_t *red_cur=red_user_info_list; uinfo_t *cur=user_info_list; while(red_cur != NULL) { char *red_aor; uinfo_t *red_tmp=red_cur; red_cur=red_cur->next; osip_uri_to_str(red_tmp->aor->uri,&red_aor); if(red_aor) osip_free(red_aor) ; char * red_registrar= (char *)osip_malloc(4 + strlen(node.GetAddress()) +1) ; sprintf (red_registrar, "sip:%s", node.GetAddress()); SndUserRegisterRequest(RED_REGISTER,red_tmp,red_registrar ,3600); if(red_registrar) osip_free(red_registrar) ; REMOVE_ELEMENT(red_user_info_list,red_tmp); delete red_tmp; } ChordId localnode=getChordId(); unsigned int uid=0; while(cur != NULL) { char *aor; uinfo_t *tmp=cur; cur=cur->next; osip_uri_to_str(tmp->aor->uri,&aor); uid=uhash(aor); if(aor) osip_free(aor) ; Constants constants(NULL); ChordId UserID(uid,&constants); if(!UserID.BelongsRightInclusive(node,localnode)) { char * registrar= (char *)osip_malloc(4 + strlen(node.GetAddress()) +1) ; sprintf (registrar, "sip:%s", node.GetAddress()); SndUserRegisterRequest(USER_REGISTRATION,tmp,registrar,3600); if(registrar) osip_free(registrar) ; REMOVE_ELEMENT(user_info_list,tmp); //ADD_ELEMENT(red_user_info_list,tmp);//move this user info to redundant user info list delete tmp; } } }
void _eXosip_subscribe_free(struct eXosip_t *excontext, 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(excontext, 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(excontext, 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(excontext, jd); } _eXosip_delete_reserved(js->s_inc_tr); _eXosip_delete_reserved(js->s_out_tr); if (js->s_inc_tr != NULL) osip_list_add(&excontext->j_transactions, js->s_inc_tr, 0); if (js->s_out_tr != NULL) osip_list_add(&excontext->j_transactions, js->s_out_tr, 0); osip_free(js); }
//------------------------------------------------------------------- Node::~Node() { //delete fileout ; BootStrap *bs ; for (bs = j_bootstraps; bs!=NULL;bs = j_bootstraps) { REMOVE_ELEMENT(j_bootstraps, bs); SAFE_DELETE(bs) ; } if (_state) delete _state ; osip_mutex_destroy (gl_lock); if(th_stabilize) delete th_stabilize ; if(th_transport) delete th_transport ; if(adosip) delete adosip ; if(fingerTable) delete fingerTable ; if(user_info_pipe) delete user_info_pipe; if(constants) delete constants ; }
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); }
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); }
void __eXosip_call_remove_dialog_reference_in_call(eXosip_call_t *jc, eXosip_dialog_t *jd) { eXosip_dialog_t *_jd; jinfo_t *ji; if (jc==NULL) return; if (jd==NULL) return; for (_jd = jc->c_dialogs; _jd!=NULL; _jd=_jd->next) { if (jd==_jd) break; } if (_jd!=NULL) /* dialog found*/ { REMOVE_ELEMENT(jc->c_dialogs, _jd); } ji = osip_transaction_get_your_instance(jc->c_inc_tr); if (ji!=NULL && ji->jd==jd) { ji->jd=NULL; } ji = osip_transaction_get_your_instance(jc->c_out_tr); if (ji!=NULL && ji->jd==jd) { ji->jd=NULL; } }
void _eXosip_call_free (struct eXosip_t *excontext, eXosip_call_t * jc) { eXosip_dialog_t *jd; if (jc->c_inc_tr != NULL && jc->c_inc_tr->orig_request != NULL && jc->c_inc_tr->orig_request->call_id != NULL && jc->c_inc_tr->orig_request->call_id->number != NULL) _eXosip_delete_nonce (excontext, jc->c_inc_tr->orig_request->call_id->number); else if (jc->c_out_tr != NULL && jc->c_out_tr->orig_request != NULL && jc->c_out_tr->orig_request->call_id != NULL && jc->c_out_tr->orig_request->call_id->number != NULL) _eXosip_delete_nonce (excontext, jc->c_out_tr->orig_request->call_id->number); for (jd = jc->c_dialogs; jd != NULL; jd = jc->c_dialogs) { REMOVE_ELEMENT (jc->c_dialogs, jd); _eXosip_dialog_free (excontext, jd); } _eXosip_delete_reserved (jc->c_inc_tr); _eXosip_delete_reserved (jc->c_out_tr); if (jc->c_inc_tr != NULL) osip_list_add (&excontext->j_transactions, jc->c_inc_tr, 0); if (jc->c_out_tr != NULL) osip_list_add (&excontext->j_transactions, jc->c_out_tr, 0); osip_free (jc); #ifndef MINISIZE excontext->statistics.allocated_calls--; #endif }
int eXosip_register_build_initial_register_withqvalue(const char *from, const char *proxy, const char *contact, int expires, const char *qvalue, osip_message_t ** reg) { eXosip_reg_t *jr = NULL; int i; *reg = NULL; if (from == NULL || proxy == NULL) return OSIP_BADPARAMETER; #ifdef REJECT_DOUBLE_REGISTRATION /* Avoid adding the same registration info twice to prevent mem leaks */ for (jr = eXosip.j_reg; jr != NULL; jr = jr->next) { if (strcmp(jr->r_aor, from) == 0 && strcmp(jr->r_registrar, proxy) == 0) { REMOVE_ELEMENT(eXosip.j_reg, jr); eXosip_reg_free(jr); jr = NULL; break; } } #endif if (jr == NULL) { /* Add new registration info */ i = eXosip_reg_init(&jr, from, proxy, contact); if (i != 0) { OSIP_TRACE(osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot register! ")); return i; } ADD_ELEMENT(eXosip.j_reg, jr); } /* build register */ jr->r_reg_period = expires; if (jr->r_reg_period <= 0) /* too low */ jr->r_reg_period = 0; else if (jr->r_reg_period < 30) /* too low */ jr->r_reg_period = 30; if(qvalue) osip_strncpy(jr->r_qvalue, qvalue, sizeof(jr->r_qvalue)); i = _eXosip_register_build_register(jr, reg); if (i != 0) { OSIP_TRACE(osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot build REGISTER!\n")); *reg = NULL; return i; } return jr->r_id; }
int eXosip_register_build_initial_register (const char *from, const char *proxy, const char *contact, int expires, osip_message_t ** reg) { eXosip_reg_t *jr = NULL; int i; *reg = NULL; /* Avoid adding the same registration info twice to prevent mem leaks */ for (jr = eXosip.j_reg; jr != NULL; jr = jr->next) { if (strcmp (jr->r_aor, from) == 0 && strcmp (jr->r_registrar, proxy) == 0) { REMOVE_ELEMENT (eXosip.j_reg, jr); eXosip_reg_free (jr); jr=NULL; break; } } if (jr == NULL) { /* Add new registration info */ i = eXosip_reg_init (&jr, from, proxy, contact); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot register! ")); return i; } ADD_ELEMENT (eXosip.j_reg, jr); } /* build register */ jr->r_reg_period = expires; if (jr->r_reg_period <= 0) /* too low */ jr->r_reg_period = 0; else if (jr->r_reg_period < 100) /* too low */ jr->r_reg_period = 100; i = _eXosip_register_build_register (jr, reg); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot build REGISTER!\n")); *reg = NULL; return i; } return jr->r_id; }
void Node::clearUserInfoList(uinfo_t **list) { uinfo_t *cur=*list; while(cur != NULL) { uinfo_t *tmp=cur; cur=cur->next; REMOVE_ELEMENT((*list),tmp); delete tmp; } *list=NULL; }
int eXosip_clear_authentication_info () { jauthinfo_t *jauthinfo; for (jauthinfo = eXosip.authinfos; jauthinfo != NULL; jauthinfo = eXosip.authinfos) { REMOVE_ELEMENT (eXosip.authinfos, jauthinfo); osip_free (jauthinfo); } return 0; }
void __nist_unload_fsm() { transition_t *transition; osip_statemachine_t *statemachine = __nist_get_fsm(); for (transition = statemachine->transitions; transition != NULL; transition = statemachine->transitions) { REMOVE_ELEMENT(statemachine->transitions, transition); osip_free(transition); } osip_free(statemachine->transitions); osip_free(statemachine); }
int eXosip_register_remove (int rid) { eXosip_reg_t *jr; jr = eXosip_reg_find (rid); if (jr == NULL) { /* fprintf(stderr, "eXosip: no registration info saved!\n"); */ return -1; } jr->r_reg_period = 0; REMOVE_ELEMENT (eXosip.j_reg, jr); eXosip_reg_free (jr); jr=NULL; return 0; }
int eXosip_register_remove(int rid) { eXosip_reg_t *jr; if (rid <= 0) return OSIP_BADPARAMETER; jr = eXosip_reg_find(rid); if (jr == NULL) return OSIP_NOTFOUND; jr->r_reg_period = 0; REMOVE_ELEMENT(eXosip.j_reg, jr); eXosip_reg_free(jr); jr = NULL; return OSIP_SUCCESS; }
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; }
void jidentity_unload() { jidentity_t *fr; if (eXosip.j_identitys==NULL) return; for (fr=eXosip.j_identitys; fr!=NULL; fr=eXosip.j_identitys) { REMOVE_ELEMENT(eXosip.j_identitys,fr); osip_free(fr->i_identity); osip_free(fr->i_registrar); osip_free(fr->i_realm); osip_free(fr->i_userid); osip_free(fr->i_pwd); osip_free(fr); } osip_free(eXosip.j_identitys); eXosip.j_identitys=NULL; return; }
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); }
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); }
int eXosip_insubscription_remove (int did) { eXosip_dialog_t *jd = NULL; eXosip_notify_t *jn = NULL; if (did <= 0) return OSIP_BADPARAMETER; if (did > 0) { eXosip_notify_dialog_find (did, &jn, &jd); } if (jd == NULL || jn == NULL) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: No incoming subscription here?\n")); return OSIP_NOTFOUND; } REMOVE_ELEMENT (eXosip.j_notifies, jn); eXosip_notify_free (jn); return OSIP_SUCCESS; }
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, ©); 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; }