[PATCH] opensmppbox: message id generation fix

Alexander Kovalenko <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <CAKYTQV4+_CmyNHFup0zEm=C7oKaZhz0jjWTFZ2j6e8MeSmkBwQ@mail.gmail.com>
Greetings.

Recently we've noticed that under load opensmppbox may return same message
ids in submit_sm_resp responses.
Looking at the sources I see, that it returns only first 8 chars of
generated UUID. This is not correct, because these bytes may be same for
different UUIDs. I suppose it was coded in such way to support both smpp
v3.3 and v3.4. According to protocol v3.3 this field must be max 9 chars
including '\0'. But in v3.4 it's allowed to have up to 65 chars.
There is our patch in attachment. It was created against
https://svn.kannel.org/opensmppbox/trunk , revision 73.
For v3.3 opensmppbox will return only first 8 chars for UUID as before, but
for v3.4 and above it will return full generated UUID.

-- 
With best regards,
Alexander Kovalenko
Ardas Group Inc.www.ardas.dp.ua
use-full-uuid.diff (application/octet-stream, 2 KB)
Index: gw/opensmppbox.c
===================================================================
--- gw/opensmppbox.c	(revision 73)
+++ gw/opensmppbox.c	(working copy)
@@ -632,7 +632,7 @@
 }
 
 /* generate 8 character ID, taken from msgid */
-static Octstr *generate_smppid(Msg *msg)
+static Octstr *generate_smppid(Msg *msg, int version)
 {
 	char uuidbuf[100];
 	Octstr *result;
@@ -640,7 +640,7 @@
 	// gw_assert(msg->type == sms); // we segfault on this
 
 	uuid_unparse(msg->sms.id, uuidbuf);
-	result = octstr_create_from_data(uuidbuf, 8);
+	result = octstr_create_from_data(uuidbuf, version > 0x33 ? UUID_STR_LEN : 8);
 	return result;
 }
 
@@ -1599,14 +1599,14 @@
 			msg->sms.boxc_id = octstr_duplicate(box->boxc_id);
 			msg_dump(msg, 0);
 			resp = smpp_pdu_create(data_sm_resp, pdu->u.data_sm.sequence_number);
-			msgid = generate_smppid(msg);
+			msgid = generate_smppid(msg, box->version);
 			msg->sms.dlr_url = octstr_duplicate(msgid);
 			resp->u.data_sm_resp.message_id = msgid;
 			if (msg_to_send) {
 				if (DLR_IS_ENABLED(msg2->sms.dlr_mask)) {
 					hold_service = msg2->sms.service;
 					msg2->sms.service = octstr_format("%ld", msg2->sms.time);
-					msgid = generate_smppid(msg2);
+					msgid = generate_smppid(msg2, box->version);
 					if (parts_list) {
 						msg2->sms.dlr_url = concat_msgids(msgid, parts_list);
 					}
@@ -1641,14 +1641,14 @@
 			msg->sms.boxc_id = octstr_duplicate(box->boxc_id);
 			msg_dump(msg, 0);
 			resp = smpp_pdu_create(submit_sm_resp, pdu->u.submit_sm.sequence_number);
-			msgid = generate_smppid(msg);
+			msgid = generate_smppid(msg, box->version);
 			msg->sms.dlr_url = octstr_duplicate(msgid);
 			resp->u.submit_sm_resp.message_id = msgid;
 			if (msg_to_send) {
 				if (DLR_IS_ENABLED(msg2->sms.dlr_mask)) {
 					hold_service = msg2->sms.service;
 					msg2->sms.service = octstr_format("%ld", msg2->sms.time);
-					msgid = generate_smppid(msg2);
+					msgid = generate_smppid(msg2, box->version);
 					if (parts_list) {
 						msg2->sms.dlr_url = concat_msgids(msgid, parts_list);
 					}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.