static int ds_count_fixup(void** param, int param_no) { char *s; int i, code = 0; if (param_no > 3) return 0; s = (char *)*param; i = strlen(s); switch (param_no) { case 1: return fixup_igp(param); case 2: while (i--) { switch (s[i]) { /* active */ case 'a': case 'A': case '1': code |= DS_COUNT_ACTIVE; break; /* inactive */ case 'i': case 'I': case '0': code |= DS_COUNT_INACTIVE; break; /* probing */ case 'p': case 'P': case '2': code |= DS_COUNT_PROBING; break; } } break; case 3: return fixup_igp(param); } s[0] = (char)code; s[1] = '\0'; return 0; }
static int check_addr_fixup(void** param, int param_no) { if (!db_url.s || db_url.len == 0) { LM_ERR("check_address needs db_url to be set!\n"); return E_UNSPEC; } /* grp ip port proto info pattern*/ switch (param_no) { case 1: return fixup_igp(param); case 2: case 3: case 4: return fixup_spve(param); case 5: if (*param && strlen((char*)*param)) return fixup_pvar(param); *param = NULL; return 0; case 6: if (*param && strlen((char*)*param)) return fixup_spve(param); *param = NULL; return 0; } return E_UNSPEC; }
static int fixup_is_dst(void** param, int param_no) { if (param_no==1) { /* the ip to test */ return fixup_pvar(param); } else if (param_no==2) { /* the port to test */ if (*param==NULL) { return 0; } else if ( *((char*)*param)==0 ) { pkg_free(*param); *param = NULL; return 0; } return fixup_pvar(param); } else if (param_no==3) { /* the group to check in */ return fixup_igp(param); } else if (param_no==4) { /* active only check ? */ return fixup_uint(param); } else { LM_CRIT("bug - too many params (%d) in lb_is_dst()\n",param_no); return -1; } }
static int fixup_check_addr(void ** param, int param_no) { if (param_no == 1) return fixup_igp(param); else if (param_no == 2) return fixup_spve(param); else if (param_no == 3) return fixup_spve(param); LM_CRIT("Unknown parameter number %d\n", param_no); return E_UNSPEC; }
static int fixup_send(void ** param, int param_no) { if (param_no == 1 || param_no == 2) return fixup_igp(param); else if (param_no == 3) return fixup_spve(param); else if (param_no == 4) return fixup_pvar(param); LM_CRIT("Unknown parameter number %d\n", param_no); return E_UNSPEC; }
static int fixup_round_op(void **param, int param_no) { switch (param_no) { case 1: case 2: return fixup_binary_op(param, param_no); case 3: return fixup_igp(param); default: LM_ERR("Invalid parameter number: %d\n", param_no); return E_UNSPEC; } }
/* fixup functions */ static int fixup_rl_check(void **param, int param_no) { switch (param_no) { /* pipe name */ case 1: return fixup_spve(param); /* limit */ case 2: return fixup_igp(param); /* algorithm */ case 3: return fixup_sgp(param); /* error */ default: LM_ERR("[BUG] too many params (%d)\n", param_no); } return E_UNSPEC; }
/* * Fixup function for mc_compress */ static int mc_compress_fixup(void** param, int param_no) { switch (param_no) { case 1: if (fixup_igp(param)) { LM_ERR("invalid algo\n"); } break; case 2: return fixup_compression_flags(param); case 3: /* Parse the whitelist */ return set_wh_param(param, NULL); default: LM_ERR("invalid parameter\n"); return -1; } return 0; }
/** * @is_async - if set, a warning will be thrown if the underlying * driver does not support async operations, and will run queries in sync mode */ static int __fixup_db_query_avp(void** param, int param_no, int is_async) { int type; pv_elem_t *model = NULL; pvname_list_t *anlist = NULL; str s; if (default_db_url==NULL) { LM_ERR("no db url defined to be used by this function\n"); return E_CFG; } s.s = (char*)(*param); if (param_no==1) { if(s.s==NULL) { LM_ERR("null format in P%d\n", param_no); return E_UNSPEC; } s.len = strlen(s.s); if(pv_parse_format(&s, &model)<0) { LM_ERR("wrong format[%s]\n", s.s); return E_UNSPEC; } *param = (void*)model; return 0; } else if(param_no==2) { if(s.s==NULL || s.s[0]==0) { *param = NULL; return 0; } s.len = strlen(s.s); anlist = parse_pvname_list(&s, PVT_AVP); if(anlist==NULL) { LM_ERR("bad format in P%d [%s]\n", param_no, s.s); return E_UNSPEC; } *param = (void*)anlist; return 0; } else if (param_no==3) { struct db_url_container *db_id; if (*param==NULL) return 0; if (fixup_igp(param) < 0) { LM_ERR("fixup failed for param #3!\n"); return -1; } db_id=pkg_malloc(sizeof(struct db_url_container)); if (db_id==NULL) { LM_ERR("no more pkg!\n"); return -1; } if ((type=((gparam_p)*param)->type) == GPARAM_TYPE_INT) { db_id->type = URL; if (id2db_url(((gparam_p)*param)->v.ival, 1, is_async, &db_id->u.url) < 0) { LM_ERR("failed to get db url!\n"); return E_CFG; } } else if (type == GPARAM_TYPE_STR) { unsigned int int_id; if (str2int(&((gparam_p)*param)->v.sval, &int_id) < 0) { LM_ERR("failed to get db id!\n"); return -1; } db_id->type = URL; if (id2db_url(int_id, 1, is_async, &db_id->u.url) < 0) { LM_ERR("failed to get db url!\n"); return E_CFG; } } else if(type==GPARAM_TYPE_PVS||type==GPARAM_TYPE_PVE){ db_id->type = GPARAM; db_id->u.gp = (gparam_p)*param; } else { LM_ERR("invalid value for param #3!\n"); return E_CFG; } *param = db_id; } return 0; }