Browse code

ratelimit: export functions to kemi

(cherry picked from commit 678d93a742ba294bbe571c975814e01fdd795371)

Stefan Mititelu authored on 13/09/2022 08:24:47 • Daniel-Constantin Mierla committed on 27/09/2022 09:51:36
Showing 1 changed files
... ...
@@ -42,6 +42,7 @@
42 42
 #include "../../core/data_lump_rpl.h"
43 43
 #include "../../core/counters.h"
44 44
 #include "../../core/rpc_lookup.h"
45
+#include "../../core/kemi.h"
45 46
 #include "rl_statistics.h"
46 47
 
47 48
 
... ...
@@ -199,6 +200,8 @@ static int w_rl_check_forced(struct sip_msg*, char *, char *);
199 200
 static int w_rl_check_forced_pipe(struct sip_msg*, char *, char *);
200 201
 static int add_queue_params(modparam_t, void *);
201 202
 static int add_pipe_params(modparam_t, void *);
203
+static int ki_rl_check(struct sip_msg *msg);
204
+static int ki_rl_check_pipe(struct sip_msg *msg, int pipe);
202 205
 /* RESERVED for future use
203 206
 static int set_load_source(modparam_t, void *);
204 207
 */
... ...
@@ -1323,3 +1326,33 @@ static rpc_export_t rpc_methods[] = {
1323 1326
 	{0, 0, 0, 0}
1324 1327
 };
1325 1328
 
1329
+static sr_kemi_t sr_kemi_ratelimit_exports[] = {
1330
+        { str_init("ratelimit"), str_init("rl_check"),
1331
+                SR_KEMIP_INT, ki_rl_check,
1332
+                { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
1333
+                        SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1334
+        },
1335
+        { str_init("ratelimit"), str_init("rl_check_pipe"),
1336
+                SR_KEMIP_INT, ki_rl_check_pipe,
1337
+                { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
1338
+                        SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1339
+        },
1340
+        { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
1341
+
1342
+};
1343
+
1344
+static int ki_rl_check(struct sip_msg *msg) {
1345
+	return rl_check(msg, -1);
1346
+}
1347
+
1348
+static int ki_rl_check_pipe(struct sip_msg *msg, int pipe) {
1349
+
1350
+	LM_DBG("trying kemi pipe %d\n", pipe);
1351
+	return rl_check(msg, pipe);
1352
+}
1353
+
1354
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
1355
+{
1356
+        sr_kemi_modules_add(sr_kemi_ratelimit_exports);
1357
+        return 0;
1358
+}