change xml_lookups to take an event as params instead of url string this will break your xml_curl scripts please update

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7333 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-01-23 20:59:25 +00:00
parent 14ba0b9999
commit 1424b6c73b
16 changed files with 286 additions and 103 deletions
+10 -4
View File
@@ -828,7 +828,8 @@ switch_status_t config_sofia(int reload, char *profile_name)
sofia_profile_t *profile = NULL;
char url[512] = "";
int profile_found = 0;
switch_event_t *params = NULL;;
if (!reload) {
su_init();
if (sip_update_default_mclass(sip_extend_mclass(NULL)) < 0) {
@@ -847,9 +848,11 @@ switch_status_t config_sofia(int reload, char *profile_name)
return status;
}
switch_snprintf(url, sizeof(url), "profile=%s", switch_str_nil(profile_name));
if (!(xml = switch_xml_open_cfg(cf, &cfg, url))) {
switch_event_create(&params, SWITCH_EVENT_MESSAGE);
switch_assert(params);
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "profile", profile_name);
if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
status = SWITCH_STATUS_FALSE;
goto done;
@@ -1279,6 +1282,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
}
}
done:
switch_event_destroy(&params);
if (xml) {
switch_xml_free(xml);
}
+12 -6
View File
@@ -775,8 +775,8 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
char *mailbox = NULL;
switch_xml_t domain, xml = NULL, user, param, uparams, dparams;
char hexdigest[2 * SU_MD5_DIGEST_SIZE + 1] = "";
char *pbuf = NULL;
char *domain_name = NULL;
switch_event_t *params = NULL;
username = realm = nonce = uri = qop = cnonce = nc = response = NULL;
@@ -854,9 +854,12 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
free(sql);
}
pbuf = switch_mprintf("action=sip_auth&profile=%s&user_agent=%s",
profile->name,
(sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown");
switch_event_create(&params, SWITCH_EVENT_MESSAGE);
switch_assert(params);
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "action", "sip_auth");
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "profile", profile->name);
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "user_agent", (sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown");
if (!switch_strlen_zero(profile->reg_domain)) {
domain_name = profile->reg_domain;
@@ -864,7 +867,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
domain_name = realm;
}
if (switch_xml_locate_user("id", username, domain_name, ip, &xml, &domain, &user, pbuf) != SWITCH_STATUS_SUCCESS) {
if (switch_xml_locate_user("id", username, domain_name, ip, &xml, &domain, &user, params) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", username, domain_name);
ret = AUTH_FORBIDDEN;
goto end;
@@ -1053,10 +1056,13 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
}
}
end:
switch_event_destroy(&params);
if (xml) {
switch_xml_free(xml);
}
switch_safe_free(pbuf);
switch_safe_free(input);
switch_safe_free(input2);
switch_safe_free(username);