diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 016b48989a..f8877bd31f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -949,10 +949,11 @@ void sofia_reg_unregister(sofia_profile_t *profile); void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp); switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status); void sofia_glue_do_xfer_invite(switch_core_session_t *session); -uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, +uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, sofia_dispatch_event_t *de, sofia_regtype_t regtype, char *key, - uint32_t keylen, switch_event_t **v_event, const char *is_nat, sofia_private_t **sofia_private_p, switch_xml_t *user_xml); + uint32_t keylen, switch_event_t **v_event, const char *is_nat, sofia_private_t **sofia_private_p, switch_xml_t *user_xml, char *sw_acl_token); +#define sofia_reg_handle_register(_nua_, _profile_, _nh_, _sip_, _de_, _regtype_, _key_, _keylen_, _v_event_, _is_nat_, _sofia_private_p_, _user_xml_) sofia_reg_handle_register_token(_nua_, _profile_, _nh_, _sip_, _de_, _regtype_, _key_, _keylen_, _v_event_, _is_nat_, _sofia_private_p_, _user_xml_, NULL) extern switch_endpoint_interface_t *sofia_endpoint_interface; void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip); switch_status_t sofia_on_hangup(switch_core_session_t *session); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index cecde4986e..40edaf1464 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1116,9 +1116,9 @@ void sofia_reg_close_handles(sofia_profile_t *profile) } -uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, +uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, sofia_dispatch_event_t *de, sofia_regtype_t regtype, char *key, - uint32_t keylen, switch_event_t **v_event, const char *is_nat, sofia_private_t **sofia_private_p, switch_xml_t *user_xml) + uint32_t keylen, switch_event_t **v_event, const char *is_nat, sofia_private_t **sofia_private_p, switch_xml_t *user_xml, char *sw_acl_token) { sip_to_t const *to = NULL; sip_from_t const *from = NULL; @@ -1172,6 +1172,8 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand const char *p; char *utmp = NULL; sofia_private_t *sofia_private = NULL; + char *sw_to_user; + char *sw_reg_host; if (sofia_private_p) { sofia_private = *sofia_private_p; @@ -1398,6 +1400,11 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand if (regtype == REG_AUTO_REGISTER || (regtype == REG_REGISTER && sofia_test_pflag(profile, PFLAG_BLIND_REG))) { regtype = REG_REGISTER; + if (sw_acl_token) { + switch_split_user_domain(sw_acl_token, &sw_to_user, &sw_reg_host); + to_user = sw_to_user; + reg_host = sw_reg_host; + } goto reg; } @@ -2067,6 +2074,7 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h sofia_regtype_t type = REG_REGISTER; int network_port = 0; char *is_nat = NULL; + char acl_token[512] = ""; #if 0 /* This seems to cause undesirable effects so nevermind */ @@ -2144,16 +2152,20 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h uint32_t x = 0; int ok = 1; char *last_acl = NULL; + const char *token_sw = NULL; for (x = 0; x < profile->reg_acl_count; x++) { last_acl = profile->reg_acl[x]; - if (!(ok = switch_check_network_list_ip(network_ip, last_acl))) { + if (!(ok = switch_check_network_list_ip_token(network_ip, last_acl, &token_sw))) { break; } } if (ok && !sofia_test_pflag(profile, PFLAG_BLIND_REG)) { type = REG_AUTO_REGISTER; + if (token_sw) { + switch_set_string(acl_token, token_sw); + } } else if (!ok) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by register acl \"%s\"\n", network_ip, profile->reg_acl[x]); nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END()); @@ -2174,7 +2186,7 @@ void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_h is_nat = NULL; } - sofia_reg_handle_register(nua, profile, nh, sip, de, type, key, sizeof(key), &v_event, is_nat, sofia_private_p, NULL); + sofia_reg_handle_register_token(nua, profile, nh, sip, de, type, key, sizeof(key), &v_event, is_nat, sofia_private_p, NULL, acl_token); if (v_event) { switch_event_destroy(&v_event);