Adding a failed registration event and adding an auth result header on the attempt event.

This commit is contained in:
William King 2012-04-17 17:28:47 -07:00
parent 395965891e
commit 180f535490
2 changed files with 23 additions and 0 deletions

View File

@ -78,6 +78,7 @@ typedef struct private_object private_object_t;
#define MY_EVENT_REGISTER "sofia::register"
#define MY_EVENT_PRE_REGISTER "sofia::pre_register"
#define MY_EVENT_REGISTER_ATTEMPT "sofia::register_attempt"
#define MY_EVENT_REGISTER_FAILURE "sofia::register_failure"
#define MY_EVENT_UNREGISTER "sofia::unregister"
#define MY_EVENT_EXPIRE "sofia::expire"
#define MY_EVENT_GATEWAY_STATE "sofia::gateway_state"

View File

@ -1241,6 +1241,20 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "username", username);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "realm", realm);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "user-agent", agent);
switch (auth_res) {
case AUTH_OK:
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "auth-result", "SUCCESS");
break;
case AUTH_RENEWED:
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "auth-result", "RENEWED");
break;
case AUTH_STALE:
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "auth-result", "STALE");
break;
case AUTH_FORBIDDEN:
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "auth-result", "FORBIDDEN");
break;
}
switch_event_fire(&s_event);
}
@ -1378,6 +1392,14 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
(regtype == REG_INVITE) ? "INVITE" : "REGISTER", profile->name, to_user, to_host, network_ip);
}
if (forbidden && switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REGISTER_FAILURE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "to-user", to_user);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "to-host", to_host);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "network-ip", network_ip);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "registration-type", (regtype == REG_INVITE) ? "INVITE" : "REGISTER");
switch_event_fire(&s_event);
}
switch_goto_int(r, 1, end);
}
}