1
0
Fork 0

new configs

This commit is contained in:
bagyenda 2007-12-15 08:40:22 +00:00
parent cade2f51a9
commit d0714028b5
9 changed files with 147 additions and 32 deletions

View File

@ -1,3 +1,6 @@
2007-12-15 P. A. Bagyenda <bagyenda@dsmagic.com>
* Added allowed-sender-prefix/denied-sender-prefix for mmsc group of mmsbox config
* Added allowed-receiver-prefix/denied-receiver-prefix to mms-service group of mmsbox config
2007-11-27 P. A. Bagyenda <bagyenda@dsmagic.com>
* Bug fix in mime convertor module
2007-11-07 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -2327,6 +2327,32 @@ string
</td>
</tr>
<tr>
<td valign=top >
<tt>allowed-sender-prefix</tt>
</td>
<td valign=top >
Number list
</td>
<td valign=top >
List of
sender number prefixes that can use this MMSC
</td>
</tr>
<tr>
<td valign=top >
<tt>denied-sender-prefix</tt>
</td>
<td valign=top >
Number list
</td>
<td valign=top >
List of
sender number prefixes that cannot use this MMSC
</td>
</tr>
<tr>
<td valign=top >
<tt>max-throughput</tt>
@ -2964,6 +2990,35 @@ A detailed list of configuration parameters for MMS Services is given below.
</td>
</tr>
<tr>
<td valign=top >
<tt>accepted-receiver-prefix</tt>
</td>
<td valign=top >
Strings
</td>
<td valign=top >
Colon-separated strings: List of receiver short code prefixes
allowed to use
this MMS Service.
</td>
</tr>
<tr>
<td valign=top >
<tt>denied-receiver-prefix</tt>
</td>
<td valign=top >
Strings
</td>
<td valign=top >
Colon-separated strings: List of receiver short code prefixes not
allowed to use
this MMS Service.
</td>
</tr>
<tr>
<td valign=top >
<tt>get-url</tt>

View File

@ -133,6 +133,8 @@ MULTI_GROUP(mmsc,
OCTSTR(deny-ip)
OCTSTR(allowed-prefix)
OCTSTR(denied-prefix)
OCTSTR(denied-sender-prefix)
OCTSTR(accepted-sender-prefix)
OCTSTR(incoming-port-ssl)
OCTSTR(max-throughput)
OCTSTR(type)
@ -163,6 +165,8 @@ MULTI_GROUP(mms-service,
OCTSTR(assume-plain-text)
OCTSTR(accepted-mmscs)
OCTSTR(denied-mmscs)
OCTSTR(denied-receiver-prefix)
OCTSTR(accepted-receiver-prefix)
OCTSTR(keyword)
OCTSTR(aliases)
OCTSTR(http-post-parameters)

View File

@ -1718,3 +1718,20 @@ void *_mms_load_module(mCfgGrp *grp, char *config_key, char *symbolname,
return retval;
}
Octstr *extract_phonenum(Octstr *num, Octstr *unified_prefix)
{
Octstr *phonenum;
int j = octstr_case_search(num, octstr_imm("/TYPE=PLMN"), 0);
if (j > 0 && j - 1 + sizeof "/TYPE=PLMN" == octstr_len(num))
phonenum = octstr_copy(num, 0, j);
else
phonenum = octstr_duplicate(num);
if (unified_prefix)
normalize_number(octstr_get_cstr(unified_prefix), &phonenum);
return phonenum;
}

View File

@ -198,6 +198,9 @@ int has_node_children(xmlNodePtr node);
/* strip non-essential headers from top-level */
void strip_non_essential_headers(MIMEEntity *mime);
/* Get phone number out of mms formatted one, and unify. */
Octstr *extract_phonenum(Octstr *num, Octstr *unified_prefix);
/* load a shared object, then load a symbol from it. */
void *_mms_load_module(mCfgGrp *grp, char *config_key, char *symbolname,
void *shell_builtin);

View File

@ -930,7 +930,7 @@ static int sendMsg(MmsEnvelope *e)
goto done;
}
if ((mmc = get_handler_mmc(e->viaproxy, to->rcpt)) == NULL) {
if ((mmc = get_handler_mmc(e->viaproxy, to->rcpt, e->from)) == NULL) {
err = octstr_format("MMSBox error: Failed to deliver to "
"%S. Don't know how to route!",
to->rcpt);

View File

@ -135,10 +135,11 @@ static int _x_octstr_comp(Octstr *x, Octstr *y)
return (octstr_case_compare(x,y) == 0);
}
static MmsService *get_service(Octstr *keyword, Octstr *mmc_id)
static MmsService *get_service(Octstr *keyword, Octstr *mmc_id, Octstr *receiver)
{
int i, n;
MmsService *catch_all = NULL;
Octstr *phonenum = receiver ? extract_phonenum(receiver, unified_prefix) : NULL;
for (i = 0, n = gwlist_len(mms_services); i < n; i++) {
MmsService *ms = gwlist_get(mms_services,i);
@ -154,16 +155,27 @@ static MmsService *get_service(Octstr *keyword, Octstr *mmc_id)
if (ms->allowed_mmscs &&
gwlist_search(ms->allowed_mmscs, mmc_id, (gwlist_item_matches_t *)octstr_compare) == NULL)
continue;
if (ms->denied_receiver_prefix && phonenum &&
does_prefix_match(ms->denied_receiver_prefix, phonenum) != 0)
continue;
if (ms->allowed_receiver_prefix && phonenum &&
does_prefix_match(ms->denied_receiver_prefix, phonenum) == 0)
continue;
if (keyword &&
gwlist_search(ms->keywords, keyword,
(gwlist_item_matches_t *)_x_octstr_comp) != NULL)
(gwlist_item_matches_t *)_x_octstr_comp) != NULL) {
octstr_destroy(phonenum);
return ms;
}
if (ms->isdefault && catch_all == NULL) /* We also find the catch-all for this sender. */
catch_all = ms;
}
octstr_destroy(phonenum);
return catch_all;
}
@ -482,7 +494,8 @@ static int mmsbox_service_dispatch(MmsEnvelope *e)
time_t tnow = time(NULL);
Octstr *err = NULL, *keyword = NULL;
MmsService *ms;
MmsEnvelopeTo *xto;
gw_assert(e->msgtype == MMS_MSGTYPE_SEND_REQ ||
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF);
@ -512,8 +525,9 @@ static int mmsbox_service_dispatch(MmsEnvelope *e)
me = mms_tomime(msg, 0);
keyword = get_keyword(me);
ms = get_service(keyword, e->fromproxy);
xto = gwlist_get(e->to, 0);
ms = get_service(keyword, e->fromproxy, xto ? xto->rcpt : NULL);
if (!ms) {
err = octstr_format("No Service to handle %S (keyword %S)!",

View File

@ -193,6 +193,9 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
m->allowed_prefix = mms_cfg_get(x, octstr_imm("allowed-prefix"));
m->denied_prefix = mms_cfg_get(x, octstr_imm("denied-prefix"));
m->allowed_sender_prefix = mms_cfg_get(x, octstr_imm("allowed-sender-prefix"));
m->denied_sender_prefix = mms_cfg_get(x, octstr_imm("denied-sender-prefix"));
m->incoming.allow_ip = mms_cfg_get(x, octstr_imm("allow-ip"));
m->incoming.deny_ip = mms_cfg_get(x, octstr_imm("deny-ip"));
@ -361,6 +364,9 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
octstr_destroy(s);
} else
m->denied_mmscs = NULL; /* means allow all. */
m->allowed_receiver_prefix = mms_cfg_get(x, octstr_imm("allowed-receiver-prefix"));
m->denied_receiver_prefix = mms_cfg_get(x, octstr_imm("denied-receiver-prefix"));
/* Get key words. Start with aliases to make life easier. */
if ((s = mms_cfg_get(x, octstr_imm("aliases"))) != NULL) {
@ -446,42 +452,52 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
}
/* Get the MMC that should handler this recipient. */
MmscGrp *get_handler_mmc(Octstr *id, Octstr *to)
MmscGrp *get_handler_mmc(Octstr *id, Octstr *to, Octstr *from)
{
MmscGrp *mmc = NULL;
int i, j, n;
Octstr *phonenum = NULL;
MmscGrp *mmc = NULL, *res = NULL;
int i, n;
Octstr *phonenum = NULL, *xfrom = NULL;
if (id)
for (i = 0, n = gwlist_len(mmscs); i < n; i++)
if ((mmc = gwlist_get(mmscs, i)) != NULL &&
mmc->id && octstr_compare(mmc->id, id) == 0)
mmc->id && octstr_compare(mmc->id, id) == 0)
return mmc;
if (octstr_search_char(to, '@', 0) > 0 ||
octstr_case_search(to, octstr_imm("/TYPE=IPv"), 0) > 0) /* For emails, or ip take first mmsc. */
return gwlist_get(mmscs, 0);
j = octstr_case_search(to, octstr_imm("/TYPE=PLMN"), 0);
if (j > 0 && j - 1 + sizeof "/TYPE=PLMN" == octstr_len(to))
phonenum = octstr_copy(to, 0, j);
else
phonenum = octstr_duplicate(to);
normalize_number(octstr_get_cstr(unified_prefix), &phonenum);
for (i = 0, n = gwlist_len(mmscs); i < n; i++)
if ((mmc = gwlist_get(mmscs, i)) != NULL &&
(mmc->allowed_prefix == NULL ||
does_prefix_match(mmc->allowed_prefix, phonenum)) &&
(mmc->denied_prefix == NULL ||
!does_prefix_match(mmc->denied_prefix, phonenum)))
return mmc;
phonenum = extract_phonenum(to, unified_prefix);
xfrom = extract_phonenum(from, unified_prefix);
for (i = 0, n = gwlist_len(mmscs); i < n; i++) {
if ((mmc = gwlist_get(mmscs, i)) == NULL)
continue;
if (mmc->allowed_prefix &&
does_prefix_match(mmc->allowed_prefix, phonenum) == 0)
continue; /* does not match. */
if (mmc->denied_prefix &&
does_prefix_match(mmc->denied_prefix, phonenum) != 0)
continue; /* matches. */
if (phonenum)
octstr_destroy(phonenum);
return NULL;
if (mmc->allowed_sender_prefix &&
does_prefix_match(mmc->allowed_sender_prefix, xfrom) == 0)
continue; /* does not match. */
if (mmc->denied_sender_prefix &&
does_prefix_match(mmc->denied_sender_prefix, xfrom) != 0)
continue; /* matches. */
res = mmc; /* otherwise it matches, so go away. */
break;
}
octstr_destroy(phonenum);
octstr_destroy(xfrom);
return res;
}
/* handle message routing. */

View File

@ -30,6 +30,7 @@ typedef struct MmscGrp {
long port;
} incoming; /* user, pass, port (and whether SSL) that MMSC uses to connect to us. */
Octstr *allowed_prefix, *denied_prefix;
Octstr *allowed_sender_prefix, *denied_sender_prefix;
enum {UNKNOWN_MMSC = -1, CUSTOM_MMSC, SOAP_MMSC, EAIF_MMSC} type; /* type of connection. */
long throughput; /* Max send rate. */
long threadid; /* handler thread. */
@ -77,6 +78,8 @@ typedef struct MmsService {
List *allowed_mmscs; /* List of MMSCs allowed to access this service (by ID). */
List *denied_mmscs; /* List of MMSCs allowed to access this service (by ID). */
Octstr *service_code; /* Service code (MM7/SOAP only) */
Octstr *allowed_receiver_prefix, *denied_receiver_prefix;
} MmsService;
typedef struct SendMmsUser {
@ -110,7 +113,7 @@ extern Octstr *rfs_settings;
extern int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func);
extern MmscGrp *get_handler_mmc(Octstr *id, Octstr *to);
extern MmscGrp *get_handler_mmc(Octstr *id, Octstr *to, Octstr *from);
extern Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m,
Octstr **mmc_id);