static struct mi_root* ds_mi_set(struct mi_root* cmd_tree, void* param) { str sp; int ret; unsigned int group; int state; struct mi_node* node; node = cmd_tree->node.kids; if(node == NULL) return init_mi_tree(400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); sp = node->value; if(sp.len<=0 || !sp.s) { LM_ERR("bad state value\n"); return init_mi_tree(500, "bad state value", 15); } state = ds_parse_flags(sp.s, sp.len); if( state < 0 ) { LM_ERR("unknow state value\n"); return init_mi_tree(500, "unknown state value", 19); } node = node->next; if(node == NULL) return init_mi_tree(400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); sp = node->value; if(sp.s == NULL) { return init_mi_tree(500, "group not found", 15); } if(str2int(&sp, &group)) { LM_ERR("bad group value\n"); return init_mi_tree( 500, "bad group value", 16); } node= node->next; if(node == NULL) return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); sp = node->value; if(sp.s == NULL) { return init_mi_tree(500,"address not found", 18 ); } ret = ds_reinit_state(group, &sp, state); if(ret!=0) { return init_mi_tree(404, "destination not found", 21); } return init_mi_tree( 200, MI_OK_S, MI_OK_LEN); }
static int w_ds_mark_dst1(struct sip_msg *msg, char *str1, char *str2) { int state; if(str1 == NULL) return w_ds_mark_dst0(msg, NULL, NULL); state = ds_parse_flags(str1, strlen(str1)); if(state < 0) { LM_WARN("Failed to parse flag: %s", str1); return -1; } return ds_mark_dst(msg, state); }