int cmd_check_addr(struct sip_msg *msg, char *param_cluster, char *param_ip, char *param_addr_type) { int cluster_id; str ip_str; str addr_type_str; static str bin_addr_t = str_init("bin"); static str sip_addr_t = str_init("sip"); enum node_addr_type check_type; if (fixup_get_ivalue(msg, (gparam_p)param_cluster, &cluster_id) < 0) { LM_ERR("Failed to fetch cluster id parameter\n"); return -1; } if (fixup_get_svalue(msg, (gparam_p)param_ip, &ip_str) < 0) { LM_ERR("Failed to fetch ip parameter\n"); return -1; } if (param_addr_type && fixup_get_svalue(msg, (gparam_p)param_addr_type, &addr_type_str) < 0) { LM_ERR("Failed to fetch address type parameter\n"); return -1; } if (param_addr_type) { if (!str_strcasecmp(&addr_type_str, &bin_addr_t)) check_type = NODE_BIN_ADDR; else if (!str_strcasecmp(&addr_type_str, &sip_addr_t)) check_type = NODE_SIP_ADDR; else { LM_ERR("Bad address type, should be 'bin' or 'sip'\n"); return -1; } } else check_type = NODE_SIP_ADDR; if (clusterer_check_addr(cluster_id, &ip_str, check_type) == 0) return -1; else return 1; }
int cmd_check_addr(struct sip_msg *msg, int *cluster_id, str *ip_str, str *addr_type_str) { static str bin_addr_t = str_init("bin"); static str sip_addr_t = str_init("sip"); enum node_addr_type check_type; if (addr_type_str) { if (!str_strcasecmp(addr_type_str, &bin_addr_t)) check_type = NODE_BIN_ADDR; else if (!str_strcasecmp(addr_type_str, &sip_addr_t)) check_type = NODE_SIP_ADDR; else { LM_ERR("Bad address type, should be 'bin' or 'sip'\n"); return -1; } } else check_type = NODE_SIP_ADDR; if (clusterer_check_addr(*cluster_id, ip_str, check_type) == 0) return -1; else return 1; }