]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6353 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 13 Mar 2014 15:23:08 +0000 (10:23 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 13 Mar 2014 15:23:13 +0000 (10:23 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_reg.c

index 016b48989ae8ca8a0b875a1161ee145df54f02a3..f8877bd31f351b0985a67bfb67c444a748d3c010 100644 (file)
@@ -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);
index cecde4986e6694526665b9bdd87e239c006538ef..40edaf14640e0a54d65c0def845d4bd36a5f4c48 100644 (file)
@@ -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);