/** * replicates a local dialog update to all the destinations * specified with the 'replicate_dialogs' modparam */ void replicate_dialog_updated(struct dlg_cell *dlg) { struct replication_dest *d; static str module_name = str_init("dialog"); int callee_leg; str *vars, *profiles; if (bin_init(&module_name, REPLICATION_DLG_UPDATED) != 0) goto error; callee_leg = callee_idx(dlg); bin_push_str(&dlg->callid); bin_push_str(&dlg->legs[DLG_CALLER_LEG].tag); bin_push_str(&dlg->legs[callee_leg].tag); bin_push_str(&dlg->from_uri); bin_push_str(&dlg->to_uri); bin_push_int(dlg->h_id); bin_push_int(dlg->start_ts); bin_push_int(dlg->state); bin_push_str(&dlg->legs[DLG_CALLER_LEG].bind_addr->sock_str); if (dlg->legs[callee_leg].bind_addr) bin_push_str(&dlg->legs[callee_leg].bind_addr->sock_str); else bin_push_str(NULL); bin_push_str(&dlg->legs[DLG_CALLER_LEG].r_cseq); bin_push_str(&dlg->legs[callee_leg].r_cseq); bin_push_str(&dlg->legs[DLG_CALLER_LEG].route_set); bin_push_str(&dlg->legs[callee_leg].route_set); bin_push_str(&dlg->legs[DLG_CALLER_LEG].contact); bin_push_str(&dlg->legs[callee_leg].contact); bin_push_str(&dlg->legs[callee_leg].from_uri); bin_push_str(&dlg->legs[callee_leg].to_uri); /* XXX: on shutdown only? */ vars = write_dialog_vars(dlg->vals); profiles = write_dialog_profiles(dlg->profile_links); bin_push_str(vars); bin_push_str(profiles); bin_push_int(dlg->user_flags); bin_push_int(dlg->flags & ~(DLG_FLAG_NEW|DLG_FLAG_CHANGED|DLG_FLAG_VP_CHANGED)); bin_push_int((unsigned int)time(0) + dlg->tl.timeout - get_ticks()); bin_push_int(dlg->legs[DLG_CALLER_LEG].last_gen_cseq); bin_push_int(dlg->legs[callee_leg].last_gen_cseq); for (d = replication_dests; d; d = d->next) bin_send(&d->to); if_update_stat(dlg_enable_stats,update_sent,1); return; error: LM_ERR("Failed to replicate updated dialog\n"); }
void bin_push_dlg(bin_packet_t *packet, struct dlg_cell *dlg) { int callee_leg; str *vars, *profiles; callee_leg = callee_idx(dlg); bin_push_str(packet, &dlg->callid); bin_push_str(packet, &dlg->legs[DLG_CALLER_LEG].tag); bin_push_str(packet, &dlg->legs[callee_leg].tag); bin_push_str(packet, &dlg->from_uri); bin_push_str(packet, &dlg->to_uri); bin_push_int(packet, dlg->h_id); bin_push_int(packet, dlg->start_ts); bin_push_int(packet, dlg->state); bin_push_str(packet, &dlg->legs[DLG_CALLER_LEG].bind_addr->sock_str); if (dlg->legs[callee_leg].bind_addr) bin_push_str(packet, &dlg->legs[callee_leg].bind_addr->sock_str); else bin_push_str(packet, NULL); bin_push_str(packet, &dlg->legs[DLG_CALLER_LEG].r_cseq); bin_push_str(packet, &dlg->legs[callee_leg].r_cseq); bin_push_str(packet, &dlg->legs[DLG_CALLER_LEG].route_set); bin_push_str(packet, &dlg->legs[callee_leg].route_set); bin_push_str(packet, &dlg->legs[DLG_CALLER_LEG].contact); bin_push_str(packet, &dlg->legs[callee_leg].contact); bin_push_str(packet, &dlg->legs[callee_leg].from_uri); bin_push_str(packet, &dlg->legs[callee_leg].to_uri); /* give modules the chance to write values/profiles before replicating */ run_dlg_callbacks(DLGCB_WRITE_VP, dlg, NULL, DLG_DIR_NONE, NULL, 1); vars = write_dialog_vars(dlg->vals); profiles = write_dialog_profiles(dlg->profile_links); bin_push_str(packet, vars); bin_push_str(packet, profiles); bin_push_int(packet, dlg->user_flags); bin_push_int(packet, dlg->mod_flags); bin_push_int(packet, dlg->flags & ~(DLG_FLAG_NEW|DLG_FLAG_CHANGED|DLG_FLAG_VP_CHANGED|DLG_FLAG_FROM_DB)); bin_push_int(packet, (unsigned int)time(0) + dlg->tl.timeout - get_ticks()); bin_push_int(packet, dlg->legs[DLG_CALLER_LEG].last_gen_cseq); bin_push_int(packet, dlg->legs[callee_leg].last_gen_cseq); }
static inline void set_final_update_cols(db_val_t *vals, struct dlg_cell *cell, int on_shutdown) { str *s; LM_DBG("DLG vals and profiles should %s[%x:%d]\n", (db_flush_vp && (cell->flags & DLG_FLAG_VP_CHANGED)) ? "be saved" : "not be saved", cell->flags, db_flush_vp); if (on_shutdown || (db_flush_vp && (cell->flags & DLG_FLAG_VP_CHANGED))) { if (cell->vals==NULL) { VAL_NULL(vals) = 1; } else { s = write_dialog_vars( cell->vals ); if (s==NULL) { VAL_NULL(vals) = 1; } else { SET_STR_VALUE(vals, *s); } } if (cell->profile_links==NULL) { VAL_NULL(vals+1) = 1; } else { s = write_dialog_profiles( cell->profile_links ); if (s==NULL) { VAL_NULL(vals+1) = 1; } else { SET_STR_VALUE(vals+1, *s); } } SET_INT_VALUE(vals+2, cell->user_flags); } else { VAL_NULL(vals) = 1; VAL_NULL(vals+1) = 1; SET_INT_VALUE(vals+2, 0); } }
/** * replicates a locally created dialog to all the destinations * specified with the 'replicate_dialogs' modparam */ void replicate_dialog_created(struct dlg_cell *dlg) { static str module_name = str_init("dialog"); int callee_leg; str *vars, *profiles; if (bin_init(&module_name, REPLICATION_DLG_CREATED, BIN_VERSION) != 0) goto error; bin_push_int(clusterer_api.get_my_id()); callee_leg = callee_idx(dlg); bin_push_str(&dlg->callid); bin_push_str(&dlg->legs[DLG_CALLER_LEG].tag); bin_push_str(&dlg->legs[callee_leg].tag); bin_push_str(&dlg->from_uri); bin_push_str(&dlg->to_uri); bin_push_int(dlg->h_id); bin_push_int(dlg->start_ts); bin_push_int(dlg->state); bin_push_str(&dlg->legs[DLG_CALLER_LEG].bind_addr->sock_str); if (dlg->legs[callee_leg].bind_addr) bin_push_str(&dlg->legs[callee_leg].bind_addr->sock_str); else bin_push_str(NULL); bin_push_str(&dlg->legs[DLG_CALLER_LEG].r_cseq); bin_push_str(&dlg->legs[callee_leg].r_cseq); bin_push_str(&dlg->legs[DLG_CALLER_LEG].route_set); bin_push_str(&dlg->legs[callee_leg].route_set); bin_push_str(&dlg->legs[DLG_CALLER_LEG].contact); bin_push_str(&dlg->legs[callee_leg].contact); bin_push_str(&dlg->legs[callee_leg].from_uri); bin_push_str(&dlg->legs[callee_leg].to_uri); /* XXX: on shutdown only? */ vars = write_dialog_vars(dlg->vals); dlg_lock_dlg(dlg); profiles = write_dialog_profiles(dlg->profile_links); dlg_unlock_dlg(dlg); bin_push_str(vars); bin_push_str(profiles); bin_push_int(dlg->user_flags); bin_push_int(dlg->flags & ~(DLG_FLAG_NEW|DLG_FLAG_CHANGED|DLG_FLAG_VP_CHANGED)); bin_push_int((unsigned int)time(0) + dlg->tl.timeout - get_ticks()); bin_push_int(dlg->legs[DLG_CALLER_LEG].last_gen_cseq); bin_push_int(dlg->legs[callee_leg].last_gen_cseq); if (clusterer_api.send_to(dialog_replicate_cluster, PROTO_BIN) < 0) goto error; if_update_stat(dlg_enable_stats,create_sent,1); return; error: LM_ERR("Failed to replicate created dialog\n"); }