Browse code

modules_k/outbound: added stub module for Outbound

Peter Dunkley authored on 14/08/2012 08:15:51
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+# $Id$
2
+#
3
+# 
4
+# WARNING: do not run this directly, it should be run by the master Makefile
5
+
6
+include ../../Makefile.defs
7
+auto_gen=
8
+NAME=outbound.so
9
+
10
+BUILDER = $(shell which pkg-config)
11
+ifeq ($(BUILDER),)
12
+        DEFS+= -I$(LOCALBASE)/ssl/include
13
+        LIBS=  -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \
14
+			-L$(LOCALBASE)/lib64 -L$(LOCALBASE)/ssl/lib64 \
15
+			-lssl
16
+else
17
+	DEFS+= $(shell pkg-config --cflags libssl)
18
+	LIBS=  $(shell pkg-config --libs libssl)
19
+endif
20
+
21
+DEFS+=-DOPENSER_MOD_INTERFACE
22
+
23
+SERLIBPATH=../../lib
24
+SER_LIBS+=$(SERLIBPATH)/kcore/kcore
25
+SER_LIBS+=$(SERLIBPATH)/kmi/kmi
26
+
27
+include ../../Makefile.modules
0 28
new file mode 100644
... ...
@@ -0,0 +1,67 @@
1
+Outbound Module
2
+
3
+Peter Dunkley
4
+
5
+   Crocodile RCS Ltd
6
+
7
+   Copyright © 2012 Crocodile RCS Ltd
8
+     __________________________________________________________________
9
+
10
+   Table of Contents
11
+
12
+   1. Admin Guide
13
+
14
+        1. Overview
15
+        2. Dependencies
16
+
17
+              2.1. Kamailio Modules
18
+              2.2. External Libraries or Applications
19
+
20
+        3. Parameters
21
+        4. Functions
22
+        5. MI Commands
23
+
24
+Chapter 1. Admin Guide
25
+
26
+   Table of Contents
27
+
28
+   1. Overview
29
+   2. Dependencies
30
+
31
+        2.1. Kamailio Modules
32
+        2.2. External Libraries or Applications
33
+
34
+   3. Parameters
35
+   4. Functions
36
+   5. MI Commands
37
+
38
+1. Overview
39
+
40
+   ...
41
+
42
+2. Dependencies
43
+
44
+   2.1. Kamailio Modules
45
+   2.2. External Libraries or Applications
46
+
47
+2.1. Kamailio Modules
48
+
49
+   ...
50
+
51
+2.2. External Libraries or Applications
52
+
53
+   The following libraries must be installed before running Kamailio with
54
+   this module loaded:
55
+     * OpenSSL.
56
+
57
+3. Parameters
58
+
59
+   ...
60
+
61
+4. Functions
62
+
63
+   ...
64
+
65
+5. MI Commands
66
+
67
+   ...
0 68
new file mode 100644
... ...
@@ -0,0 +1,52 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2012 Crocodile RCS Ltd
5
+ *
6
+ * This file is part of Kamailio, a free SIP server.
7
+ *
8
+ * Kamailio 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
+ * Kamailio is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License 
19
+ * along with this program; if not, write to the Free Software 
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
+ *
22
+ */
23
+
24
+#ifndef OB_API_H
25
+#define OB_API_H
26
+
27
+typedef int (*ob_fn1_t)(int, int, int);
28
+typedef int (*ob_fn2_t)(int, int, int);
29
+typedef int (*ob_fn3_t)(int, int, int);
30
+
31
+typedef struct ob_binds {
32
+	ob_fn1_t ob_fn1;
33
+	ob_fn2_t ob_fn2;
34
+	ob_fn3_t ob_fn3;
35
+} ob_api_t;
36
+
37
+typedef int (*bind_ob_f)(ob_api_t*);
38
+
39
+int bind_ob(struct ob_binds*);
40
+
41
+inline static int ob_load_api(ob_api_t *pxb)
42
+{
43
+	bind_ob_f bind_ob_exports;
44
+	if (!(bind_ob_exports = (bind_ob_f)find_export("bind_ob", 1, 0)))
45
+	{
46
+		LM_ERR("Failed to import bind_ob\n");
47
+		return -1;
48
+	}
49
+	return bind_ob_exports(pxb);
50
+}
51
+
52
+#endif /* OB_API_H */
0 53
new file mode 100644
... ...
@@ -0,0 +1,4 @@
1
+docs = outbound.xml
2
+
3
+docbook_dir = ../../../docbook
4
+include $(docbook_dir)/Makefile.module
0 5
new file mode 100644
... ...
@@ -0,0 +1,33 @@
1
+<?xml version="1.0" encoding='ISO-8859-1'?>
2
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4
+
5
+<!-- Include general documentation entities -->
6
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
7
+%docentities;
8
+
9
+]>
10
+
11
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
12
+	<bookinfo>
13
+	<title>Outbound Module</title>
14
+	<productname class="trade">&kamailioname;</productname>
15
+	<authorgroup>
16
+		<author>
17
+		<firstname>Peter</firstname>
18
+		<surname>Dunkley</surname>
19
+		<affiliation><orgname>Crocodile RCS Ltd</orgname></affiliation>
20
+		<address>
21
+			<email>peter.dunkley@crocodile-rcs.com</email>
22
+		</address>
23
+		</author>
24
+	</authorgroup>
25
+	<copyright>
26
+		<year>2012</year>
27
+		<holder>Crocodile RCS Ltd</holder>
28
+	</copyright>
29
+	</bookinfo>
30
+	<toc></toc>
31
+	
32
+	<xi:include href="outbound_admin.xml"/>
33
+</book>
0 34
new file mode 100644
... ...
@@ -0,0 +1,59 @@
1
+<?xml version="1.0" encoding='ISO-8859-1'?>
2
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4
+
5
+<!-- Include general documentation entities -->
6
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
7
+%docentities;
8
+
9
+]>
10
+<!-- Module User's Guide -->
11
+
12
+<chapter>
13
+	
14
+	<title>&adminguide;</title>
15
+	
16
+	<section>
17
+	<title>Overview</title>
18
+	<para>...</para>
19
+	</section>
20
+
21
+	<section>
22
+	<title>Dependencies</title>
23
+	<section>
24
+		<title>&kamailio; Modules</title>
25
+		<para>...</para>
26
+	</section>
27
+
28
+	<section>
29
+		<title>External Libraries or Applications</title>
30
+		<para>
31
+		The following libraries must be installed before running
32
+		&kamailio; with this module loaded:
33
+		<itemizedlist>
34
+		<listitem>
35
+		<para><emphasis>OpenSSL</emphasis>.</para>
36
+		</listitem>
37
+		</itemizedlist>
38
+		</para>
39
+	</section>
40
+	</section>
41
+
42
+
43
+	<section>
44
+	<title>Parameters</title>
45
+	<para>...</para>
46
+	</section>
47
+
48
+	<section>
49
+	<title>Functions</title>
50
+	<para>...</para>
51
+	</section>
52
+
53
+	<section>
54
+	<title>MI Commands</title>
55
+	<para>...</para>
56
+	</section>
57
+
58
+</chapter>
59
+
0 60
new file mode 100644
... ...
@@ -0,0 +1,151 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2012 Crocodile RCS Ltd
5
+ *
6
+ * This file is part of Kamailio, a free SIP server.
7
+ *
8
+ * Kamailio 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
+ * Kamailio is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License 
19
+ * along with this program; if not, write to the Free Software 
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
+ *
22
+ */
23
+
24
+#include "../../dprint.h"
25
+#include "../../sr_module.h"
26
+#include "../../lib/kcore/kstats_wrapper.h"
27
+#include "../../lib/kmi/mi.h"
28
+
29
+#include "api.h"
30
+
31
+MODULE_VERSION
32
+
33
+static int mod_init(void);
34
+static int child_init(int rank);
35
+static void destroy(void);
36
+
37
+static int ob_force_bflag = -1;
38
+static str ob_key = {0, 0};
39
+
40
+static cmd_export_t cmds[]= 
41
+{
42
+	{ "bind_ob", (cmd_function) bind_ob,
43
+	  1, 0, 0,
44
+	  0 },
45
+	{ 0, 0, 0, 0, 0, 0 }
46
+};
47
+
48
+static param_export_t params[]=
49
+{
50
+	{ "force_outbound_bflag",	INT_PARAM, &ob_force_bflag },
51
+	{ "flow_token_key",		STR_PARAM, &ob_key.s},
52
+	{ 0, 0, 0 }
53
+};
54
+
55
+static stat_export_t stats[] =
56
+{
57
+	{ 0, 0, 0 }
58
+};
59
+
60
+static mi_export_t mi_cmds[] =
61
+{
62
+	{ 0, 0, 0, 0, 0 }
63
+};
64
+
65
+struct module_exports exports= 
66
+{
67
+	"outbound",
68
+	DEFAULT_DLFLAGS,	/* dlopen flags */
69
+	cmds,			/* Exported functions */
70
+	params,			/* Exported parameters */
71
+	stats,			/* exported statistics */
72
+	mi_cmds,		/* exported MI functions */
73
+	0,			/* exported pseudo-variables */
74
+	0,			/* extra processes */
75
+	mod_init,		/* module initialization function */
76
+	0,			/* response function */
77
+	destroy,		/* destroy function */
78
+	child_init		/* per-child initialization function */
79
+};
80
+
81
+static int mod_init(void)
82
+{
83
+	if (register_module_stats(exports.name, stats) != 0)
84
+	{
85
+		LM_ERR("registering core statistics\n");
86
+		return -1;
87
+	}
88
+
89
+	if (register_mi_mod(exports.name, mi_cmds) != 0)
90
+	{
91
+		LM_ERR("registering MI commands\n");
92
+		return -1;
93
+	}
94
+
95
+	if (ob_force_bflag == -1)
96
+	{
97
+		LM_ERR("force_outbound_bflag not set\n");
98
+		return -1;
99
+	}
100
+
101
+	if (ob_key.s == 0)
102
+	{
103
+		LM_ERR("flow_token_key not set\n");
104
+		return -1;
105
+	}
106
+	else
107
+		ob_key.len = strlen(ob_key.s);
108
+
109
+	return 0;
110
+}
111
+
112
+static int child_init(int rank)
113
+{
114
+	/* TODO */
115
+	return 0;
116
+}
117
+
118
+static void destroy(void)
119
+{
120
+	/* TODO */
121
+}
122
+
123
+int ob_fn1(int p1, int p2, int p3)
124
+{
125
+	return 0;
126
+}
127
+
128
+int ob_fn2(int p1, int p2, int p3)
129
+{
130
+	return 0;
131
+}
132
+
133
+int ob_fn3(int p1, int p2, int p3)
134
+{
135
+	return 0;
136
+}
137
+
138
+int bind_ob(struct ob_binds *pxb)
139
+{
140
+	if (pxb == NULL)
141
+	{
142
+		LM_WARN("bind_outbound: Cannot load outbound API into NULL pointer\n");
143
+		return -1;
144
+	}
145
+
146
+	pxb->ob_fn1 = ob_fn1;
147
+	pxb->ob_fn2 = ob_fn2;
148
+	pxb->ob_fn3 = ob_fn3;
149
+
150
+	return 0;
151
+}