Module: kamailio
Branch: master
Commit: a138f65cd5e4f810d3311891ac01a323a76c4807
URL: 
https://github.com/kamailio/kamailio/commit/a138f65cd5e4f810d3311891ac01a323a76c4807

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2017-04-18T14:07:27+02:00

geoip: exported functions to kemi framework

---

Modified: src/modules/geoip/geoip_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/a138f65cd5e4f810d3311891ac01a323a76c4807.diff
Patch: 
https://github.com/kamailio/kamailio/commit/a138f65cd5e4f810d3311891ac01a323a76c4807.patch

---

diff --git a/src/modules/geoip/geoip_mod.c b/src/modules/geoip/geoip_mod.c
index 1962172..ab827a1 100644
--- a/src/modules/geoip/geoip_mod.c
+++ b/src/modules/geoip/geoip_mod.c
@@ -30,6 +30,7 @@
 #include "../../core/dprint.h"
 #include "../../core/ut.h"
 #include "../../core/pvar.h"
+#include "../../core/kemi.h"
 #include "../../core/mod_fix.h"
 
 #include "geoip_pv.h"
@@ -42,7 +43,7 @@ static int  mod_init(void);
 static void mod_destroy(void);
 
 static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2);
-static int geoip_match(struct sip_msg *msg, gparam_t *target, gparam_t 
*pvname);
+static int geoip_match(sip_msg_t *msg, str *tomatch, str *pvclass);
 
 static pv_export_t mod_pvs[] = {
        { {"gip", sizeof("git")-1}, PVT_OTHER, pv_get_geoip, 0,
@@ -78,7 +79,6 @@ struct module_exports exports = {
 };
 
 
-
 /**
  * init module function
  */
@@ -107,34 +107,50 @@ static void mod_destroy(void)
        geoip_destroy_pv();
 }
 
-static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2)
+
+static int geoip_match(sip_msg_t *msg, str *tomatch, str *pvclass)
 {
-       return geoip_match(msg, (gparam_t*)str1, (gparam_t*)str2);
+       geoip_pv_reset(pvclass);
+
+       return geoip_update_pv(tomatch, pvclass);
 }
 
-static int geoip_match(struct sip_msg *msg, gparam_t *target, gparam_t *pvname)
+static int w_geoip_match(sip_msg_t* msg, char* target, char* pvname)
 {
-       str tomatch;
-       str pvclass;
+       str tomatch = STR_NULL;
+       str pvclass = STR_NULL;
 
-       if(msg==NULL)
-       {
+       if(msg==NULL) {
                LM_ERR("received null msg\n");
                return -1;
        }
 
-       if(fixup_get_svalue(msg, target, &tomatch)<0)
-       {
+       if(fixup_get_svalue(msg, (gparam_t*)target, &tomatch)<0) {
                LM_ERR("cannot get the address\n");
                return -1;
        }
-       if(fixup_get_svalue(msg, pvname, &pvclass)<0)
-       {
+       if(fixup_get_svalue(msg, (gparam_t*)pvname, &pvclass)<0) {
                LM_ERR("cannot get the pv class\n");
                return -1;
        }
-       geoip_pv_reset(&pvclass);
 
-       return geoip_update_pv(&tomatch, &pvclass);
+       return geoip_match(msg, &tomatch, &pvclass);
 }
 
+/**
+ *
+ */
+static sr_kemi_t sr_kemi_geoip_exports[] = {
+    { str_init("geoip"), str_init("match"),
+        SR_KEMIP_INT, geoip_match,
+        { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+    },
+
+    { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
+};
+
+int mod_register(char *path, int *dlflags, void *p1, void *p2) {
+    sr_kemi_modules_add(sr_kemi_geoip_exports);
+    return 0;
+}
\ No newline at end of file


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to