2005-03-23 05:55:16 +00:00
|
|
|
/*
|
|
|
|
* Mbuni - Open Source MMS Gateway
|
|
|
|
*
|
|
|
|
* Resolving MSISDNs to local/remote MMSCs
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com
|
|
|
|
*
|
|
|
|
* Paul Bagyenda <bagyenda@dsmagic.com>
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License, with a few exceptions granted (see LICENSE)
|
|
|
|
*/
|
2005-03-10 08:01:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "mms_resolve.h"
|
2005-09-01 10:26:36 +00:00
|
|
|
#include "mmsc_cfg.h"
|
2005-03-10 08:01:02 +00:00
|
|
|
|
|
|
|
static void *mms_resolvermodule_init(char *settings)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mms_resolvermodule_fini(void *module_data)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Octstr *mms_resolve(Octstr * phonenum, void *module_data, void *settings_p, void *proxyrelays_p)
|
|
|
|
{
|
|
|
|
/* Most custom implementations of this library will probably just ignore the two last arguments,
|
|
|
|
* but this one needs them
|
|
|
|
*/
|
|
|
|
|
2005-09-01 10:26:36 +00:00
|
|
|
MmscSettings *settings = (MmscSettings *) settings_p;
|
2005-03-10 08:01:02 +00:00
|
|
|
List *proxyrelays = (List *) proxyrelays_p;
|
|
|
|
int j, m;
|
|
|
|
|
|
|
|
if (does_prefix_match(settings->local_prefix, phonenum)) {
|
|
|
|
return settings->hostname;
|
|
|
|
} else if (proxyrelays && list_len(proxyrelays) > 0) /* Step through proxies. */
|
|
|
|
for (j = 0, m = list_len(proxyrelays); j < m; j++) {
|
|
|
|
MmsProxyRelay *mp = list_get(proxyrelays, j);
|
|
|
|
if (does_prefix_match(mp->allowed_prefix, phonenum) &&
|
|
|
|
!does_prefix_match(mp->denied_prefix, phonenum)) {
|
|
|
|
return mp->host;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The function itself. */
|
|
|
|
MmsResolverFuncStruct mms_resolvefuncs = {
|
|
|
|
mms_resolvermodule_init,
|
|
|
|
mms_resolve,
|
|
|
|
mms_resolvermodule_fini
|
|
|
|
};
|