diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml index 3629c92..9b4426b 100644 --- a/mbuni/doc/userguide.shtml +++ b/mbuni/doc/userguide.shtml @@ -1232,7 +1232,8 @@ lists all the configuration directives. The column Mode Optional library containing billing and CDR functions. This library is loaded at runtime and should contain functions to be called to effect billing and CDR - generation. See mms_billing.h for details. + generation. See mms_billing.h for + details. (builtin:shell supported as a special built-in library.)     @@ -1275,7 +1276,9 @@ lists all the configuration directives. The column Mode over-rides the local-prefixes setting given above. If the Proxy-Relay hostname returned by the module is the hostname of the local MMSC, then the recipient is considered local. See - mms_resolve.h for details. + mms_resolve.h for details. (builtin:shell supported as a special + built-in library.)     @@ -1318,7 +1321,7 @@ lists all the configuration directives. The column Mode interpreted by the library and transformed into an MSISDN. This libary is only a fall-back in case the default sender address resolution fails. See - mms_detokenize.h for details. + mms_detokenize.h for details. (builtin:shell supported as a special built-in library.)     @@ -1571,7 +1574,37 @@ Boolean
- +Built-in billing, resolver and detokenizer + modules:

+Mbuni supports one type of built-in modules: Shell script + handlers. Each expect a parameter that is a shell script that is + used as follows: + +

MMSC-specific Configurations

This section describes extra configuration sections that should only diff --git a/mbuni/mmsc/Makefile.am b/mbuni/mmsc/Makefile.am index c4df4d1..a1779e3 100644 --- a/mbuni/mmsc/Makefile.am +++ b/mbuni/mmsc/Makefile.am @@ -2,7 +2,7 @@ libmms = $(top_builddir)/mmlib/libmms.la libmmsc = libmmsc.la noinst_LTLIBRARIES = libmmsc.la -libmmsc_la_SOURCES = mmsc_cfg.c mms_detokenize.c mms_resolve.c mms_billing.c +libmmsc_la_SOURCES = mmsc_cfg.c mms_detokenize.c mms_resolve.c mms_billing.c mms_detokenize_shell.c mms_resolve_shell.c mms_billing_shell.c bin_PROGRAMS = mmsrelay mmsproxy mmsfromemail mmssend mmsrelay_SOURCES = mmsglobalsender.c mmsmobilesender.c mmsrelay.c @@ -11,9 +11,9 @@ mmsproxy_LDADD = $(libmmsc) $(libmms) mmsfromemail_LDADD = $(libmmsc) $(libmms) mmssend_LDADD = $(libmmsc) $(libmms) -pkglib_LTLIBRARIES = libmmsc_billing_shell.la libmmsc_resolve_shell.la libmmsc_detokenize_shell.la -libmmsc_billing_shell_la_SOURCES = mms_billing_shell.c -libmmsc_resolve_shell_la_SOURCES = mms_resolve_shell.c -libmmsc_detokenize_shell_la_SOURCES = mms_detokenize_shell.c +#pkglib_LTLIBRARIES = libmmsc_billing_shell.la libmmsc_resolve_shell.la libmmsc_detokenize_shell.la +#libmmsc_billing_shell_la_SOURCES = mms_billing_shell.c +#libmmsc_resolve_shell_la_SOURCES = mms_resolve_shell.c +#libmmsc_detokenize_shell_la_SOURCES = mms_detokenize_shell.c EXTRA_DIST = mms_billing.h mmsc_cfg.h mms_detokenize.h mmsrelay.h mms_resolve.h diff --git a/mbuni/mmsc/mms_billing_shell.c b/mbuni/mmsc/mms_billing_shell.c index cd6c530..51b8755 100644 --- a/mbuni/mmsc/mms_billing_shell.c +++ b/mbuni/mmsc/mms_billing_shell.c @@ -60,7 +60,7 @@ static int mms_logcdr(MmsCdrStruct *cdr) } /* The function itself. */ -MmsBillingFuncStruct mms_billfuncs = { +MmsBillingFuncStruct mms_billfuncs_shell = { mms_billingmodule_init, mms_logcdr, mms_billmsg, diff --git a/mbuni/mmsc/mms_billing_shell.h b/mbuni/mmsc/mms_billing_shell.h new file mode 100644 index 0000000..fcd596f --- /dev/null +++ b/mbuni/mmsc/mms_billing_shell.h @@ -0,0 +1,24 @@ +/* + * Mbuni - Open Source MMS Gateway + * + * Mbuni billing integration interface (shell) + * + * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * + * Paul Bagyenda + * + * This program is free software, distributed under the terms of + * the GNU General Public License, with a few exceptions granted (see LICENSE) + */ + +#ifndef __MMS_BILLING_SHELL_INCLUDED__ +#define __MMS_BILLING_SHELL_INCLUDED__ + + +#include +#include "gwlib/gwlib.h" +#include "mms_billing.h" + +extern MmsBillingFuncStruct mms_billfuncs_shell; + +#endif diff --git a/mbuni/mmsc/mms_detokenize_shell.c b/mbuni/mmsc/mms_detokenize_shell.c index 832e807..f1a5701 100644 --- a/mbuni/mmsc/mms_detokenize_shell.c +++ b/mbuni/mmsc/mms_detokenize_shell.c @@ -80,7 +80,7 @@ static Octstr *mms_gettoken(Octstr *msisdn) } /* The function itself. */ -MmsDetokenizerFuncStruct mms_detokenizefuncs = { +MmsDetokenizerFuncStruct mms_detokenizefuncs_shell = { mms_detokenizer_init, mms_detokenize, mms_gettoken, diff --git a/mbuni/mmsc/mms_detokenize_shell.h b/mbuni/mmsc/mms_detokenize_shell.h new file mode 100644 index 0000000..fe5a4e7 --- /dev/null +++ b/mbuni/mmsc/mms_detokenize_shell.h @@ -0,0 +1,22 @@ +/* + * Mbuni - Open Source MMS Gateway + * + * Mbuni MSISDN mapper interface (shell) + * + * Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com + * + * Paul Bagyenda + * + * This program is free software, distributed under the terms of + * the GNU General Public License, with a few exceptions granted (see LICENSE) + */ +#ifndef __MMS_DETOKENIZE_SHELL_INCLUDED__ +#define __MMS_DETOKENIZE_SHELL_INCLUDED__ + +#include +#include "gwlib/gwlib.h" +#include "mms_detokenize.h" + +extern MmsDetokenizerFuncStruct mms_detokenizefuncs_shell; + +#endif diff --git a/mbuni/mmsc/mms_resolve_shell.c b/mbuni/mmsc/mms_resolve_shell.c index c472fad..ef9ccb7 100644 --- a/mbuni/mmsc/mms_resolve_shell.c +++ b/mbuni/mmsc/mms_resolve_shell.c @@ -56,7 +56,7 @@ static Octstr *mms_resolve(Octstr * phonenum, void *module_data, void *settings_ } /* The function itself. */ -MmsResolverFuncStruct mms_resolvefuncs = { +MmsResolverFuncStruct mms_resolvefuncs_shell = { mms_resolvermodule_init, mms_resolve, mms_resolvermodule_fini diff --git a/mbuni/mmsc/mms_resolve_shell.h b/mbuni/mmsc/mms_resolve_shell.h new file mode 100644 index 0000000..e58528b --- /dev/null +++ b/mbuni/mmsc/mms_resolve_shell.h @@ -0,0 +1,22 @@ +/* + * Mbuni - Open Source MMS Gateway + * + * Resolving MSISDNs to local/remote MMSCs - interface (shell) + * + * Copyright (C) 2003 - 2006, Digital Solutions Ltd. - http://www.dsmagic.com + * + * Paul Bagyenda + * + * This program is free software, distributed under the terms of + * the GNU General Public License, with a few exceptions granted (see LICENSE) + */ +#ifndef __MMS_RESOLVE_SHELL_INCLUDED__ +#define __MMS_RESOLVE_SHELL_INCLUDED__ + +#include +#include "gwlib/gwlib.h" +#include "mms_resolve.h" + +extern MmsResolverFuncStruct mms_resolvefuncs_shell; + +#endif diff --git a/mbuni/mmsc/mmsc_cfg.c b/mbuni/mmsc/mmsc_cfg.c index b684703..69328c1 100644 --- a/mbuni/mmsc/mmsc_cfg.c +++ b/mbuni/mmsc/mmsc_cfg.c @@ -23,40 +23,52 @@ #include "mmsc_cfg.h" #include "mms_queue.h" + #define MMS_PORT 8191 /* Default content fetch port. */ -static void *load_module(mCfgGrp *grp, char *config_key, char *symbolname) +static void *load_module(mCfgGrp *grp, char *config_key, char *symbolname, + void *shell_builtin) { - Octstr *s; + Octstr *s = NULL; void *retval = NULL; s = mms_cfg_get(grp, octstr_imm(config_key)); + if (s) { - void *x = dlopen(octstr_get_cstr(s), RTLD_LAZY); + void *x; void *y = NULL; -#ifdef __APPLE__ +#ifdef __APPLE__ char sbuf[512]; - - sprintf(sbuf, "_%s", symbolname); #endif - if (x == NULL || ((y = dlsym(x, symbolname)) == NULL + /* First look for the builtin: keyword. + * For now only builtin:shell is supported. + */ + if (octstr_case_search(s, octstr_imm("builtin:shell"), 0) >= 0) + retval = shell_builtin; + else { + x = dlopen(octstr_get_cstr(s), RTLD_LAZY); +#ifdef __APPLE__ + sprintf(sbuf, "_%s", symbolname); +#endif + if (x == NULL || ((y = dlsym(x, symbolname)) == NULL #ifdef __APPLE__ /* fink version of dlsym has issues it seems. */ - && (y = dlsym(x, sbuf)) == NULL + && (y = dlsym(x, sbuf)) == NULL #endif - )) + )) - panic(0, - "Error, unable to load dynamic libary (%s): " - "libhandle is %s, funcs is %s, err=%s", - octstr_get_cstr(s), - x ? "OK" : "Not OK", y ? "OK" : "Not OK", dlerror()); - else - retval = y; - + panic(0, + "Error, unable to load dynamic libary (%s): " + "libhandle is %s, funcs is %s, err=%s", + octstr_get_cstr(s), + x ? "OK" : "Not OK", y ? "OK" : "Not OK", dlerror()); + else + retval = y; + } octstr_destroy(s); } + return retval; } @@ -221,7 +233,8 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) octstr_imm("billing-module-parameters")); /* Get and load the billing lib if any. */ - if ((m->mms_billfuncs = load_module(grp, "billing-library", "mms_billfuncs"))) { + if ((m->mms_billfuncs = load_module(grp, "billing-library", "mms_billfuncs", + &mms_billfuncs_shell)) != NULL) { if (m->mms_billfuncs->mms_billingmodule_init == NULL || m->mms_billfuncs->mms_billmsg == NULL || m->mms_billfuncs->mms_billingmodule_fini == NULL || @@ -236,7 +249,9 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) octstr_imm("resolver-module-parameters")); /* Get and load the resolver lib if any. */ - if ((m->mms_resolvefuncs = load_module(grp, "resolver-library", "mms_resolvefuncs"))) { + if ((m->mms_resolvefuncs = load_module(grp, "resolver-library", + "mms_resolvefuncs", + &mms_resolvefuncs_shell)) != NULL) { if (m->mms_resolvefuncs->mms_resolvermodule_init == NULL || m->mms_resolvefuncs->mms_resolve == NULL || m->mms_resolvefuncs->mms_resolvermodule_fini == NULL) @@ -249,7 +264,9 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) m->detokenizer_params = _mms_cfg_getx(grp, octstr_imm("detokenizer-module-parameters")); /* Get and load the detokenizer lib if any. */ - if ((m->mms_detokenizefuncs = load_module(grp, "detokenizer-library", "mms_detokenizefuncs"))) { + if ((m->mms_detokenizefuncs = load_module(grp, "detokenizer-library", + "mms_detokenizefuncs", + &mms_detokenizefuncs_shell)) != NULL) { if (m->mms_detokenizefuncs->mms_detokenizer_init == NULL || m->mms_detokenizefuncs->mms_detokenize == NULL || m->mms_detokenizefuncs->mms_gettoken == NULL || diff --git a/mbuni/mmsc/mmsc_cfg.h b/mbuni/mmsc/mmsc_cfg.h index eab6f40..ce4ffe6 100644 --- a/mbuni/mmsc/mmsc_cfg.h +++ b/mbuni/mmsc/mmsc_cfg.h @@ -13,9 +13,9 @@ #ifndef __MMSC_CFG__ #define __MMSC_CFG__ #include "mms_util.h" -#include "mms_resolve.h" -#include "mms_billing.h" -#include "mms_detokenize.h" +#include "mms_resolve_shell.h" +#include "mms_billing_shell.h" +#include "mms_detokenize_shell.h" typedef struct MmsProxyRelay { Octstr *host;