[svn-commits] may: branch may/smpp r401116 - /team/may/smpp/branches/10/addons/res_smpp.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 16 20:28:51 CDT 2013


Author: may
Date: Wed Oct 16 20:28:49 2013
New Revision: 401116

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=401116
Log:
adjust size of login data fields
process errors on msg processing


Modified:
    team/may/smpp/branches/10/addons/res_smpp.c

Modified: team/may/smpp/branches/10/addons/res_smpp.c
URL: http://svnview.digium.com/svn/asterisk/team/may/smpp/branches/10/addons/res_smpp.c?view=diff&rev=401116&r1=401115&r2=401116
==============================================================================
--- team/may/smpp/branches/10/addons/res_smpp.c (original)
+++ team/may/smpp/branches/10/addons/res_smpp.c Wed Oct 16 20:28:49 2013
@@ -15,10 +15,16 @@
 // todo
 // data coding scheme +
 // message-id +
-// bind_resp failed
+// bind_resp failed +
 // locking +
 // memory leaks & valgrind testing +
 // many other things ;)
+// tlv??
+// dlr??
+// ton/npi params
+// empty system_id in bind_resp (unpack failed, libsmpp error??)
+// 0.0.0.0 in 'smpp show peers' if esme allowed to connect from any
+// must be connected ip instead
 
 #include "asterisk.h"
 #include <pthread.h>
@@ -93,9 +99,9 @@
 
 struct smpp_smsc {
 	char name[256];
-	char system_id[16];
-	char password[9];
-	char system_type[13];
+	char system_id[17];
+	char password[10];
+	char system_type[14];
 	int seq;
 	int enquire;
 	time_t lastenq;
@@ -216,14 +222,17 @@
 	enq = unpack;
 	enq_resp = unpack;
 
-	if ((uint32_t)submit_sm_resp->command_id == (uint32_t) SUBMIT_SM_RESP && submit_sm_resp->command_status == ESME_ROK) {
+	if ((uint32_t)submit_sm_resp->command_id == (uint32_t) SUBMIT_SM_RESP) {
 		sequence_number = submit_sm_resp->sequence_number;
 		AST_LIST_LOCK(&smsc->respq);
 		AST_LIST_TRAVERSE(&smsc->respq, resp, next) {
 			ast_mutex_lock(&resp->lock);
 			if (resp->sequence_number == sequence_number) {
-				resp->delivered = 1;
-				snprintf((char *)resp->message_id, sizeof(resp->message_id), "%s", submit_sm_resp->message_id);
+				if (submit_sm_resp->command_status == ESME_ROK) {
+					resp->delivered = 1;
+					snprintf((char *)resp->message_id, sizeof(resp->message_id), "%s",
+						submit_sm_resp->message_id);
+				}
 				ast_mutex_unlock(&resp->lock);
 				break;
 			}
@@ -235,13 +244,15 @@
 		}
 		AST_LIST_UNLOCK(&smsc->respq);
 
-	} else if ((uint32_t)deliver_sm_resp->command_id == (uint32_t) DELIVER_SM_RESP && deliver_sm_resp->command_status == ESME_ROK) {
+	} else if ((uint32_t)deliver_sm_resp->command_id == (uint32_t) DELIVER_SM_RESP) {
 		sequence_number = deliver_sm_resp->sequence_number;
 		AST_LIST_LOCK(&smsc->respq);
 		AST_LIST_TRAVERSE(&smsc->respq, resp, next) {
 			ast_mutex_lock(&resp->lock);
 			if (resp->sequence_number == sequence_number) {
-				resp->delivered = 1;
+				if (deliver_sm_resp->command_status == ESME_ROK) {
+					resp->delivered = 1;
+				}
 				ast_mutex_unlock(&resp->lock);
 				break;
 			}
@@ -290,12 +301,12 @@
 
 		ast_msg_set_var(msg, "smpp_source", smsc->name);
 
-		ast_msg_queue(msg);
+		res = ast_msg_queue(msg);
 
 		memset(&sm_resp, 0, sizeof(sm_resp));
 		sm_resp.command_length = 0;
 		sm_resp.command_id = DELIVER_SM_RESP;
-		sm_resp.command_status = ESME_ROK;
+		sm_resp.command_status = (res != -1) ? ESME_ROK : ESME_RUNKNOWNERR;
 		sm_resp.sequence_number = sequence_number;
 		snprintf((char*)sm_resp.message_id, sizeof(sm_resp.message_id), "%s", "");
 
@@ -331,12 +342,12 @@
 
 		ast_msg_set_var(msg, "smpp_source", smsc->name);
 
-		ast_msg_queue(msg);
+		res = ast_msg_queue(msg);
 
 		memset(&sm_resp, 0, sizeof(sm_resp));
 		sm_resp.command_length = 0;
 		sm_resp.command_id = SUBMIT_SM_RESP;
-		sm_resp.command_status = ESME_ROK;
+		sm_resp.command_status = (res != -1) ? ESME_ROK : ESME_RUNKNOWNERR;
 		sm_resp.sequence_number = sequence_number;
 		snprintf((char*)sm_resp.message_id, sizeof(sm_resp.message_id), "%s", messageid);
 
@@ -442,7 +453,7 @@
 
 			if (smsc->socket) {
 				ast_log(LOG_WARNING, "ESME %s already connected\n", smsc->name);
-				return NULL;
+				break;
 			}
 			smsc->socket = socket;
 			smsc->seq = 1;
@@ -566,7 +577,7 @@
 	snprintf((char*)bind.password, sizeof(bind.password), "%s", smsc->password);
 	snprintf((char*)bind.system_type, sizeof(bind.system_type), "%s", smsc->system_type);
 	bind.interface_version = 0x34;
-	bind.addr_ton = 2;
+	bind.addr_ton = 1;
 	bind.addr_npi = 1;
 	snprintf((char*)bind.address_range, sizeof(bind.address_range), "%s", "");
 




More information about the svn-commits mailing list