1
0
Fork 0

mmsglobalsender & mmsmobilsender folded into one -- mmsrelay.

This commit is contained in:
bagyenda 2005-04-14 14:45:48 +00:00
parent 7497919605
commit bbf523d144
7 changed files with 229 additions and 240 deletions

View File

@ -57,8 +57,8 @@ This document describes the installation and usage of the MMS Gateway.
</UL></LI>
<LI><A HREF="#Section_.1.4">Chapter 4: Gateway Architecture</A><UL>
<LI><A HREF="#Section_.1.4.1">MMS Proxy</A></LI>
<LI><A HREF="#Section_.1.4.2">MMS Mobile Sender</A></LI>
<LI><A HREF="#Section_.1.4.3">MMS Global Sender</A></LI>
<LI><A HREF="#Section_.1.4.2">MMS Relay</A></LI>
<LI><A HREF="#Section_.1.4.4">SMTP/Mail Interface</A></LI>
<LI><A HREF="#Section_.1.4.5">Utilities</A></LI>
</UL></LI>
@ -424,10 +424,9 @@ Kannel in a non-standard location, you will need to supply the location to <tt>c
<p >Mbuni consists of
4 programs:
3 programs:
<ul>
<li><tt>mmsc/mmsglobalsender</tt>
<li><tt>mmsc/mmsmobilesender</tt>
<li><tt>mmsc/mmsrelay</tt>
<li><tt>mmsc/mmsproxy</tt>
<li><tt>mmsc/mmsfromemail</tt>
</ul>
@ -435,12 +434,14 @@ which are by
default installed in <tt>/usr/local/bin</tt>
</p>
<p ><tt>mmsglobalsender</tt> is the main relay server. It routes
<p ><tt>mmsrelay</tt> is the main relay server. It routes
incoming messages to email, other MMS gateways, MMS clients/handsets,
etc. <tt>mmsmobilesender</tt> manages routing messages to MMS clients
using WAP Push, sending of delivery reports, etc. <tt>mmsproxy</tt>
etc. It also manages routing messages to MMS clients
using WAP Push, sending of delivery reports, etc.
<br><br>
<tt>mmsproxy</tt>
provides the HTTP interface via which messages are
sent and received by MMS clients. <tt>mmsfromemail </tt>Is
sent and received by MMS clients. <br><br><tt>mmsfromemail </tt>Is
the email2MMS gateway module. All programs must be configured, and the first
three running for the gateway to function smoothly.</p>
@ -503,8 +504,8 @@ is not very efficient but it works (which is important!)</p>
<H3><!--TableOfContentsAnchor:Begin--><A NAME="Section_.1.3"></A><!--TableOfContentsAnchor:End-->Chapter 3: Running the Gateway</H3>
<p>To run the gateway, you must run the
three programs listed above (<tt>mmsglobalsender</tt>,
<tt>mmsmobilsender</tt>, <tt>mmsproxy</tt>). <tt>mmsfromemail</tt>
two programs listed above (<tt>mmsrelay</tt>
and <tt>mmsproxy</tt>). <tt>mmsfromemail</tt>
should be called from your MTA (SMTP Mailer) to convert
and deliver an MMS from an email sender. The order in which they are started
is unimportant. They expect the configuration file to be passed as the last
@ -976,7 +977,7 @@ lists all the configuration directives</p>
of sender. Similar to the above, if the MSISDN is not set, then we
assume that the client is identified by IP address, which we extract
from the request headers (using this header). Default header name
is <tt>X-WAP-Network-Client-Address</tt>. If the header is not
is <tt>X-WAP-Network-Client-IP</tt>. If the header is not
found, we assume the IP address as seen by Mbuni's MM1 interface.
&nbsp; &nbsp;</td>
</tr>
@ -1550,8 +1551,8 @@ sent via SMTP to the proxy.
<br>
<br>
As indicated, there are four components to the gateway: The Global
Sender (<tt>mmsglobalsender</tt>), Mobile Sender (<tt>mmsmobilesender</tt>), Proxy
As indicated, there are thre components to the gateway: The Relay
(<tt>mmsrelay</tt>), the Proxy
(<tt>mmsproxy</tt>) and SMTP/Email Interface (<tt>mmsfromemail</tt>). We describe the
function of each of these in turn.
</p>
@ -1621,22 +1622,56 @@ This component must always be running.
</p>
<H4><!--TableOfContentsAnchor:Begin--><A NAME="Section_.1.4.2"></A><!--TableOfContentsAnchor:End-->MMS Mobile Sender</H4>
<H4><!--TableOfContentsAnchor:Begin--><A NAME="Section_.1.4.2"></A><!--TableOfContentsAnchor:End-->MMS Relay</H4>
The Relay manages routing of all messages (to phone, email, VASP).
<p>
The Relay watches the global queue for incoming messages (from VASP,
external MMSCs or clients). For each message that arrives
in the queue, the relay:
<ol>
<li> Determines if the message is due for delivery attempt. An
attempt is made to deliver the message as soon as it is received
(deffered delivery requests are honoured however), with
exponential back-off in case of failure.
<li> At the first delivery attempt, a call is made to the billing
module to effect billing and CDR generation. If the billing module
indicates that the sender does not have sufficient credit, the message
is discarded and the sender notified via delivery report.
<li> If the message is due for delivery attempt, the global sender
determines, for each recipient, how to deliver the message:
<ol type="a">
<li> If the message is destined for a local MMS client, the message
is transferred to the mobile/local queue. A copy of the message is
sent (as MIME) to the MMBox host (if one is configured)
<li> If the message is destined for an email user, the message is
re-formatted as MIME, sender and recipient addresses normalised as RFC
822 addresses, and the message passed to the mailer.
<li> If the message is destined for a foreign gateway, it is coded
as MIME and passed to the mailer for delivery via SMTP
<li>If the the message is destined for a VASP (identified by short
code), then it is sent using MM7 protocols to the relevant VASP.
<li> If the message cannot be delivered, the sender is notified.
</ol>
</ol>
</p>
<p>
This component handles
For messages placed in the mobile/local queue (i.e. those destined to
MSISDNs in the area served by this MMSC or IP-based clients), the
relay performs the following functions:
<ol>
<li> Notification of MMS clients of received message via WAP Push
<li> Notification is sent to the recipient client via WAP Push
<li> Delivery of other notifications such as delivery and read
reports to MMS clients via WAP Push
reports to clients via WAP Push
</ol>
SMS is used as the transport for WAP Push messages, if the recipient
is an MSISDN, otherwise TCP/IP is used.
is an MSISDN, otherwise UDP is used.
<br>
The mobile sender maintains a queue of messages pending delivery. At
The Relay maintains a separate queue for messages pending delivery. At
set intervals (see configuration section), it sends notifications to
the recipients. It keeps sending notifications until the message is
the recipient. It keeps sending notifications until the message is
fetched or the client indicates that it wishes to defer message
retrieval. A back-off mechanism is utilised to prevent flooding of
notifications.
@ -1651,34 +1686,6 @@ notified of expiry if they requested a delivery report)
</p>
<p>
<H4><!--TableOfContentsAnchor:Begin--><A NAME="Section_.1.4.3"></A><!--TableOfContentsAnchor:End-->MMS Global Sender</H4>
This is the master message switch. It consists largely of a queue
runner that monitors the global queue. For each message that arrives
in the queue, the global sender:
<ol>
<li> Determines if the message is due for delivery attempt. An
attempt is made to deliver the message as soon as it is received, with
exponential back-off in case of failure.
<li> At the first delivery attempt, a call is made to the billing
module to effect billing and CDR generation. If the billing module
indicates that the sender does not have sufficient credit, the message
is discarded and the sender notified via delivery report.
<li> If the message is due for delivery attempt, the global sender
determines, for each recipient, how to deliver the message:
<ol type="a">
<li> If the message is destined for a local MMS client, the message
is transferred to the mobile sender queue. A copy of the message is
sent (as MIME) to the MMBox host (if one is configured)
<li> If the message is destined for an email user, the message is
re-formatted as MIME, sender and recipient addresses normalised as RFC
822 addresses, and the message passed to the mailer.
<li> If the message is destined for a foreign gateway, it is coded
as MIME and passed to the mailer for delivery via SMTP
<li>If the the message is destined for a VASP (identified by short
code), then it is sent using MM7 protocols to the relevant VASP.
<li> If the message cannot be delivered, the sender is notified.
</ol>
</ol>
<br>
A word about queue management: A simple queue management scheme is
used. Each queue entry consists of two files: The 'q' file (which is
@ -1740,8 +1747,8 @@ guess which by inspecting the first byte of the file.
<li>From/To addresses are only used for delivery purposes (so internal
message headers may not be updated
<li>The <tt>-b</tt> flag, if specified, causes a copy of the message
to be saved in the recipients MMbox. (No check is made to confirm that
recipient is local!)
to be saved in the sender's MMbox. (No check is made to confirm that
sender address is local!)
</ul>
The message is placed in he global queue with expiry set to the system
maximum, and the queue entry ID is printed to standard output.
@ -1760,14 +1767,14 @@ NAME="Section_.1.5"></A><!--TableOfContentsAnchor:End-->Chapter 5: Tips & Tricks
MMS request. For such cases, Mbuni provides another way to specify
the sender MSISDN: The last part of the URL passed in the HTTP
transaction is passed to the De-tokenizer module (if specified),
which should return an MSISDN. So for instance
which should return a valid sender address. So for instance
you can configure a clients to use a URL like <tt>http://mmsc/xYz12R2
</tt>
as the MMSC address, and Mbuni will pass <tt>xYz12R2</tt> to the
de-tokenizer module, which must return the sender
MSISDN. Mbuni will only do this it has failed to find the MISDN request header.
address. Mbuni will only do this it has failed to find the address request header.
<br>
If no MSISDN is found, Mbuni assumes that the MMS client is
If no sender address (MSISDN) is found, Mbuni assumes that the MMS client is
identified by IP address, and attempts to look up the IP address of
the sender (see config section) and use that as the sender
address. You can block this by specifying <tt>allow-ip-type = false</tt>

View File

@ -1,2 +1,2 @@
bin_PROGRAMS = mmsglobalsender mmsproxy mmsmobilesender mmsfromemail mmssend
bin_PROGRAMS = mmsrelay mmsproxy mmsfromemail mmssend
mmsrelay_SOURCES = mmsglobalsender.c mmsmobilesender.c mmsrelay.h mmsrelay.c

View File

@ -11,10 +11,10 @@
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
#
@SET_MAKE@
SOURCES = mmsfromemail.c mmsglobalsender.c mmsmobilesender.c mmsproxy.c mmssend.c
SOURCES = mmsfromemail.c mmsproxy.c $(mmsrelay_SOURCES) mmssend.c
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@ -38,9 +38,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = mmsglobalsender$(EXEEXT) mmsproxy$(EXEEXT) \
mmsmobilesender$(EXEEXT) mmsfromemail$(EXEEXT) \
mmssend$(EXEEXT)
bin_PROGRAMS = mmsrelay$(EXEEXT) mmsproxy$(EXEEXT) \
mmsfromemail$(EXEEXT) mmssend$(EXEEXT)
subdir = mmsc
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -56,15 +55,13 @@ PROGRAMS = $(bin_PROGRAMS)
mmsfromemail_SOURCES = mmsfromemail.c
mmsfromemail_OBJECTS = mmsfromemail.$(OBJEXT)
mmsfromemail_LDADD = $(LDADD)
mmsglobalsender_SOURCES = mmsglobalsender.c
mmsglobalsender_OBJECTS = mmsglobalsender.$(OBJEXT)
mmsglobalsender_LDADD = $(LDADD)
mmsmobilesender_SOURCES = mmsmobilesender.c
mmsmobilesender_OBJECTS = mmsmobilesender.$(OBJEXT)
mmsmobilesender_LDADD = $(LDADD)
mmsproxy_SOURCES = mmsproxy.c
mmsproxy_OBJECTS = mmsproxy.$(OBJEXT)
mmsproxy_LDADD = $(LDADD)
am_mmsrelay_OBJECTS = mmsglobalsender.$(OBJEXT) \
mmsmobilesender.$(OBJEXT) mmsrelay.$(OBJEXT)
mmsrelay_OBJECTS = $(am_mmsrelay_OBJECTS)
mmsrelay_LDADD = $(LDADD)
mmssend_SOURCES = mmssend.c
mmssend_OBJECTS = mmssend.$(OBJEXT)
mmssend_LDADD = $(LDADD)
@ -79,10 +76,8 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = mmsfromemail.c mmsglobalsender.c mmsmobilesender.c \
mmsproxy.c mmssend.c
DIST_SOURCES = mmsfromemail.c mmsglobalsender.c mmsmobilesender.c \
mmsproxy.c mmssend.c
SOURCES = mmsfromemail.c mmsproxy.c $(mmsrelay_SOURCES) mmssend.c
DIST_SOURCES = mmsfromemail.c mmsproxy.c $(mmsrelay_SOURCES) mmssend.c
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -184,6 +179,7 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
mmsrelay_SOURCES = mmsglobalsender.c mmsmobilesender.c mmsrelay.h mmsrelay.c
all: all-am
.SUFFIXES:
@ -248,15 +244,12 @@ clean-binPROGRAMS:
mmsfromemail$(EXEEXT): $(mmsfromemail_OBJECTS) $(mmsfromemail_DEPENDENCIES)
@rm -f mmsfromemail$(EXEEXT)
$(LINK) $(mmsfromemail_LDFLAGS) $(mmsfromemail_OBJECTS) $(mmsfromemail_LDADD) $(LIBS)
mmsglobalsender$(EXEEXT): $(mmsglobalsender_OBJECTS) $(mmsglobalsender_DEPENDENCIES)
@rm -f mmsglobalsender$(EXEEXT)
$(LINK) $(mmsglobalsender_LDFLAGS) $(mmsglobalsender_OBJECTS) $(mmsglobalsender_LDADD) $(LIBS)
mmsmobilesender$(EXEEXT): $(mmsmobilesender_OBJECTS) $(mmsmobilesender_DEPENDENCIES)
@rm -f mmsmobilesender$(EXEEXT)
$(LINK) $(mmsmobilesender_LDFLAGS) $(mmsmobilesender_OBJECTS) $(mmsmobilesender_LDADD) $(LIBS)
mmsproxy$(EXEEXT): $(mmsproxy_OBJECTS) $(mmsproxy_DEPENDENCIES)
@rm -f mmsproxy$(EXEEXT)
$(LINK) $(mmsproxy_LDFLAGS) $(mmsproxy_OBJECTS) $(mmsproxy_LDADD) $(LIBS)
mmsrelay$(EXEEXT): $(mmsrelay_OBJECTS) $(mmsrelay_DEPENDENCIES)
@rm -f mmsrelay$(EXEEXT)
$(LINK) $(mmsrelay_LDFLAGS) $(mmsrelay_OBJECTS) $(mmsrelay_LDADD) $(LIBS)
mmssend$(EXEEXT): $(mmssend_OBJECTS) $(mmssend_DEPENDENCIES)
@rm -f mmssend$(EXEEXT)
$(LINK) $(mmssend_LDFLAGS) $(mmssend_OBJECTS) $(mmssend_LDADD) $(LIBS)
@ -271,6 +264,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmsglobalsender.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmsmobilesender.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmsproxy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmsrelay.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmssend.Po@am__quote@
.c.o:

View File

@ -1,7 +1,7 @@
/*
* Mbuni - Open Source MMS Gateway
*
* MMS Relay, implements message routing
* MMS Global Queue Runner, routes messages generally.
*
* Copyright (C) 2003 - 2005, Digital Solutions Ltd. - http://www.dsmagic.com
*
@ -11,13 +11,7 @@
* the GNU General Public License, with a few exceptions granted (see LICENSE)
*/
#include <signal.h>
#include <ctype.h>
#include <unistd.h>
#include "mms_queue.h"
#include "mms_uaprof.h"
#include "mms_util.h"
#include "mms_mm7soap.h"
#include "mmsrelay.h"
#define NMAX 256
static char mobile_qdir[NMAX];
@ -68,15 +62,8 @@ static int _x_octstr_int_compare(int n, Octstr *s);
#define NMAX 256
static char qdir[NMAX];
static Cfg *cfg;
static MmsBoxSettings *settings;
static List *proxyrelays;
static List *cdr_list; /* List for cdr as used by cdr consumer thread. */
static int rstop = 0; /* Set to 1 to stop queue runner. */
static int sendMsg(MmsEnvelope *e)
{
int i, n;
@ -315,11 +302,6 @@ static int sendMsg(MmsEnvelope *e)
}
static void quit_now(int notused)
{
rstop = 1;
}
static void cdr_thread(void *unused)
{
MmsCdrStruct *cdr;
@ -331,62 +313,8 @@ static void cdr_thread(void *unused)
}
}
int main(int argc, char *argv[])
void mbuni_global_queue_runner(void *unused)
{
int cfidx;
Octstr *fname;
CfgGroup *grp;
Octstr *log, *alog;
long loglevel;
mms_lib_init();
srandom(time(NULL));
cfidx = get_and_set_debugs(argc, argv, NULL);
if (argv[cfidx] == NULL)
fname = octstr_imm("mmsc.conf");
else
fname = octstr_create(argv[cfidx]);
cfg = cfg_create(fname);
if (cfg_read(cfg) == -1)
panic(0, "Couldn't read configuration from '%s'.", octstr_get_cstr(fname));
octstr_destroy(fname);
info(0, "----------------------------------------");
info(0, " MMSC Global queue runner version %s starting", MMSC_VERSION);
grp = cfg_get_single_group(cfg, octstr_imm("core"));
log = cfg_get(grp, octstr_imm("log-file"));
if (log != NULL) {
if (cfg_get_integer(&loglevel, grp, octstr_imm("log-level")) == -1)
loglevel = 0;
log_open(octstr_get_cstr(log), loglevel, GW_NON_EXCL);
octstr_destroy(log);
}
/* Get access log and open it. */
alog = cfg_get(grp, octstr_imm("access-log"));
if (alog) {
alog_open(octstr_get_cstr(alog), 1, 1);
octstr_destroy(alog);
}
/* Load proxy relays. */
proxyrelays = mms_proxy_relays(cfg);
/* Load settings. */
settings = mms_load_mmsbox_settings(cfg);
if (!settings)
panic(0, "No global MMSC configuration!");
mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));
mms_setmobile_queuedir(octstr_get_cstr(settings->mm1_queuedir));
mms_setmm4_queuedir(octstr_get_cstr(settings->mm4_queuedir));
@ -402,15 +330,12 @@ int main(int argc, char *argv[])
gwthread_create(cdr_thread, NULL);
signal(SIGHUP, quit_now);
signal(SIGTERM, quit_now);
signal(SIGPIPE,SIG_IGN); /* Ignore pipe errors. They kill us sometimes for nothing*/
mms_queue_run(qdir, sendMsg, settings->queue_interval, settings->maxthreads, &rstop);
mms_stop_profile_engine(); /* Stop profile stuff. */
/* When it ends, wait a little for other stuff to stop... */
sleep(2);
list_remove_producer(cdr_list); /* Stop CDR thread. */
sleep(2); /* Wait for them to die. */
return 0;
return;
}

View File

@ -11,20 +11,12 @@
* This program is free software, distributed under the terms of
* the GNU General Public License, with a few exceptions granted (see LICENSE)
*/
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include "mms_queue.h"
#include "mms_uaprof.h"
#include "mms_util.h"
#include "mmsrelay.h"
#define WAPPUSH_PORT 2948
static MmsBoxSettings *settings;
static HTTPCaller *httpcaller;
static int rstop = 0;
static MmsEnvelope edummy;
@ -461,72 +453,8 @@ static int sendNotify(MmsEnvelope *e)
return 1;
}
static void quit_now(int notused)
void mbuni_mm1_queue_runner(void *unused)
{
rstop = 1;
}
static Cfg *cfg;
static List *proxyrelays;
int main(int argc, char *argv[])
{
int cfidx;
Octstr *fname;
CfgGroup *grp;
Octstr *log, *alog;
long loglevel;
mms_lib_init();
srandom(time(NULL));
cfidx = get_and_set_debugs(argc, argv, NULL);
if (argv[cfidx] == NULL)
fname = octstr_imm("mmsc.conf");
else
fname = octstr_create(argv[cfidx]);
cfg = cfg_create(fname);
if (cfg_read(cfg) == -1)
panic(0, "Couldn't read configuration from '%s'.", octstr_get_cstr(fname));
octstr_destroy(fname);
info(0, "----------------------------------------");
info(0, " MMSC Mobile queue runner version %s starting", MMSC_VERSION);
grp = cfg_get_single_group(cfg, octstr_imm("core"));
log = cfg_get(grp, octstr_imm("log-file"));
if (log != NULL) {
if (cfg_get_integer(&loglevel, grp, octstr_imm("log-level")) == -1)
loglevel = 0;
log_open(octstr_get_cstr(log), loglevel, GW_NON_EXCL);
octstr_destroy(log);
}
/* Get access log and open it. */
alog = cfg_get(grp, octstr_imm("access-log"));
if (alog) {
alog_open(octstr_get_cstr(alog), 1, 1);
octstr_destroy(alog);
}
/* Load proxy relays. */
proxyrelays = mms_proxy_relays(cfg);
/* Load settings. */
settings = mms_load_mmsbox_settings(cfg);
if (!settings)
panic(0, "No global MMSC configuration!");
mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));
httpcaller = http_caller_create();
if (gwthread_create((gwthread_func_t *)receive_push_reply, httpcaller) < 0) { /* Listener thread. */
error(0, "Mobile sender: Failed to create push reply thread: %d: %s!",
@ -534,19 +462,12 @@ int main(int argc, char *argv[])
return -1;
}
signal(SIGHUP, quit_now);
signal(SIGTERM, quit_now);
signal(SIGPIPE,SIG_IGN); /* Ignore pipe errors. They kill us sometimes for nothing*/
mms_queue_run(octstr_get_cstr(settings->mm1_queuedir),
sendNotify, settings->queue_interval, settings->maxthreads, &rstop);
mms_stop_profile_engine();
sleep(2); /* Wait for it to die. */
http_caller_signal_shutdown(httpcaller);
sleep(2);
http_caller_destroy(httpcaller);
return 0;
}

113
mbuni/mmsc/mmsrelay.c Normal file
View File

@ -0,0 +1,113 @@
/*
* Mbuni - Open Source MMS Gateway
*
* MMS Relay, implements message routing
*
* 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)
*/
#include "mmsrelay.h"
static Cfg *cfg;
MmsBoxSettings *settings;
List *proxyrelays;
int rstop = 0; /* Set to 1 to stop relay. */
static void quit_now(int notused)
{
rstop = 1;
}
int main(int argc, char *argv[])
{
int cfidx;
Octstr *fname;
CfgGroup *grp;
Octstr *log, *alog;
long loglevel;
long qthread = 0;
mms_lib_init();
srandom(time(NULL));
cfidx = get_and_set_debugs(argc, argv, NULL);
if (argv[cfidx] == NULL)
fname = octstr_imm("mmsc.conf");
else
fname = octstr_create(argv[cfidx]);
cfg = cfg_create(fname);
if (cfg_read(cfg) == -1)
panic(0, "Couldn't read configuration from '%s'.", octstr_get_cstr(fname));
octstr_destroy(fname);
info(0, "----------------------------------------");
info(0, " MMSC Relay version %s starting", MMSC_VERSION);
grp = cfg_get_single_group(cfg, octstr_imm("core"));
log = cfg_get(grp, octstr_imm("log-file"));
if (log != NULL) {
if (cfg_get_integer(&loglevel, grp, octstr_imm("log-level")) == -1)
loglevel = 0;
log_open(octstr_get_cstr(log), loglevel, GW_NON_EXCL);
octstr_destroy(log);
}
/* Get access log and open it. */
alog = cfg_get(grp, octstr_imm("access-log"));
if (alog) {
alog_open(octstr_get_cstr(alog), 1, 1);
octstr_destroy(alog);
}
/* Load proxy relays. */
proxyrelays = mms_proxy_relays(cfg);
/* Load settings. */
settings = mms_load_mmsbox_settings(cfg);
if (!settings)
panic(0, "No global MMSC configuration!");
mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));
signal(SIGHUP, quit_now);
signal(SIGTERM, quit_now);
signal(SIGPIPE,SIG_IGN); /* Ignore pipe errors. They kill us sometimes for nothing*/
/* Start global queue runner. */
info(0, "Starting Global Queue Runner...");
qthread = gwthread_create(mbuni_global_queue_runner, NULL);
/* Start the local queue runner. */
info(0, "Starting Local Queue Runner...");
mbuni_mm1_queue_runner(NULL);
gwthread_join(qthread); /* Wait for it to die... */
sleep(2);
/* It terminates, so start dying... */
mms_stop_profile_engine(); /* Stop profile stuff. */
sleep(2); /* Wait for them to die. */
return 0;
};

29
mbuni/mmsc/mmsrelay.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef __MMSRELAY_INCLUDED__
#define __MMSRELAY_INCLUDED__
/*
* Mbuni - Open Source MMS Gateway
*
* MMS Relay, implements message routing
*
* 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)
*/
#include <signal.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include "mms_queue.h"
#include "mms_uaprof.h"
#include "mms_util.h"
#include "mms_mm7soap.h"
extern void mbuni_global_queue_runner(void *unused);
extern void mbuni_mm1_queue_runner(void *unused);
extern MmsBoxSettings *settings;
extern List *proxyrelays;
extern int rstop;
#endif