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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 15 15:09:24 CDT 2013


Author: may
Date: Tue Oct 15 15:09:22 2013
New Revision: 401021

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=401021
Log:
add transceiver_bind_resp for failed input esme connections

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=401021&r1=401020&r2=401021
==============================================================================
--- team/may/smpp/branches/10/addons/res_smpp.c (original)
+++ team/may/smpp/branches/10/addons/res_smpp.c Tue Oct 15 15:09:22 2013
@@ -114,7 +114,9 @@
 	struct smpp_smsc *next;
 } *smsc_list = NULL;
 
+// forward declaration
 static struct smpp_buff* queue_pdu(struct smpp_smsc *smsc, uint32_t cmd, void *unpack);
+static int send_bind_resp_fail(int socket, int sequence, int command_status);
 
 //
 //	return conference parameters to channel driver
@@ -431,8 +433,10 @@
 	smsc = smsc_list;
 	while(smsc) {
 		if (smsc->esme && 
-			!strcmp((char *)bind.system_id, smsc->system_id) && !strcmp((char *)bind.password, smsc->password) &&
-			!strcmp((char *)bind.system_type, smsc->system_type) && 
+			!strcmp((char *)bind.system_id, smsc->system_id) &&
+			!strcmp((char *)bind.password, smsc->password) &&
+			!strcmp((char *)bind.system_type, smsc->system_type) &&
+
 			((smsc->host[0] == 0) || !strcmp(smsc->host, "0.0.0.0") || !strcmp(smsc->host, "dynamic") ||
 				!strcmp(smsc->host, host))) {
 
@@ -448,6 +452,7 @@
 	}
 
 	ast_verb(2, "Can't bind %s/%s/%s from %s:%d\n", bind.system_id, bind.password, bind.system_type, host, port);
+	send_bind_resp_fail(socket, bind.sequence_number, ESME_RBINDFAIL);
 	
 	return NULL;
 }
@@ -582,6 +587,43 @@
 	if (write(smsc->socket, pdu, pdulen) < 0) {
 		ast_log(LOG_WARNING, "smpp write error %s to smsc %s\n", strerror(errno),
 					smsc->name);
+		return 1;
+	}
+	return 0;
+}
+static int send_bind_resp_fail(int socket, int sequence, int command_status)
+{
+	bind_transceiver_resp_t bind_resp;
+        unsigned char pdu[2048];
+        unsigned char bPrint[2048];
+        int pdulen;
+        int ret;
+
+	memset(&bind_resp, 0, sizeof(bind));
+	memset(&pdu, 0, sizeof(pdu));
+	
+	bind_resp.command_length = 0;
+	bind_resp.command_id = BIND_TRANSCEIVER_RESP;
+	bind_resp.command_status = command_status;
+	bind_resp.sequence_number = sequence;
+
+	snprintf((char*)bind_resp.system_id, sizeof(bind_resp.system_id), "%s", "");
+
+	ret = smpp34_pack(BIND_TRANSCEIVER_RESP, pdu, sizeof(pdu), &pdulen, (void *)&bind_resp);
+	if (ret) {
+		ast_log(LOG_WARNING, "Error in smpp34_pack():%d:\n%s\n",
+						smpp34_errno, smpp34_strerror);
+		return 1;
+	}
+	if (smppDebug) {
+		if (smpp34_dumpPdu2(bPrint, sizeof(bPrint), (void *)&bind_resp)) {
+			ast_log(LOG_WARNING, "Error in smpp34_dumpPdu2():%d:\n%s\n",
+						smpp34_errno, smpp34_strerror);
+		} else {
+			ast_verb(3, "PDU Dump:\n%s\n", bPrint);
+		}
+	}
+	if (write(socket, pdu, pdulen) < 0) {
 		return 1;
 	}
 	return 0;




More information about the asterisk-commits mailing list