diff --git a/src/modules/h350/h350_exp_fn.c b/src/modules/h350/h350_exp_fn.c index 09c5c49aa2d..a2bcee0da21 100644 --- a/src/modules/h350/h350_exp_fn.c +++ b/src/modules/h350/h350_exp_fn.c @@ -48,7 +48,7 @@ static str h350_service_level_name = str_init("SIPIdentityServiceLevel"); static regex_t* call_pref_preg; -int h350_sipuri_lookup(struct sip_msg* _msg, pv_elem_t* _sip_uri) +int h350_sipuri_lookup(struct sip_msg *_msg, pv_elem_t *_sip_uri) { str sip_uri, sip_uri_escaped; int ld_result_count; @@ -57,8 +57,7 @@ int h350_sipuri_lookup(struct sip_msg* _msg, pv_elem_t* _sip_uri) /* * get sip_uri */ - if (pv_printf_s(_msg, _sip_uri, &sip_uri) != 0) - { + if(pv_printf_s(_msg, _sip_uri, &sip_uri) != 0) { LM_ERR("pv_printf_s failed\n"); return E_H350_INTERNAL; } @@ -68,64 +67,50 @@ int h350_sipuri_lookup(struct sip_msg* _msg, pv_elem_t* _sip_uri) */ sip_uri_escaped.s = sip_uri_escaped_buf; sip_uri_escaped.len = SIP_URI_ESCAPED_MAX_LEN - 1; - if (ldap_api.ldap_rfc4515_escape(&sip_uri, &sip_uri_escaped, 0)) - { + if(ldap_api.ldap_rfc4515_escape(&sip_uri, &sip_uri_escaped, 0)) { LM_ERR("ldap_rfc4515_escape failed\n"); return E_H350_INTERNAL; } - + /* * do ldap search */ - if (ldap_api.ldap_params_search(&ld_result_count, - h350_ldap_session, - h350_base_dn, - h350_search_scope_int, - NULL, - H350_SIPURI_LOOKUP_LDAP_FILTER, - sip_uri_escaped.s) - != 0) - { + if(ldap_api.ldap_params_search(&ld_result_count, h350_ldap_session, + h350_base_dn, h350_search_scope_int, NULL, + H350_SIPURI_LOOKUP_LDAP_FILTER, sip_uri_escaped.s) + != 0) { LM_ERR("ldap search failed\n"); return E_H350_INTERNAL; } - - if (ld_result_count < 1) - { + + if(ld_result_count < 1) { return E_H350_NO_SUCCESS; } return ld_result_count; } -int h350_auth_lookup( - struct sip_msg* _msg, - pv_elem_t* _digest_username, - struct h350_auth_lookup_avp_params* _avp_specs) +int h350_auth_lookup(struct sip_msg *_msg, pv_elem_t *_digest_username, + struct h350_auth_lookup_avp_params *_avp_specs) { - str digest_username, - digest_username_escaped, - digest_password; - static char digest_username_buf[DIGEST_USERNAME_BUF_SIZE], - username_avp_name_buf[AVP_NAME_STR_BUF_LEN], - password_avp_name_buf[AVP_NAME_STR_BUF_LEN]; - struct berval **attr_vals = NULL; - int_str username_avp_name, password_avp_name, avp_val; - unsigned short username_avp_type, password_avp_type; - int rc, ld_result_count; + str digest_username, digest_username_escaped, digest_password; + static char digest_username_buf[DIGEST_USERNAME_BUF_SIZE], + username_avp_name_buf[AVP_NAME_STR_BUF_LEN], + password_avp_name_buf[AVP_NAME_STR_BUF_LEN]; + struct berval **attr_vals = NULL; + int_str username_avp_name, password_avp_name, avp_val; + unsigned short username_avp_type, password_avp_type; + int rc, ld_result_count; /* * get digest_username str */ - if (_digest_username) - { - if (pv_printf_s(_msg, _digest_username, &digest_username) != 0) - { - LM_ERR("pv_printf_s failed\n"); - return E_H350_INTERNAL; - } - } else - { + if(_digest_username) { + if(pv_printf_s(_msg, _digest_username, &digest_username) != 0) { + LM_ERR("pv_printf_s failed\n"); + return E_H350_INTERNAL; + } + } else { LM_ERR("empty digest username\n"); return E_H350_NO_SUCCESS; } @@ -134,178 +119,144 @@ int h350_auth_lookup( * get AVP names for username and password */ - if (pv_get_avp_name( _msg, - &(_avp_specs->username_avp_spec.pvp), - &username_avp_name, - &username_avp_type) - != 0) - { + if(pv_get_avp_name(_msg, &(_avp_specs->username_avp_spec.pvp), + &username_avp_name, &username_avp_type) + != 0) { LM_ERR("error getting AVP name - pv_get_avp_name failed\n"); return E_H350_INTERNAL; } - if (username_avp_type & AVP_NAME_STR) - { - if (username_avp_name.s.len >= AVP_NAME_STR_BUF_LEN) - { + if(username_avp_type & AVP_NAME_STR) { + if(username_avp_name.s.len >= AVP_NAME_STR_BUF_LEN) { LM_ERR("username AVP name too long\n"); return E_H350_INTERNAL; } - strncpy(username_avp_name_buf, username_avp_name.s.s, username_avp_name.s.len); - username_avp_name_buf[username_avp_name.s.len] = '\0'; - username_avp_name.s.s = username_avp_name_buf; + strncpy(username_avp_name_buf, username_avp_name.s.s, + username_avp_name.s.len); + username_avp_name_buf[username_avp_name.s.len] = '\0'; + username_avp_name.s.s = username_avp_name_buf; + } + + if(pv_get_avp_name(_msg, &(_avp_specs->password_avp_spec.pvp), + &password_avp_name, &password_avp_type) + != 0) { + LM_ERR("error getting AVP name - pv_get_avp_name failed\n"); + return E_H350_INTERNAL; + } + if(password_avp_type & AVP_NAME_STR) { + if(password_avp_name.s.len >= AVP_NAME_STR_BUF_LEN) { + LM_ERR("password AVP name too long\n"); + return E_H350_INTERNAL; + } + strncpy(password_avp_name_buf, password_avp_name.s.s, + password_avp_name.s.len); + password_avp_name_buf[password_avp_name.s.len] = '\0'; + password_avp_name.s.s = password_avp_name_buf; } - if (pv_get_avp_name(_msg, - &(_avp_specs->password_avp_spec.pvp), - &password_avp_name, - &password_avp_type) - != 0) - { - LM_ERR("error getting AVP name - pv_get_avp_name failed\n"); - return E_H350_INTERNAL; - } - if (password_avp_type & AVP_NAME_STR) - { - if (password_avp_name.s.len >= AVP_NAME_STR_BUF_LEN) - { - LM_ERR("password AVP name too long\n"); - return E_H350_INTERNAL; - } - strncpy(password_avp_name_buf, - password_avp_name.s.s, - password_avp_name.s.len); - password_avp_name_buf[password_avp_name.s.len] = '\0'; - password_avp_name.s.s = password_avp_name_buf; - } - /* * search for sip digest username in H.350, store digest password */ - + /* ldap filter escape digest username */ digest_username_escaped.s = digest_username_buf; digest_username_escaped.len = DIGEST_USERNAME_BUF_SIZE - 1; - if (ldap_api.ldap_rfc4515_escape( - &digest_username, - &digest_username_escaped, - 0) - ) - { - LM_ERR("ldap_rfc4515_escape() failed\n"); - return E_H350_INTERNAL; - } + if(ldap_api.ldap_rfc4515_escape( + &digest_username, &digest_username_escaped, 0)) { + LM_ERR("ldap_rfc4515_escape() failed\n"); + return E_H350_INTERNAL; + } /* do ldap search */ - if (ldap_api.ldap_params_search(&ld_result_count, - h350_ldap_session, - h350_base_dn, - h350_search_scope_int, - NULL, - H350_AUTH_FILTER_PATTERN, - digest_username_escaped.s) - != 0) - { - LM_ERR("LDAP search failed\n"); + if(ldap_api.ldap_params_search(&ld_result_count, h350_ldap_session, + h350_base_dn, h350_search_scope_int, NULL, + H350_AUTH_FILTER_PATTERN, digest_username_escaped.s) + != 0) { + LM_ERR("LDAP search failed\n"); return E_H350_INTERNAL; - } + } - if (ld_result_count < 1) - { + if(ld_result_count < 1) { LM_INFO("no H.350 entry found for username [%s]\n", - digest_username_escaped.s); + digest_username_escaped.s); return E_H350_NO_SUCCESS; } - if (ld_result_count > 1) - { + if(ld_result_count > 1) { LM_WARN("more than one [%d] H.350 entry found for username [%s]\n", - ld_result_count, - digest_username_escaped.s); + ld_result_count, digest_username_escaped.s); } /* get ldap result values */ rc = ldap_api.ldap_result_attr_vals(&h350_sip_pwd_name, &attr_vals); - if (rc < 0) - { - LM_ERR("getting LDAP attribute values failed\n"); - ldap_api.ldap_value_free_len(attr_vals); + if(rc < 0) { + LM_ERR("getting LDAP attribute values failed\n"); + ldap_api.ldap_value_free_len(attr_vals); return E_H350_INTERNAL; - } - if ((rc > 0) || (attr_vals == NULL)) - { - LM_INFO("no values found in LDAP entry for username [%s]\n", - digest_username_escaped.s); + } + if((rc > 0) || (attr_vals == NULL)) { + LM_INFO("no values found in LDAP entry for username [%s]\n", + digest_username_escaped.s); ldap_api.ldap_value_free_len(attr_vals); return E_H350_INTERNAL; - } + } digest_password.s = attr_vals[0]->bv_val; - digest_password.len = attr_vals[0]->bv_len; + digest_password.len = attr_vals[0]->bv_len; /* * write AVPs */ - + avp_val.s = digest_username; - if (add_avp( username_avp_type | AVP_VAL_STR, - username_avp_name, - avp_val) - < 0) - { + if(add_avp(username_avp_type | AVP_VAL_STR, username_avp_name, avp_val) + < 0) { LM_ERR("failed to create new AVP\n"); ldap_api.ldap_value_free_len(attr_vals); return E_H350_INTERNAL; } avp_val.s = digest_password; - if (add_avp( password_avp_type | AVP_VAL_STR, - password_avp_name, - avp_val) - < 0) - { - LM_ERR("failed to create new AVP\n"); - ldap_api.ldap_value_free_len(attr_vals); - return E_H350_INTERNAL; - } + if(add_avp(password_avp_type | AVP_VAL_STR, password_avp_name, avp_val) + < 0) { + LM_ERR("failed to create new AVP\n"); + ldap_api.ldap_value_free_len(attr_vals); + return E_H350_INTERNAL; + } ldap_api.ldap_value_free_len(attr_vals); return E_H350_SUCCESS; } -int h350_call_preferences(struct sip_msg* _msg, pv_elem_t* _avp_name_prefix) +int h350_call_preferences(struct sip_msg *_msg, pv_elem_t *_avp_name_prefix) { - int rc, i, avp_count = 0; + int rc, i, avp_count = 0; struct berval **attr_vals; - size_t nmatch = 5; - regmatch_t pmatch[5]; - int_str avp_name, avp_val; - str avp_val_str, avp_name_str, - avp_name_prefix_str, call_pref_timeout_str; - int call_pref_timeout; - static char call_pref_avp_name[AVP_NAME_STR_BUF_LEN]; - - /* + size_t nmatch = 5; + regmatch_t pmatch[5]; + int_str avp_name, avp_val; + str avp_val_str, avp_name_str, avp_name_prefix_str, call_pref_timeout_str; + int call_pref_timeout; + static char call_pref_avp_name[AVP_NAME_STR_BUF_LEN]; + + /* * get avp_name_prefix_str */ - if (pv_printf_s(_msg, _avp_name_prefix, &avp_name_prefix_str) != 0) - { - LM_ERR("pv_printf_s failed\n"); - return E_H350_INTERNAL; - } + if(pv_printf_s(_msg, _avp_name_prefix, &avp_name_prefix_str) != 0) { + LM_ERR("pv_printf_s failed\n"); + return E_H350_INTERNAL; + } + - /* * get LDAP attribute values */ - if ((rc = ldap_api.ldap_result_attr_vals( - &h350_call_pref_name, &attr_vals)) < 0) - { + if((rc = ldap_api.ldap_result_attr_vals(&h350_call_pref_name, &attr_vals)) + < 0) { LM_ERR("Getting LDAP attribute values failed\n"); return E_H350_INTERNAL; } - if (rc > 0) - { + if(rc > 0) { /* no LDAP values found */ return E_H350_NO_SUCCESS; } @@ -315,40 +266,38 @@ int h350_call_preferences(struct sip_msg* _msg, pv_elem_t* _avp_name_prefix) */ /* copy avp name prefix into call_pref_avp_name */ - if (avp_name_prefix_str.len < AVP_NAME_STR_BUF_LEN) - { - memcpy(call_pref_avp_name, avp_name_prefix_str.s, avp_name_prefix_str.len); - } else - { - LM_ERR("AVP name prefix too long [%d] (max [%d])", - avp_name_prefix_str.len, - AVP_NAME_STR_BUF_LEN); + if(avp_name_prefix_str.len < AVP_NAME_STR_BUF_LEN) { + memcpy(call_pref_avp_name, avp_name_prefix_str.s, + avp_name_prefix_str.len); + } else { + LM_ERR("AVP name prefix too long [%d] (max [%d])", + avp_name_prefix_str.len, AVP_NAME_STR_BUF_LEN); return E_H350_INTERNAL; } - for (i = 0; attr_vals[i] != NULL; i++) - { - if ((rc = regexec(call_pref_preg, attr_vals[i]->bv_val, nmatch, pmatch, 0)) != 0) - { - switch (rc) - { - case REG_NOMATCH: - LM_INFO("no h350 call preference regex match for [%s]\n", - attr_vals[i]->bv_val); - continue; - case REG_ESPACE: - LM_ERR("regexec returned REG_ESPACE - out of memory\n"); - default: - LM_ERR("regexec failed\n"); - ldap_api.ldap_value_free_len(attr_vals); - return E_H350_INTERNAL; + for(i = 0; attr_vals[i] != NULL; i++) { + if((rc = regexec( + call_pref_preg, attr_vals[i]->bv_val, nmatch, pmatch, 0)) + != 0) { + switch(rc) { + case REG_NOMATCH: + LM_INFO("no h350 call preference regex match for [%s]\n", + attr_vals[i]->bv_val); + continue; + case REG_ESPACE: + LM_ERR("regexec returned REG_ESPACE - out of memory\n"); + ldap_api.ldap_value_free_len(attr_vals); + return E_H350_INTERNAL; + default: + LM_ERR("regexec failed\n"); + ldap_api.ldap_value_free_len(attr_vals); + return E_H350_INTERNAL; } } /* calculate call preference sip uri */ - if (avp_name_prefix_str.len + pmatch[2].rm_eo - pmatch[2].rm_so - >= AVP_NAME_STR_BUF_LEN) - { + if(avp_name_prefix_str.len + pmatch[2].rm_eo - pmatch[2].rm_so + >= AVP_NAME_STR_BUF_LEN) { LM_ERR("AVP name too long for [%s]", attr_vals[i]->bv_val); continue; } @@ -356,43 +305,41 @@ int h350_call_preferences(struct sip_msg* _msg, pv_elem_t* _avp_name_prefix) avp_val_str.len = pmatch[1].rm_eo - pmatch[1].rm_so; avp_val.s = avp_val_str; - + /* calculate call preference avp name */ - memcpy( call_pref_avp_name + avp_name_prefix_str.len, - attr_vals[i]->bv_val + pmatch[2].rm_so, - pmatch[2].rm_eo - pmatch[2].rm_so); + memcpy(call_pref_avp_name + avp_name_prefix_str.len, + attr_vals[i]->bv_val + pmatch[2].rm_so, + pmatch[2].rm_eo - pmatch[2].rm_so); avp_name_str.s = call_pref_avp_name; - avp_name_str.len = avp_name_prefix_str.len + pmatch[2].rm_eo - pmatch[2].rm_so; + avp_name_str.len = + avp_name_prefix_str.len + pmatch[2].rm_eo - pmatch[2].rm_so; avp_name.s = avp_name_str; - + /* add avp */ - if (add_avp(AVP_NAME_STR | AVP_VAL_STR, avp_name, avp_val) < 0) - { + if(add_avp(AVP_NAME_STR | AVP_VAL_STR, avp_name, avp_val) < 0) { LM_ERR("failed to create new AVP\n"); ldap_api.ldap_value_free_len(attr_vals); return E_H350_INTERNAL; } avp_count++; - + /* check for call preference timeout */ - if ((pmatch[4].rm_eo - pmatch[4].rm_so) == 0) - { + if((pmatch[4].rm_eo - pmatch[4].rm_so) == 0) { continue; } - + /* calculate call preference timeout avp name */ - memcpy( avp_name_str.s + avp_name_str.len, "_t", 2); + memcpy(avp_name_str.s + avp_name_str.len, "_t", 2); avp_name_str.len += 2; avp_name.s = avp_name_str; /* calculate timeout avp value */ call_pref_timeout_str.s = attr_vals[i]->bv_val + pmatch[4].rm_so; call_pref_timeout_str.len = pmatch[4].rm_eo - pmatch[4].rm_so; - if (str2sint(&call_pref_timeout_str, &call_pref_timeout) != 0) - { + if(str2sint(&call_pref_timeout_str, &call_pref_timeout) != 0) { LM_ERR("str2sint failed\n"); ldap_api.ldap_value_free_len(attr_vals); return E_H350_INTERNAL; @@ -401,124 +348,110 @@ int h350_call_preferences(struct sip_msg* _msg, pv_elem_t* _avp_name_prefix) /* add timeout avp */ avp_val.n = call_pref_timeout; - if (add_avp(AVP_NAME_STR, avp_name, avp_val) < 0) - { - LM_ERR("failed to create new AVP\n"); + if(add_avp(AVP_NAME_STR, avp_name, avp_val) < 0) { + LM_ERR("failed to create new AVP\n"); ldap_api.ldap_value_free_len(attr_vals); - return E_H350_INTERNAL; - } + return E_H350_INTERNAL; + } } ldap_api.ldap_value_free_len(attr_vals); - if (avp_count > 0) - { + if(avp_count > 0) { return avp_count; - } else - { + } else { return E_H350_NO_SUCCESS; } } -int h350_service_level(struct sip_msg* _msg, pv_elem_t* _avp_name_prefix) +int h350_service_level(struct sip_msg *_msg, pv_elem_t *_avp_name_prefix) { - int i, rc, avp_count = 0; - str avp_name_prefix; - int_str avp_name, avp_val; + int i, rc, avp_count = 0; + str avp_name_prefix; + int_str avp_name, avp_val; struct berval **attr_vals; - static char service_level_avp_name[AVP_NAME_STR_BUF_LEN]; + static char service_level_avp_name[AVP_NAME_STR_BUF_LEN]; - /* + /* * get service_level */ - if (pv_printf_s(_msg, _avp_name_prefix, &avp_name_prefix) != 0) - { - LM_ERR("pv_printf_s failed\n"); - return E_H350_INTERNAL; - } + if(pv_printf_s(_msg, _avp_name_prefix, &avp_name_prefix) != 0) { + LM_ERR("pv_printf_s failed\n"); + return E_H350_INTERNAL; + } - /* + /* * get LDAP attribute values */ - if ((rc = ldap_api.ldap_result_attr_vals(&h350_service_level_name, &attr_vals)) < 0) - { - LM_ERR("Getting LDAP attribute values failed\n"); - return E_H350_INTERNAL; - } - if (rc > 0) - { - /* no LDAP values found */ - return E_H350_NO_SUCCESS; - } - - /* copy avp name prefix into service_level_avp_name */ - if (avp_name_prefix.len < AVP_NAME_STR_BUF_LEN) - { - memcpy(service_level_avp_name, avp_name_prefix.s, avp_name_prefix.len); - } else - { - LM_ERR("AVP name prefix too long [%d] (max [%d])\n", - avp_name_prefix.len, - AVP_NAME_STR_BUF_LEN); + if((rc = ldap_api.ldap_result_attr_vals( + &h350_service_level_name, &attr_vals)) + < 0) { + LM_ERR("Getting LDAP attribute values failed\n"); + return E_H350_INTERNAL; + } + if(rc > 0) { + /* no LDAP values found */ + return E_H350_NO_SUCCESS; + } + + /* copy avp name prefix into service_level_avp_name */ + if(avp_name_prefix.len < AVP_NAME_STR_BUF_LEN) { + memcpy(service_level_avp_name, avp_name_prefix.s, avp_name_prefix.len); + } else { + LM_ERR("AVP name prefix too long [%d] (max [%d])\n", + avp_name_prefix.len, AVP_NAME_STR_BUF_LEN); ldap_api.ldap_value_free_len(attr_vals); - return E_H350_INTERNAL; - } - + return E_H350_INTERNAL; + } + /* * loop through service level values and add AVP(s) */ - for (i = 0; attr_vals[i] != NULL; i++) - { + for(i = 0; attr_vals[i] != NULL; i++) { /* get avp name */ - if (avp_name_prefix.len + attr_vals[i]->bv_len >= AVP_NAME_STR_BUF_LEN) - { + if(avp_name_prefix.len + attr_vals[i]->bv_len >= AVP_NAME_STR_BUF_LEN) { LM_ERR("AVP name too long for [%s]\n", attr_vals[i]->bv_val); continue; } - memcpy( service_level_avp_name + avp_name_prefix.len, - attr_vals[i]->bv_val, - attr_vals[i]->bv_len); + memcpy(service_level_avp_name + avp_name_prefix.len, + attr_vals[i]->bv_val, attr_vals[i]->bv_len); avp_name.s.s = service_level_avp_name; avp_name.s.len = avp_name_prefix.len + attr_vals[i]->bv_len; - + /* avp value = 1 */ avp_val.n = 1; - if (add_avp(AVP_NAME_STR, avp_name, avp_val) < 0) - { - LM_ERR("failed to create new AVP\n"); - ldap_api.ldap_value_free_len(attr_vals); - return E_H350_INTERNAL; - } + if(add_avp(AVP_NAME_STR, avp_name, avp_val) < 0) { + LM_ERR("failed to create new AVP\n"); + ldap_api.ldap_value_free_len(attr_vals); + return E_H350_INTERNAL; + } avp_count++; } ldap_api.ldap_value_free_len(attr_vals); - if (avp_count > 0) - { - return avp_count; - } else - { - return E_H350_NO_SUCCESS; - } + if(avp_count > 0) { + return avp_count; + } else { + return E_H350_NO_SUCCESS; + } } int h350_exp_fn_init(void) { int rc; - if ((call_pref_preg = pkg_malloc(sizeof(regex_t))) == 0) - { + if((call_pref_preg = pkg_malloc(sizeof(regex_t))) == 0) { LM_ERR("allocating memory for regex failed\n"); return -1; } - if ((rc = regcomp(call_pref_preg, H350_CALL_PREF_REGEX, REG_EXTENDED)) != 0) - { + if((rc = regcomp(call_pref_preg, H350_CALL_PREF_REGEX, REG_EXTENDED)) + != 0) { pkg_free(call_pref_preg); LM_ERR("regcomp failed - returned [%d]\n", rc); return -1; } return 0; -} +} \ No newline at end of file diff --git a/src/modules/h350/h350_mod.c b/src/modules/h350/h350_mod.c index d103120d3e9..3e8ed607956 100644 --- a/src/modules/h350/h350_mod.c +++ b/src/modules/h350/h350_mod.c @@ -118,24 +118,23 @@ struct module_exports exports = { static int child_init(int rank) { - + /* don't do anything for non-worker process */ - if (rank < 1) { - return 0; + if(rank < 1) { + return 0; } h350_search_scope_int = ldap_api.ldap_str2scope(h350_search_scope); - /* + /* * initialize h350_exp_fn */ - if (h350_exp_fn_init() != 0) - { - LM_ERR("h350_exp_fn_init failed\n"); - return -1; - } + if(h350_exp_fn_init() != 0) { + LM_ERR("h350_exp_fn_init failed\n"); + return -1; + } + - return 0; } @@ -145,105 +144,94 @@ static int mod_init(void) /* * load the LDAP API */ - if (load_ldap_api(&ldap_api) != 0) - { + if(load_ldap_api(&ldap_api) != 0) { LM_ERR("Unable to load LDAP API - this module requires ldap module\n"); return -1; } return 0; - - /* - * check module parameters - */ - if (ldap_api.ldap_str2scope(h350_search_scope) == -1) - { - LM_ERR("Invalid search_scope [%s]\n", h350_search_scope); - return -1; - } - } /* * EXPORTED functions */ -static int w_h350_sipuri_lookup(struct sip_msg* msg, char* sip_uri, char* s2) +static int w_h350_sipuri_lookup(struct sip_msg *msg, char *sip_uri, char *s2) { - return h350_sipuri_lookup(msg, (pv_elem_t*)sip_uri); + return h350_sipuri_lookup(msg, (pv_elem_t *)sip_uri); } -static int w_h350_auth_lookup(struct sip_msg* msg, char* digest_username, char* avp_specs) +static int w_h350_auth_lookup( + struct sip_msg *msg, char *digest_username, char *avp_specs) { - return h350_auth_lookup( - msg, - (pv_elem_t*)digest_username, - (struct h350_auth_lookup_avp_params*)avp_specs); + return h350_auth_lookup(msg, (pv_elem_t *)digest_username, + (struct h350_auth_lookup_avp_params *)avp_specs); } -static int w_h350_call_preferences(struct sip_msg* msg, char* avp_name_prefix, char* s2) +static int w_h350_call_preferences( + struct sip_msg *msg, char *avp_name_prefix, char *s2) { - return h350_call_preferences(msg, (pv_elem_t*)avp_name_prefix); + return h350_call_preferences(msg, (pv_elem_t *)avp_name_prefix); } -static int w_h350_service_level(struct sip_msg* msg, char* avp_name_prefix, char* s2) +static int w_h350_service_level( + struct sip_msg *msg, char *avp_name_prefix, char *s2) { - return h350_service_level(msg, (pv_elem_t*)avp_name_prefix); + return h350_service_level(msg, (pv_elem_t *)avp_name_prefix); } /* * FIXUP functions */ -static int one_str_pv_elem_fixup(void** param, int param_no) +static int one_str_pv_elem_fixup(void **param, int param_no) { pv_elem_t *model; str s; - if (param_no == 1) { - s.s = (char*)*param; - if (s.s==0 || s.s[0]==0) { + if(param_no == 1) { + s.s = (char *)*param; + if(s.s == 0 || s.s[0] == 0) { model = 0; } else { s.len = strlen(s.s); - if (pv_parse_format(&s,&model)<0) { + if(pv_parse_format(&s, &model) < 0) { LM_ERR("pv_parse_format failed\n"); return E_OUT_OF_MEM; } } - *param = (void*)model; + *param = (void *)model; } return 0; } -static int h350_auth_lookup_fixup(void** param, int param_no) +static int h350_auth_lookup_fixup(void **param, int param_no) { pv_elem_t *model; - char *p, *username_avp_spec_str, *pwd_avp_spec_str; + char *p, *username_avp_spec_str, *pwd_avp_spec_str; str s; struct h350_auth_lookup_avp_params *params; - if (param_no == 1) - { - s.s = (char*)*param; - if (s.s==0 || s.s[0]==0) { - model = 0; + if(param_no == 1) { + s.s = (char *)*param; + if(s.s == 0 || s.s[0] == 0) { + model = 0; } else { - if (pv_parse_format(&s,&model)<0) { - LM_ERR("pv_parse_format failed\n"); - return E_OUT_OF_MEM; - } - } - *param = (void*)model; - } else if (param_no == 2) { + s.len = strlen(s.s); + if(pv_parse_format(&s, &model) < 0) { + LM_ERR("pv_parse_format failed\n"); + return E_OUT_OF_MEM; + } + } + *param = (void *)model; + } else if(param_no == 2) { /* * parse *param into username_avp_spec_str and pwd_avp_spec_str */ - - username_avp_spec_str = (char*)*param; - if ((pwd_avp_spec_str = strchr(username_avp_spec_str, '/')) == 0) - { + + username_avp_spec_str = (char *)*param; + if((pwd_avp_spec_str = strchr(username_avp_spec_str, '/')) == 0) { /* no '/' found in username_avp_spec_str */ LM_ERR("invalid second argument [%s]\n", username_avp_spec_str); return E_UNSPEC; @@ -253,45 +241,42 @@ static int h350_auth_lookup_fixup(void** param, int param_no) /* * parse avp specs into pv_spec_t and store in params */ - params = (struct h350_auth_lookup_avp_params*)pkg_malloc - (sizeof(struct h350_auth_lookup_avp_params)); - if (params == NULL) - { + params = (struct h350_auth_lookup_avp_params *)pkg_malloc( + sizeof(struct h350_auth_lookup_avp_params)); + if(params == NULL) { LM_ERR("no memory\n"); return E_OUT_OF_MEM; } memset(params, 0, sizeof(struct h350_auth_lookup_avp_params)); - s.s = username_avp_spec_str; s.len = strlen(s.s); + s.s = username_avp_spec_str; + s.len = strlen(s.s); p = pv_parse_spec(&s, ¶ms->username_avp_spec); - if (p == 0) - { + if(p == 0) { pkg_free(params); LM_ERR("parse error for [%s]\n", username_avp_spec_str); return E_UNSPEC; } - if (params->username_avp_spec.type != PVT_AVP) - { + if(params->username_avp_spec.type != PVT_AVP) { pkg_free(params); LM_ERR("invalid AVP specification [%s]\n", username_avp_spec_str); return E_UNSPEC; } - s.s = pwd_avp_spec_str; s.len = strlen(s.s); + s.s = pwd_avp_spec_str; + s.len = strlen(s.s); p = pv_parse_spec(&s, ¶ms->password_avp_spec); - if (p == 0) - { - pkg_free(params); - LM_ERR("parse error for [%s]\n", pwd_avp_spec_str); - return E_UNSPEC; - } - if (params->password_avp_spec.type != PVT_AVP) - { - pkg_free(params); - LM_ERR("invalid AVP specification [%s]\n", pwd_avp_spec_str); - return E_UNSPEC; - } - - *param = (void*)params; + if(p == 0) { + pkg_free(params); + LM_ERR("parse error for [%s]\n", pwd_avp_spec_str); + return E_UNSPEC; + } + if(params->password_avp_spec.type != PVT_AVP) { + pkg_free(params); + LM_ERR("invalid AVP specification [%s]\n", pwd_avp_spec_str); + return E_UNSPEC; + } + + *param = (void *)params; } - return 0; -} + return 0; +} \ No newline at end of file