]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] Implement maximum receiving requests per second max-recv-requests-per...
authorAndrey Volk <andywolk@gmail.com>
Wed, 13 Oct 2021 15:21:52 +0000 (18:21 +0300)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:01:06 +0000 (22:01 +0300)
conf/vanilla/sip_profiles/internal-ipv6.xml
conf/vanilla/sip_profiles/internal.xml
src/mod/endpoints/mod_sofia/conf/sofia.conf.xml
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index 21bb1f1e776face5711834753030aed820256361..f067ae74821f79d03fc70323a8e87f00f2ab1a57 100644 (file)
@@ -36,6 +36,8 @@
     <!-- <param name="bitpacking" value="aal2"/> -->
     <!--max number of open dialogs in proceeding -->
     <!--<param name="max-proceeding" value="1000"/>-->
+    <!--max number of receiving requests per second (Default: 1000, 0 - unlimited) -->
+    <!--<param name="max-recv-requests-per-second" value="0"/>-->
     <!--session timers for all call to expire after the specified seconds -->
     <!--<param name="session-timeout" value="1800"/>-->
     <!--<param name="multiple-registrations" value="true"/>-->
index 85692fa63152e52dbba9bc5c647ea8edd3a0d6a6..749e4b06879d864b8493da4530d44eb98da61088 100644 (file)
     <!-- <param name="bitpacking" value="aal2"/> -->
     <!--max number of open dialogs in proceeding -->
     <!--<param name="max-proceeding" value="1000"/>-->
+    <!--max number of receiving requests per second (Default: 1000, 0 - unlimited) -->
+    <!--<param name="max-recv-requests-per-second" value="0"/> -->
     <!--session timers for all call to expire after the specified seconds -->
     <!--<param name="session-timeout" value="1800"/>-->
     <!-- Can be 'true' or 'contact' -->
index 37e0937aeb1b0f5124fd037ced06d1f616c5f60e..0f5db4468f08e4f59fd78d417259e35f47541440 100644 (file)
         <!-- <param name="bitpacking" value="aal2"/> -->
         <!-- max number of open dialogs in proceeding -->
         <!-- <param name="max-proceeding" value="1000"/> -->
+        <!-- max number of receiving requests per second (Default: 1000, 0 - unlimited) -->
+        <!-- <param name="max-recv-requests-per-second" value="0"/> -->
         <!-- session timers for all call to expire after the specified seconds -->
         <!-- <param name="session-timeout" value="1800"/> -->
         <!-- Can be 'true' or 'contact' -->
index 1637cff9248a7adc5b0290d1516b220ea9398351..a3a6cd8e919afc817dc95a25d1a67cdd092a45b4 100644 (file)
@@ -3061,6 +3061,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
                                        stream->write_function(stream, "CNG              \t%d\n", profile->cng_pt);
                                        stream->write_function(stream, "SESSION-TO       \t%d\n", profile->session_timeout);
                                        stream->write_function(stream, "MAX-DIALOG       \t%d\n", profile->max_proceeding);
+                                       stream->write_function(stream, "MAX-RECV-RPS     \t%d\n", profile->max_recv_requests_per_second);
                                        stream->write_function(stream, "NOMEDIA          \t%s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
                                        stream->write_function(stream, "LATE-NEG         \t%s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
                                        stream->write_function(stream, "PROXY-MEDIA      \t%s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
@@ -3363,6 +3364,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
                                        stream->write_function(stream, "    <cng>%d</cng>\n", profile->cng_pt);
                                        stream->write_function(stream, "    <session-to>%d</session-to>\n", profile->session_timeout);
                                        stream->write_function(stream, "    <max-dialog>%d</max-dialog>\n", profile->max_proceeding);
+                                       stream->write_function(stream, "    <max-recv-rps>%d</max-recv-rps>\n", profile->max_recv_requests_per_second);
                                        stream->write_function(stream, "    <nomedia>%s</nomedia>\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
                                        stream->write_function(stream, "    <late-neg>%s</late-neg>\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
                                        stream->write_function(stream, "    <proxy-media>%s</proxy-media>\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
index 6e118e1fe325867f9d97c67508f4cd5a5cf5af7b..3408b7ca0bff3b61a6b7036304fa364a1c896a46 100644 (file)
@@ -722,6 +722,7 @@ struct sofia_profile {
        uint32_t session_timeout;
        uint32_t minimum_session_expires;
        uint32_t max_proceeding;
+       uint32_t max_recv_requests_per_second;
        uint32_t rtp_timeout_sec;
        uint32_t rtp_hold_timeout_sec;
        char *odbc_dsn;
index 25e3278c973187865274de0957a9306090abeb1b..36f3087db126ac3f7f3df7aed5546c935070f645 100644 (file)
@@ -3345,6 +3345,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
                                   TAG_IF(profile->session_timeout && profile->minimum_session_expires, NUTAG_MIN_SE(profile->minimum_session_expires)),
                                   NUTAG_SESSION_TIMER(profile->session_timeout),
                                   NTATAG_MAX_PROCEEDING(profile->max_proceeding),
+                                  NTATAG_MAX_RECV_REQUESTS_PER_SECOND(profile->max_recv_requests_per_second),
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW("PUBLISH")),
                                   TAG_IF(profile->pres_type, NUTAG_ALLOW("SUBSCRIBE")),
                                   TAG_IF(profile->pres_type, NUTAG_ENABLEMESSAGE(1)),
@@ -4571,6 +4572,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
                                char *auth_subscriptions_value = NULL;
                                uint8_t disable_message_auth_flag = 0;
                                uint8_t disable_subscription_auth_flag = 0;
+                               uint8_t max_recv_requests_per_second_initialized = 0;
 
                                if (!xprofilename) {
                                        xprofilename = "unnamed";
@@ -5307,6 +5309,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
                                                if (v_max_proceeding >= 0) {
                                                        profile->max_proceeding = v_max_proceeding;
                                                }
+                                       } else if (!strcasecmp(var, "max-recv-requests-per-second") && !zstr(val)) {
+                                               int v_max_recv_requests_per_second = atoi(val);
+                                               if (v_max_recv_requests_per_second >= 0) {
+                                                       profile->max_recv_requests_per_second = v_max_recv_requests_per_second;
+                                                       max_recv_requests_per_second_initialized = 1;
+                                               }
                                        } else if (!strcasecmp(var, "rtp-timeout-sec") && !zstr(val)) {
                                                int v = atoi(val);
                                                if (v >= 0) {
@@ -6097,6 +6105,10 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
                                        }
                                }
 
+                               if (!max_recv_requests_per_second_initialized) {
+                                       profile->max_recv_requests_per_second = 1000;
+                               }
+
                                if (!disable_message_auth_flag) {
                                        if (!auth_messages_value || switch_true(auth_messages_value)) {
                                                sofia_set_pflag(profile, PFLAG_AUTH_MESSAGES);