[sr-dev] git:pd/outbound: modules_k/outbound: added stub module for Outbound

Peter Dunkley peter.dunkley at crocodile-rcs.com
Tue Aug 14 10:16:32 CEST 2012


Module: sip-router
Branch: pd/outbound
Commit: 82de81e6becd747f84f67b360c510e3edbeeedf3
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=82de81e6becd747f84f67b360c510e3edbeeedf3

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Tue Aug 14 09:15:51 2012 +0100

modules_k/outbound: added stub module for Outbound

---

 modules_k/outbound/Makefile               |   27 +++++
 modules_k/outbound/README                 |   67 +++++++++++++
 modules_k/outbound/api.h                  |   52 ++++++++++
 modules_k/outbound/doc/Makefile           |    4 +
 modules_k/outbound/doc/outbound.xml       |   33 ++++++
 modules_k/outbound/doc/outbound_admin.xml |   59 +++++++++++
 modules_k/outbound/ob_mod.c               |  151 +++++++++++++++++++++++++++++
 7 files changed, 393 insertions(+), 0 deletions(-)

diff --git a/modules_k/outbound/Makefile b/modules_k/outbound/Makefile
new file mode 100644
index 0000000..148a900
--- /dev/null
+++ b/modules_k/outbound/Makefile
@@ -0,0 +1,27 @@
+# $Id$
+#
+# 
+# WARNING: do not run this directly, it should be run by the master Makefile
+
+include ../../Makefile.defs
+auto_gen=
+NAME=outbound.so
+
+BUILDER = $(shell which pkg-config)
+ifeq ($(BUILDER),)
+        DEFS+= -I$(LOCALBASE)/ssl/include
+        LIBS=  -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \
+			-L$(LOCALBASE)/lib64 -L$(LOCALBASE)/ssl/lib64 \
+			-lssl
+else
+	DEFS+= $(shell pkg-config --cflags libssl)
+	LIBS=  $(shell pkg-config --libs libssl)
+endif
+
+DEFS+=-DOPENSER_MOD_INTERFACE
+
+SERLIBPATH=../../lib
+SER_LIBS+=$(SERLIBPATH)/kcore/kcore
+SER_LIBS+=$(SERLIBPATH)/kmi/kmi
+
+include ../../Makefile.modules
diff --git a/modules_k/outbound/README b/modules_k/outbound/README
new file mode 100644
index 0000000..7feab22
--- /dev/null
+++ b/modules_k/outbound/README
@@ -0,0 +1,67 @@
+Outbound Module
+
+Peter Dunkley
+
+   Crocodile RCS Ltd
+
+   Copyright © 2012 Crocodile RCS Ltd
+     __________________________________________________________________
+
+   Table of Contents
+
+   1. Admin Guide
+
+        1. Overview
+        2. Dependencies
+
+              2.1. Kamailio Modules
+              2.2. External Libraries or Applications
+
+        3. Parameters
+        4. Functions
+        5. MI Commands
+
+Chapter 1. Admin Guide
+
+   Table of Contents
+
+   1. Overview
+   2. Dependencies
+
+        2.1. Kamailio Modules
+        2.2. External Libraries or Applications
+
+   3. Parameters
+   4. Functions
+   5. MI Commands
+
+1. Overview
+
+   ...
+
+2. Dependencies
+
+   2.1. Kamailio Modules
+   2.2. External Libraries or Applications
+
+2.1. Kamailio Modules
+
+   ...
+
+2.2. External Libraries or Applications
+
+   The following libraries must be installed before running Kamailio with
+   this module loaded:
+     * OpenSSL.
+
+3. Parameters
+
+   ...
+
+4. Functions
+
+   ...
+
+5. MI Commands
+
+   ...
diff --git a/modules_k/outbound/api.h b/modules_k/outbound/api.h
new file mode 100644
index 0000000..117ce49
--- /dev/null
+++ b/modules_k/outbound/api.h
@@ -0,0 +1,52 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2012 Crocodile RCS Ltd
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef OB_API_H
+#define OB_API_H
+
+typedef int (*ob_fn1_t)(int, int, int);
+typedef int (*ob_fn2_t)(int, int, int);
+typedef int (*ob_fn3_t)(int, int, int);
+
+typedef struct ob_binds {
+	ob_fn1_t ob_fn1;
+	ob_fn2_t ob_fn2;
+	ob_fn3_t ob_fn3;
+} ob_api_t;
+
+typedef int (*bind_ob_f)(ob_api_t*);
+
+int bind_ob(struct ob_binds*);
+
+inline static int ob_load_api(ob_api_t *pxb)
+{
+	bind_ob_f bind_ob_exports;
+	if (!(bind_ob_exports = (bind_ob_f)find_export("bind_ob", 1, 0)))
+	{
+		LM_ERR("Failed to import bind_ob\n");
+		return -1;
+	}
+	return bind_ob_exports(pxb);
+}
+
+#endif /* OB_API_H */
diff --git a/modules_k/outbound/doc/Makefile b/modules_k/outbound/doc/Makefile
new file mode 100644
index 0000000..2b088ac
--- /dev/null
+++ b/modules_k/outbound/doc/Makefile
@@ -0,0 +1,4 @@
+docs = outbound.xml
+
+docbook_dir = ../../../docbook
+include $(docbook_dir)/Makefile.module
diff --git a/modules_k/outbound/doc/outbound.xml b/modules_k/outbound/doc/outbound.xml
new file mode 100644
index 0000000..fcf307c
--- /dev/null
+++ b/modules_k/outbound/doc/outbound.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
+	<bookinfo>
+	<title>Outbound Module</title>
+	<productname class="trade">&kamailioname;</productname>
+	<authorgroup>
+		<author>
+		<firstname>Peter</firstname>
+		<surname>Dunkley</surname>
+		<affiliation><orgname>Crocodile RCS Ltd</orgname></affiliation>
+		<address>
+			<email>peter.dunkley at crocodile-rcs.com</email>
+		</address>
+		</author>
+	</authorgroup>
+	<copyright>
+		<year>2012</year>
+		<holder>Crocodile RCS Ltd</holder>
+	</copyright>
+	</bookinfo>
+	<toc></toc>
+	
+	<xi:include href="outbound_admin.xml"/>
+</book>
diff --git a/modules_k/outbound/doc/outbound_admin.xml b/modules_k/outbound/doc/outbound_admin.xml
new file mode 100644
index 0000000..0a08053
--- /dev/null
+++ b/modules_k/outbound/doc/outbound_admin.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+<!-- Module User's Guide -->
+
+<chapter>
+	
+	<title>&adminguide;</title>
+	
+	<section>
+	<title>Overview</title>
+	<para>...</para>
+	</section>
+
+	<section>
+	<title>Dependencies</title>
+	<section>
+		<title>&kamailio; Modules</title>
+		<para>...</para>
+	</section>
+
+	<section>
+		<title>External Libraries or Applications</title>
+		<para>
+		The following libraries must be installed before running
+		&kamailio; with this module loaded:
+		<itemizedlist>
+		<listitem>
+		<para><emphasis>OpenSSL</emphasis>.</para>
+		</listitem>
+		</itemizedlist>
+		</para>
+	</section>
+	</section>
+
+
+	<section>
+	<title>Parameters</title>
+	<para>...</para>
+	</section>
+
+	<section>
+	<title>Functions</title>
+	<para>...</para>
+	</section>
+
+	<section>
+	<title>MI Commands</title>
+	<para>...</para>
+	</section>
+
+</chapter>
+
diff --git a/modules_k/outbound/ob_mod.c b/modules_k/outbound/ob_mod.c
new file mode 100644
index 0000000..858dac1
--- /dev/null
+++ b/modules_k/outbound/ob_mod.c
@@ -0,0 +1,151 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2012 Crocodile RCS Ltd
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include "../../dprint.h"
+#include "../../sr_module.h"
+#include "../../lib/kcore/kstats_wrapper.h"
+#include "../../lib/kmi/mi.h"
+
+#include "api.h"
+
+MODULE_VERSION
+
+static int mod_init(void);
+static int child_init(int rank);
+static void destroy(void);
+
+static int ob_force_bflag = -1;
+static str ob_key = {0, 0};
+
+static cmd_export_t cmds[]= 
+{
+	{ "bind_ob", (cmd_function) bind_ob,
+	  1, 0, 0,
+	  0 },
+	{ 0, 0, 0, 0, 0, 0 }
+};
+
+static param_export_t params[]=
+{
+	{ "force_outbound_bflag",	INT_PARAM, &ob_force_bflag },
+	{ "flow_token_key",		STR_PARAM, &ob_key.s},
+	{ 0, 0, 0 }
+};
+
+static stat_export_t stats[] =
+{
+	{ 0, 0, 0 }
+};
+
+static mi_export_t mi_cmds[] =
+{
+	{ 0, 0, 0, 0, 0 }
+};
+
+struct module_exports exports= 
+{
+	"outbound",
+	DEFAULT_DLFLAGS,	/* dlopen flags */
+	cmds,			/* Exported functions */
+	params,			/* Exported parameters */
+	stats,			/* exported statistics */
+	mi_cmds,		/* exported MI functions */
+	0,			/* exported pseudo-variables */
+	0,			/* extra processes */
+	mod_init,		/* module initialization function */
+	0,			/* response function */
+	destroy,		/* destroy function */
+	child_init		/* per-child initialization function */
+};
+
+static int mod_init(void)
+{
+	if (register_module_stats(exports.name, stats) != 0)
+	{
+		LM_ERR("registering core statistics\n");
+		return -1;
+	}
+
+	if (register_mi_mod(exports.name, mi_cmds) != 0)
+	{
+		LM_ERR("registering MI commands\n");
+		return -1;
+	}
+
+	if (ob_force_bflag == -1)
+	{
+		LM_ERR("force_outbound_bflag not set\n");
+		return -1;
+	}
+
+	if (ob_key.s == 0)
+	{
+		LM_ERR("flow_token_key not set\n");
+		return -1;
+	}
+	else
+		ob_key.len = strlen(ob_key.s);
+
+	return 0;
+}
+
+static int child_init(int rank)
+{
+	/* TODO */
+	return 0;
+}
+
+static void destroy(void)
+{
+	/* TODO */
+}
+
+int ob_fn1(int p1, int p2, int p3)
+{
+	return 0;
+}
+
+int ob_fn2(int p1, int p2, int p3)
+{
+	return 0;
+}
+
+int ob_fn3(int p1, int p2, int p3)
+{
+	return 0;
+}
+
+int bind_ob(struct ob_binds *pxb)
+{
+	if (pxb == NULL)
+	{
+		LM_WARN("bind_outbound: Cannot load outbound API into NULL pointer\n");
+		return -1;
+	}
+
+	pxb->ob_fn1 = ob_fn1;
+	pxb->ob_fn2 = ob_fn2;
+	pxb->ob_fn3 = ob_fn3;
+
+	return 0;
+}




More information about the sr-dev mailing list