Browse code

geoip: add clang-format directives to skip format on kemi_exports

format is important for generating docs by our python tool

Victor Seva authored on 09/12/2019 17:30:25
Showing 1 changed files
... ...
@@ -138,6 +138,7 @@ static int w_geoip_match(sip_msg_t* msg, char* target, char* pvname)
138 138
 /**
139 139
  *
140 140
  */
141
+/* clang-format off */
141 142
 static sr_kemi_t sr_kemi_geoip_exports[] = {
142 143
     { str_init("geoip"), str_init("match"),
143 144
         SR_KEMIP_INT, geoip_match,
... ...
@@ -147,6 +148,7 @@ static sr_kemi_t sr_kemi_geoip_exports[] = {
147 148
 
148 149
     { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
149 150
 };
151
+/* clang-format on */
150 152
 
151 153
 int mod_register(char *path, int *dlflags, void *p1, void *p2) {
152 154
     sr_kemi_modules_add(sr_kemi_geoip_exports);
Browse code

geoip: updated to new module interface format

Charles Chance authored on 27/09/2018 16:04:26 • Victor Seva committed on 28/09/2018 11:03:26
Showing 1 changed files
... ...
@@ -64,18 +64,16 @@ static param_export_t params[]={
64 64
 };
65 65
 
66 66
 struct module_exports exports = {
67
-	"geoip",
68
-	DEFAULT_DLFLAGS, /* dlopen flags */
69
-	cmds,
70
-	params,
71
-	0,
72
-	0,              /* exported MI functions */
73
-	mod_pvs,        /* exported pseudo-variables */
74
-	0,              /* extra processes */
75
-	mod_init,       /* module initialization function */
76
-	0,              /* response function */
77
-	mod_destroy,    /* destroy function */
78
-	0               /* per child init function */
67
+	"geoip",			/* module name */
68
+	DEFAULT_DLFLAGS,	/* dlopen flags */
69
+	cmds,				/* exported functions */
70
+	params,				/* exported parameters */
71
+	0,					/* RPC method exports */
72
+	mod_pvs,			/* exported pseudo-variables */
73
+	0,					/* response handling function */
74
+	mod_init,			/* module initialization function */
75
+	0,					/* per-child init function */
76
+	mod_destroy			/* module destroy function */
79 77
 };
80 78
 
81 79
 
Browse code

geoip: fixed typo in definition of gip variable

Daniel-Constantin Mierla authored on 17/10/2017 05:45:58
Showing 1 changed files
... ...
@@ -46,7 +46,7 @@ static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2);
46 46
 static int geoip_match(sip_msg_t *msg, str *tomatch, str *pvclass);
47 47
 
48 48
 static pv_export_t mod_pvs[] = {
49
-	{ {"gip", sizeof("git")-1}, PVT_OTHER, pv_get_geoip, 0,
49
+	{ {"gip", sizeof("gip")-1}, PVT_OTHER, pv_get_geoip, 0,
50 50
 		pv_parse_geoip_name, 0, 0, 0 },
51 51
 	{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
52 52
 };
... ...
@@ -153,4 +153,4 @@ static sr_kemi_t sr_kemi_geoip_exports[] = {
153 153
 int mod_register(char *path, int *dlflags, void *p1, void *p2) {
154 154
     sr_kemi_modules_add(sr_kemi_geoip_exports);
155 155
     return 0;
156
-}
157 156
\ No newline at end of file
157
+}
Browse code

geoip: exported functions to kemi framework

Daniel-Constantin Mierla authored on 18/04/2017 12:07:27
Showing 1 changed files
... ...
@@ -30,6 +30,7 @@
30 30
 #include "../../core/dprint.h"
31 31
 #include "../../core/ut.h"
32 32
 #include "../../core/pvar.h"
33
+#include "../../core/kemi.h"
33 34
 #include "../../core/mod_fix.h"
34 35
 
35 36
 #include "geoip_pv.h"
... ...
@@ -42,7 +43,7 @@ static int  mod_init(void);
42 43
 static void mod_destroy(void);
43 44
 
44 45
 static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2);
45
-static int geoip_match(struct sip_msg *msg, gparam_t *target, gparam_t *pvname);
46
+static int geoip_match(sip_msg_t *msg, str *tomatch, str *pvclass);
46 47
 
47 48
 static pv_export_t mod_pvs[] = {
48 49
 	{ {"gip", sizeof("git")-1}, PVT_OTHER, pv_get_geoip, 0,
... ...
@@ -78,7 +79,6 @@ struct module_exports exports = {
78 79
 };
79 80
 
80 81
 
81
-
82 82
 /**
83 83
  * init module function
84 84
  */
... ...
@@ -107,34 +107,50 @@ static void mod_destroy(void)
107 107
 	geoip_destroy_pv();
108 108
 }
109 109
 
110
-static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2)
110
+
111
+static int geoip_match(sip_msg_t *msg, str *tomatch, str *pvclass)
111 112
 {
112
-	return geoip_match(msg, (gparam_t*)str1, (gparam_t*)str2);
113
+	geoip_pv_reset(pvclass);
114
+
115
+	return geoip_update_pv(tomatch, pvclass);
113 116
 }
114 117
 
115
-static int geoip_match(struct sip_msg *msg, gparam_t *target, gparam_t *pvname)
118
+static int w_geoip_match(sip_msg_t* msg, char* target, char* pvname)
116 119
 {
117
-	str tomatch;
118
-	str pvclass;
120
+	str tomatch = STR_NULL;
121
+	str pvclass = STR_NULL;
119 122
 
120
-	if(msg==NULL)
121
-	{
123
+	if(msg==NULL) {
122 124
 		LM_ERR("received null msg\n");
123 125
 		return -1;
124 126
 	}
125 127
 
126
-	if(fixup_get_svalue(msg, target, &tomatch)<0)
127
-	{
128
+	if(fixup_get_svalue(msg, (gparam_t*)target, &tomatch)<0) {
128 129
 		LM_ERR("cannot get the address\n");
129 130
 		return -1;
130 131
 	}
131
-	if(fixup_get_svalue(msg, pvname, &pvclass)<0)
132
-	{
132
+	if(fixup_get_svalue(msg, (gparam_t*)pvname, &pvclass)<0) {
133 133
 		LM_ERR("cannot get the pv class\n");
134 134
 		return -1;
135 135
 	}
136
-	geoip_pv_reset(&pvclass);
137 136
 
138
-	return geoip_update_pv(&tomatch, &pvclass);
137
+	return geoip_match(msg, &tomatch, &pvclass);
139 138
 }
140 139
 
140
+/**
141
+ *
142
+ */
143
+static sr_kemi_t sr_kemi_geoip_exports[] = {
144
+    { str_init("geoip"), str_init("match"),
145
+        SR_KEMIP_INT, geoip_match,
146
+        { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
147
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
148
+    },
149
+
150
+    { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
151
+};
152
+
153
+int mod_register(char *path, int *dlflags, void *p1, void *p2) {
154
+    sr_kemi_modules_add(sr_kemi_geoip_exports);
155
+    return 0;
156
+}
141 157
\ No newline at end of file
Browse code

geoip: removed unneeded lib kmi from Makefile

- bits of formatting and removed snv ids

Daniel-Constantin Mierla authored on 02/01/2017 08:05:46
Showing 1 changed files
... ...
@@ -1,5 +1,4 @@
1 1
 /**
2
- * $Id$
3 2
  *
4 3
  * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com)
5 4
  *
... ...
@@ -117,7 +116,7 @@ static int geoip_match(struct sip_msg *msg, gparam_t *target, gparam_t *pvname)
117 116
 {
118 117
 	str tomatch;
119 118
 	str pvclass;
120
-	
119
+
121 120
 	if(msg==NULL)
122 121
 	{
123 122
 		LM_ERR("received null msg\n");
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -27,11 +27,11 @@
27 27
 #include <stdlib.h>
28 28
 #include <string.h>
29 29
 
30
-#include "../../sr_module.h"
31
-#include "../../dprint.h"
32
-#include "../../ut.h"
33
-#include "../../pvar.h"
34
-#include "../../mod_fix.h"
30
+#include "../../core/sr_module.h"
31
+#include "../../core/dprint.h"
32
+#include "../../core/ut.h"
33
+#include "../../core/pvar.h"
34
+#include "../../core/mod_fix.h"
35 35
 
36 36
 #include "geoip_pv.h"
37 37
 
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,141 @@
1
+/**
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com)
5
+ *
6
+ * This file is part of Kamailio, a free SIP server.
7
+ *
8
+ * This file is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ *
14
+ * This file is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program; if not, write to the Free Software
21
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
+ *
23
+ */
24
+
25
+#include <stdio.h>
26
+#include <unistd.h>
27
+#include <stdlib.h>
28
+#include <string.h>
29
+
30
+#include "../../sr_module.h"
31
+#include "../../dprint.h"
32
+#include "../../ut.h"
33
+#include "../../pvar.h"
34
+#include "../../mod_fix.h"
35
+
36
+#include "geoip_pv.h"
37
+
38
+MODULE_VERSION
39
+
40
+static char *geoip_path = NULL;
41
+
42
+static int  mod_init(void);
43
+static void mod_destroy(void);
44
+
45
+static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2);
46
+static int geoip_match(struct sip_msg *msg, gparam_t *target, gparam_t *pvname);
47
+
48
+static pv_export_t mod_pvs[] = {
49
+	{ {"gip", sizeof("git")-1}, PVT_OTHER, pv_get_geoip, 0,
50
+		pv_parse_geoip_name, 0, 0, 0 },
51
+	{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
52
+};
53
+
54
+
55
+static cmd_export_t cmds[]={
56
+	{"geoip_match", (cmd_function)w_geoip_match, 2, fixup_spve_spve,
57
+		0, ANY_ROUTE},
58
+	{0, 0, 0, 0, 0, 0}
59
+};
60
+
61
+static param_export_t params[]={
62
+	{"path",     PARAM_STRING, &geoip_path},
63
+	{0, 0, 0}
64
+};
65
+
66
+struct module_exports exports = {
67
+	"geoip",
68
+	DEFAULT_DLFLAGS, /* dlopen flags */
69
+	cmds,
70
+	params,
71
+	0,
72
+	0,              /* exported MI functions */
73
+	mod_pvs,        /* exported pseudo-variables */
74
+	0,              /* extra processes */
75
+	mod_init,       /* module initialization function */
76
+	0,              /* response function */
77
+	mod_destroy,    /* destroy function */
78
+	0               /* per child init function */
79
+};
80
+
81
+
82
+
83
+/**
84
+ * init module function
85
+ */
86
+static int mod_init(void)
87
+{
88
+
89
+	if(geoip_path==NULL || strlen(geoip_path)==0)
90
+	{
91
+		LM_ERR("path to GeoIP database file not set\n");
92
+		return -1;
93
+	}
94
+
95
+	if(geoip_init_pv(geoip_path)!=0)
96
+	{
97
+		LM_ERR("cannot init for database file at: %s\n", geoip_path);
98
+		return -1;
99
+	}
100
+	return 0;
101
+}
102
+
103
+/**
104
+ * destroy module function
105
+ */
106
+static void mod_destroy(void)
107
+{
108
+	geoip_destroy_pv();
109
+}
110
+
111
+static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2)
112
+{
113
+	return geoip_match(msg, (gparam_t*)str1, (gparam_t*)str2);
114
+}
115
+
116
+static int geoip_match(struct sip_msg *msg, gparam_t *target, gparam_t *pvname)
117
+{
118
+	str tomatch;
119
+	str pvclass;
120
+	
121
+	if(msg==NULL)
122
+	{
123
+		LM_ERR("received null msg\n");
124
+		return -1;
125
+	}
126
+
127
+	if(fixup_get_svalue(msg, target, &tomatch)<0)
128
+	{
129
+		LM_ERR("cannot get the address\n");
130
+		return -1;
131
+	}
132
+	if(fixup_get_svalue(msg, pvname, &pvclass)<0)
133
+	{
134
+		LM_ERR("cannot get the pv class\n");
135
+		return -1;
136
+	}
137
+	geoip_pv_reset(&pvclass);
138
+
139
+	return geoip_update_pv(&tomatch, &pvclass);
140
+}
141
+