[PATCH] dlr-group-id : Multiple SMSCs and a DLR group
Ben Suffolk <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
> I think a simple fix would be to have another field say dlr-id, > which if not set would default to the smsc-id. This field would > then be used for the smsc name in the dlr tables. This way you can > group multiple smscs into a logical dlr group, but still have > individual control over them. > > Any thoughts on this before I have a go at implementing it? Well I got no responses in the negative to this idea, so I have implemented it. This patch allows you to add a config option to the smsc group called dlr-group-id, this lets you have several SMSCs with different id's grouped together so that they can share DLR data. i.e. in the situation that you send a message via one SMSC and get the DLR back via the other but you want to allow all the SMSCs to have different id's for control / logging purposes. If you do not specify dlr-group-id in the config is uses smsc-id as before. Regards Ben
dlr_group_smsc.patch
(application/octet-stream, 14.3 KB)
? .DS_Store
? gw/.DS_Store
Index: doc/userguide/userguide.xml
===================================================================
RCS file: /home/cvs/gateway/doc/userguide/userguide.xml,v
retrieving revision 1.327
diff -u -p -r1.327 userguide.xml
--- doc/userguide/userguide.xml 22 Jan 2007 15:12:42 -0000 1.327
+++ doc/userguide/userguide.xml 29 Jan 2007 12:50:27 -0000
@@ -2399,6 +2399,17 @@ secret-nas = radius
</entry></row>
+ <row><entry><literal>dlr-group-id</literal></entry>
+ <entry><literal>string</literal></entry>
+ <entry valign="bottom">
+ An optional name or id for grouping more than one SMSC together for the purposes
+ of Delivery Reports. e.g. if you have multiple SMSC connections to the same provider
+ and there is the possibility that you can receive the DLR on a different connection to
+ the one you sent the message on, then you should group the SMSCs together. This allows
+ you to have different <literal>smsc-id</literal> specified for each SMSC whilst mainting
+ functional DLRs.
+ </entry></row>
+
<row><entry><literal>throughput</literal></entry>
<entry><literal>number (messages/sec)</literal></entry>
<entry valign="bottom">
Index: gw/smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn.c,v
retrieving revision 1.56
diff -u -p -r1.56 smscconn.c
--- gw/smscconn.c 7 Jan 2007 23:53:00 -0000 1.56
+++ gw/smscconn.c 29 Jan 2007 12:50:28 -0000
@@ -184,6 +184,10 @@ SMSCConn *smscconn_create(CfgGroup *grp,
}while(0)
GET_OPTIONAL_VAL(conn->id, "smsc-id");
+ GET_OPTIONAL_VAL(conn->dlr_group_id, "dlr-group-id");
+ if (conn->dlr_group_id == NULL)
+ conn->dlr_group_id = octstr_duplicate(conn->id);
+
SPLIT_OPTIONAL_VAL(conn->allowed_smsc_id, "allowed-smsc-id");
SPLIT_OPTIONAL_VAL(conn->denied_smsc_id, "denied-smsc-id");
SPLIT_OPTIONAL_VAL(conn->preferred_smsc_id, "preferred-smsc-id");
@@ -330,6 +334,7 @@ int smscconn_destroy(SMSCConn *conn)
octstr_destroy(conn->name);
octstr_destroy(conn->id);
+ octstr_destroy(conn->dlr_group_id);
gwlist_destroy(conn->allowed_smsc_id, octstr_destroy_item);
gwlist_destroy(conn->denied_smsc_id, octstr_destroy_item);
gwlist_destroy(conn->preferred_smsc_id, octstr_destroy_item);
Index: gw/smscconn_p.h
===================================================================
RCS file: /home/cvs/gateway/gw/smscconn_p.h,v
retrieving revision 1.50
diff -u -p -r1.50 smscconn_p.h
--- gw/smscconn_p.h 7 Jan 2007 23:52:59 -0000 1.50
+++ gw/smscconn_p.h 29 Jan 2007 12:50:28 -0000
@@ -168,6 +168,7 @@ struct smscconn {
Octstr *name; /* Descriptive name filled from connection info */
Octstr *id; /* Abstract name specified in configuration and
used for logging and routing */
+ Octstr *dlr_group_id; /* ID used for DLRs specified in configuration */
List *allowed_smsc_id;
List *denied_smsc_id;
List *preferred_smsc_id;
Index: gw/smsc/smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.33
diff -u -p -r1.33 smsc_at.c
--- gw/smsc/smsc_at.c 7 Jan 2007 23:52:53 -0000 1.33
+++ gw/smsc/smsc_at.c 29 Jan 2007 12:50:30 -0000
@@ -1891,7 +1891,7 @@ static Msg *at2_pdu_decode_report_sm(Oct
* categories. It will catch "reserved" values where the first 3 MSBits
* are not set as "Success" which may not be correct. */
- if ((dlrmsg = dlr_find(privdata->conn->id, msg_id, receiver, type)) == NULL) {
+ if ((dlrmsg = dlr_find(privdata->conn->dlr_group_id, msg_id, receiver, type)) == NULL) {
debug("bb.smsc.at2", 1, "AT2[%s]: Received delivery notification but can't find that ID in the DLR storage",
octstr_get_cstr(privdata->name));
goto error;
@@ -2092,7 +2092,7 @@ static void at2_send_one_message(PrivAT2
else {
Octstr *dlrmsgid = octstr_format("%d", msg_id);
- dlr_add(privdata->conn->id, dlrmsgid, msg);
+ dlr_add(privdata->conn->dlr_group_id, dlrmsgid, msg);
O_DESTROY(dlrmsgid);
}
Index: gw/smsc/smsc_cgw.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_cgw.c,v
retrieving revision 1.15
diff -u -p -r1.15 smsc_cgw.c
--- gw/smsc/smsc_cgw.c 7 Jan 2007 23:52:53 -0000 1.15
+++ gw/smsc/smsc_cgw.c 29 Jan 2007 12:50:31 -0000
@@ -1134,19 +1134,19 @@ static int cgw_handle_op(SMSCConn *conn,
switch (stat) {
case 0: /* delivered */
- dlrmsg = dlr_find(conn->id,
+ dlrmsg = dlr_find(conn->dlr_group_id,
ts, /* timestamp */
msid, /* destination */
DLR_SUCCESS);
break;
case 1: /* buffered */
- dlrmsg = dlr_find(conn->id,
+ dlrmsg = dlr_find(conn->dlr_group_id,
ts, /* timestamp */
msid, /* destination */
DLR_BUFFERED);
break;
case 2: /* not delivered */
- dlrmsg = dlr_find(conn->id,
+ dlrmsg = dlr_find(conn->dlr_group_id,
ts, /* timestamp */
msid, /* destination */
DLR_FAIL);
@@ -1181,7 +1181,7 @@ static int cgw_handle_op(SMSCConn *conn,
octstr_append_char(ts, '-');
octstr_append_decimal(ts, trn);
- dlr_add(conn->id, ts, msg);
+ dlr_add(conn->dlr_group_id, ts, msg);
octstr_destroy(ts);
privdata->dlr[trn] = 1;
Index: gw/smsc/smsc_cimd2.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_cimd2.c,v
retrieving revision 1.30
diff -u -p -r1.30 smsc_cimd2.c
--- gw/smsc/smsc_cimd2.c 7 Jan 2007 23:52:53 -0000 1.30
+++ gw/smsc/smsc_cimd2.c 29 Jan 2007 12:50:33 -0000
@@ -1976,7 +1976,7 @@ static int cimd2_submit_msg(SMSCConn *co
ret = cimd2_request(packet, conn, &ts);
if((ret == 0) && (ts) && DLR_IS_SUCCESS_OR_FAIL(msg->sms.dlr_mask) && !pdata->no_dlr) {
- dlr_add(conn->name, ts, msg);
+ dlr_add(conn->dlr_group_id, ts, msg);
}
octstr_destroy(ts);
packet_destroy(packet);
@@ -2114,7 +2114,7 @@ static Msg *cimd2_accept_delivery_report
code = 0;
}
if(code)
- msg = dlr_find(conn->name, timestamp, destination, code);
+ msg = dlr_find(conn->dlr_group_id, timestamp, destination, code);
else
msg = NULL;
Index: gw/smsc/smsc_emi.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_emi.c,v
retrieving revision 1.19
diff -u -p -r1.19 smsc_emi.c
--- gw/smsc/smsc_emi.c 7 Jan 2007 23:52:53 -0000 1.19
+++ gw/smsc/smsc_emi.c 29 Jan 2007 12:50:34 -0000
@@ -839,19 +839,19 @@ static int handle_operation(SMSCConn *co
switch(st_code)
{
case 0: /* delivered */
- msg = dlr_find((conn->id ? conn->id : privdata->name),
+ msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
emimsg->fields[E50_SCTS], /* timestamp */
emimsg->fields[E50_OADC], /* destination */
DLR_SUCCESS);
break;
case 1: /* buffered */
- msg = dlr_find((conn->id ? conn->id : privdata->name),
+ msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
emimsg->fields[E50_SCTS], /* timestamp */
emimsg->fields[E50_OADC], /* destination */
DLR_BUFFERED);
break;
case 2: /* not delivered */
- msg = dlr_find((conn->id ? conn->id : privdata->name),
+ msg = dlr_find((conn->dlr_group_id ? conn->dlr_group_id : privdata->name),
emimsg->fields[E50_SCTS], /* timestamp */
emimsg->fields[E50_OADC], /* destination */
DLR_FAIL);
@@ -1104,7 +1104,7 @@ static int emi2_handle_smscreq(SMSCConn
info(0,"EMI2[%s]: uhhh m is NULL, very bad",
octstr_get_cstr(privdata->name));
} else if (DLR_IS_ENABLED_DEVICE(m->sms.dlr_mask)) {
- dlr_add((conn->id ? conn->id : privdata->name), ts, m);
+ dlr_add((conn->dlr_group_id ? conn->dlr_group_id : privdata->name), ts, m);
}
octstr_destroy(ts);
octstr_destroy(adc);
Index: gw/smsc/smsc_fake.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_fake.c,v
retrieving revision 1.20
diff -u -p -r1.20 smsc_fake.c
--- gw/smsc/smsc_fake.c 7 Jan 2007 23:52:53 -0000 1.20
+++ gw/smsc/smsc_fake.c 29 Jan 2007 12:50:34 -0000
@@ -288,7 +288,7 @@ static void main_connection_loop(SMSCCon
uuid_unparse(copy->sms.id, id);
tmp = octstr_create(id);
- dlrmsg = dlr_find(conn->id,
+ dlrmsg = dlr_find(conn->dlr_group_id,
tmp, /* smsc message id */
copy->sms.receiver, /* destination */
dlrstat);
@@ -446,7 +446,7 @@ static int add_msg_cb(SMSCConn *conn, Ms
char id[UUID_STR_LEN + 1];
uuid_unparse(sms->sms.id, id);
tmp = octstr_format("%s", id);
- dlr_add(conn->id, tmp, sms);
+ dlr_add(conn->dlr_group_id, tmp, sms);
octstr_destroy(tmp);
}
gwlist_produce(privdata->outgoing_queue, copy);
Index: gw/smsc/smsc_http.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_http.c,v
retrieving revision 1.53
diff -u -p -r1.53 smsc_http.c
--- gw/smsc/smsc_http.c 11 Jan 2007 20:18:16 -0000 1.53
+++ gw/smsc/smsc_http.c 29 Jan 2007 12:50:36 -0000
@@ -478,7 +478,7 @@ static void kannel_parse_reply(SMSCConn
/* add to our own DLR storage */
if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
- dlr_add(conn->id, mid, msg);
+ dlr_add(conn->dlr_group_id, mid, msg);
octstr_destroy(mid);
@@ -556,7 +556,7 @@ static void kannel_receive_sms(SMSCConn
/* we got a DLR, and we don't require additional values */
Msg *dlrmsg;
- dlrmsg = dlr_find(conn->id,
+ dlrmsg = dlr_find(conn->dlr_group_id,
dlrmid, /* message id */
to, /* destination */
dlrmask);
@@ -735,7 +735,7 @@ static void clickatell_parse_reply(SMSCC
/* SMSC ACK.. now we have the message id. */
if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
- dlr_add(conn->id, msgid, msg);
+ dlr_add(conn->dlr_group_id, msgid, msg);
bb_smscconn_sent(conn, msg, NULL);
@@ -834,7 +834,7 @@ static void clickatell_receive_sms(SMSCC
dlrstat = 16; /* smsc reject */
break;
}
- dlrmsg = dlr_find(conn->id,
+ dlrmsg = dlr_find(conn->dlr_group_id,
apimsgid, /* smsc message id */
dest , /* destination */
dlrstat);
@@ -1239,7 +1239,7 @@ static void xidris_parse_reply(SMSCConn
/* SMSC ACK.. now we have the message id. */
if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
- dlr_add(conn->id, mid, msg);
+ dlr_add(conn->dlr_group_id, mid, msg);
octstr_destroy(mid);
bb_smscconn_sent(conn, msg, NULL);
@@ -1313,7 +1313,7 @@ static void xidris_receive_sms(SMSCConn
else
dlrstat = DLR_FAIL;
- dlrmsg = dlr_find(conn->id,
+ dlrmsg = dlr_find(conn->dlr_group_id,
mid, /* smsc message id */
dest , /* destination */
dlrstat);
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.100
diff -u -p -r1.100 smsc_smpp.c
--- gw/smsc/smsc_smpp.c 23 Jan 2007 16:18:26 -0000 1.100
+++ gw/smsc/smsc_smpp.c 29 Jan 2007 12:50:41 -0000
@@ -1279,7 +1279,7 @@ static Msg *handle_dlr(SMPP *smpp, Octst
}
}
- dlrmsg = dlr_find(smpp->conn->id,
+ dlrmsg = dlr_find(smpp->conn->dlr_group_id,
tmp, /* smsc message id */
destination_addr, /* destination */
dlrstat);
@@ -1507,7 +1507,7 @@ static void handle_pdu(SMPP *smpp, Conne
/* SMSC ACK.. now we have the message id. */
if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask))
- dlr_add(smpp->conn->id, tmp, msg);
+ dlr_add(smpp->conn->dlr_group_id, tmp, msg);
octstr_destroy(tmp);
bb_smscconn_sent(smpp->conn, msg, NULL);
Index: gw/smsc/smsc_soap.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_soap.c,v
retrieving revision 1.18
diff -u -p -r1.18 smsc_soap.c
--- gw/smsc/smsc_soap.c 7 Jan 2007 23:52:54 -0000 1.18
+++ gw/smsc/smsc_soap.c 29 Jan 2007 12:50:44 -0000
@@ -1174,7 +1174,7 @@ static void soap_read_response(SMSCConn
sprintf(tmpid,"%lld",msgID);
debug("bb.soap.read_response",0,"SOAP[%s]: ACK - id: %lld", octstr_get_cstr(privdata->name), msgID);
- dlr_add(conn->id, octstr_imm(tmpid), msg);
+ dlr_add(conn->dlr_group_id, octstr_imm(tmpid), msg);
/* send msg back to bearerbox for recycling */
bb_smscconn_sent(conn, msg, NULL);
@@ -1616,7 +1616,7 @@ static long soap_parse_dlr(SMSCConn *con
/* fetch the DLR */
- dlrmsg = dlr_find(conn->id, octstr_imm(msgid), octstr_imm("receiver"), /* destination */
+ dlrmsg = dlr_find(conn->dlr_group_id, octstr_imm(msgid), octstr_imm("receiver"), /* destination */
dlrtype);
if (!dlrmsg) {
Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.126
diff -u -p -r1.126 cfg.def
--- gwlib/cfg.def 22 Jan 2007 15:12:42 -0000 1.126
+++ gwlib/cfg.def 29 Jan 2007 12:50:44 -0000
@@ -289,6 +289,7 @@ MULTI_GROUP(smsbox-route,
MULTI_GROUP(smsc,
OCTSTR(smsc)
OCTSTR(smsc-id)
+ OCTSTR(dlr-group-id)
OCTSTR(denied-smsc-id)
OCTSTR(allowed-smsc-id)
OCTSTR(preferred-smsc-id)