[svn-commits] may: branch may/smpp r420986 - in /team/may/smpp/trunk: ./ addons/res_smpp.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Aug 14 07:11:10 CDT 2014
Author: may
Date: Thu Aug 14 07:11:08 2014
New Revision: 420986
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=420986
Log:
add check_bind_npi, bind_ton, bind_npi paramters for bind operation
add src_ton/npi, dst_ton/npi message_data paramters (r/w)
........
Merged revisions 420984 from http://svn.asterisk.org/svn/asterisk/team/may/smpp/branches/10
Modified:
team/may/smpp/trunk/ (props changed)
team/may/smpp/trunk/addons/res_smpp.c
Propchange: team/may/smpp/trunk/
------------------------------------------------------------------------------
--- smpp-10-merge (original)
+++ smpp-10-merge Thu Aug 14 07:11:08 2014
@@ -1,1 +1,1 @@
-/team/may/smpp/branches/10:1-411579
+/team/may/smpp/branches/10:1-420985
Propchange: team/may/smpp/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 14 07:11:08 2014
@@ -1,1 +1,1 @@
-/team/may/smpp/branches/10:400905-401373,401882,402222,403011,404526,404528-404529,410963,411579
+/team/may/smpp/branches/10:400905-401373,401882,402222,403011,404526,404528-404529,410963,411579,420984
Modified: team/may/smpp/trunk/addons/res_smpp.c
URL: http://svnview.digium.com/svn/asterisk/team/may/smpp/trunk/addons/res_smpp.c?view=diff&rev=420986&r1=420985&r2=420986
==============================================================================
--- team/may/smpp/trunk/addons/res_smpp.c (original)
+++ team/may/smpp/trunk/addons/res_smpp.c Thu Aug 14 07:11:08 2014
@@ -143,6 +143,9 @@
char system_type[14];
int seq;
int enquire;
+ int bind_ton, bind_npi;
+ int addr_ton, addr_npi;
+ int check_bind:1;
time_t lastenq, sentenq;
char host[MAXHOSTNAMELEN];
char connected_host[MAXHOSTNAMELEN];
@@ -423,7 +426,15 @@
snprintf(tmp, sizeof(tmp), "%d", deliver->esm_class); \
ast_msg_set_var(msg, "esm_class", tmp); \
ast_base64encode(tmp, deliver->short_message, deliver->sm_length, sizeof(tmp)); \
- ast_msg_set_var(msg, "base64_body", tmp);
+ ast_msg_set_var(msg, "base64_body", tmp); \
+ snprintf(tmp, sizeof(tmp), "%d", deliver->source_addr_ton); \
+ ast_msg_set_var(msg, "src_ton", tmp); \
+ snprintf(tmp, sizeof(tmp), "%d", deliver->source_addr_npi); \
+ ast_msg_set_var(msg, "src_npi", tmp); \
+ snprintf(tmp, sizeof(tmp), "%d", deliver->source_addr_ton); \
+ ast_msg_set_var(msg, "dst_npi", tmp); \
+ snprintf(tmp, sizeof(tmp), "%d", deliver->dest_addr_npi); \
+ ast_msg_set_var(msg, "dst_npi", tmp);
FILL_MSG_HEADERS(msg, deliver, tmp);
ast_msg_set_var(msg, "smpp_type", "MO");
@@ -597,6 +608,10 @@
ast_log(LOG_WARNING, "ESME %s already connected\n", smsc->name);
break;
}
+ if (smsc->check_bind && ((smsc->bind_npi != bind.addr_npi) || (smsc->bind_ton != bind.addr_ton))) {
+ ast_log(LOG_WARNING, "ESME %s haven't proper TON/NPI on BIND PDU\n", smsc->name);
+ break;
+ }
strncpy(smsc->connected_host, host, sizeof(smsc->connected_host));
smsc->socket = socket;
smsc->seq = 1;
@@ -721,12 +736,9 @@
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 = 1;
- bind.addr_npi = 1;
- if (!strcmp(smsc->name, "astragsm")) {
- bind.addr_ton = 0;
- bind.addr_npi = 0;
- }
+ bind.addr_ton = smsc->bind_ton;
+ bind.addr_npi = smsc->bind_npi;
+
snprintf((char*)bind.address_range, sizeof(bind.address_range), "%s", "");
ret = smpp34_pack(BIND_TRANSCEIVER, pdu, sizeof(pdu), &pdulen, (void *)&bind);
@@ -1244,6 +1256,10 @@
if (smsc) {
ast_copy_string(smsc->name, name, sizeof(smsc->name) - 1);
ast_copy_string(smsc->system_id, name, sizeof(smsc->system_id) - 1);
+ smsc->bind_ton = 1;
+ smsc->bind_npi = 1;
+ smsc->addr_ton = 0;
+ smsc->addr_npi = 0;
while (v) {
if (!strcasecmp(v->name, "system_id")) {
ast_copy_string(smsc->system_id, v->value, sizeof(smsc->system_id) - 1);
@@ -1262,7 +1278,7 @@
}
} else if (!strcasecmp(v->name, "port")) {
if ((smsc->port = atoi(v->value)) < 0) {
- ast_log(LOG_ERROR, "Invalid smsc port: %s\n", v->value);
+ ast_log(LOG_ERROR, "Invalid smsc port: %s on %s\n", v->value, smsc->name);
smsc = NULL;
break;
}
@@ -1273,6 +1289,32 @@
}
} else if (!strcasecmp(v->name, "context")) {
ast_copy_string(smsc->context, v->value, sizeof(smsc->context));
+ } else if (!strcasecmp(v->name, "bind_npi")) {
+ if ((smsc->bind_npi = atoi(v->value)) < 0) {
+ ast_log(LOG_ERROR, "Invalid bind_npi: %s on %s\n", v->value, smsc->name);
+ smsc = NULL;
+ break;
+ }
+ } else if (!strcasecmp(v->name, "bind_ton")) {
+ if ((smsc->bind_ton = atoi(v->value)) < 0) {
+ ast_log(LOG_ERROR, "Invalid bind_ton: %s on %s\n", v->value, smsc->name);
+ smsc = NULL;
+ break;
+ }
+ } else if (!strcasecmp(v->name, "addr_npi")) {
+ if ((smsc->addr_npi = atoi(v->value)) < -1) {
+ ast_log(LOG_ERROR, "Invalid addr_npi: %s on %s\n", v->value, smsc->name);
+ smsc = NULL;
+ break;
+ }
+ } else if (!strcasecmp(v->name, "addr_ton")) {
+ if ((smsc->bind_ton = atoi(v->value)) < -1) {
+ ast_log(LOG_ERROR, "Invalid addr_ton: %s on %s\n", v->value, smsc->name);
+ smsc = NULL;
+ break;
+ }
+ } else if (!strcasecmp(v->name, "check_bind_npi")) {
+ smsc->check_bind = ast_true(v->value);
}
v = v->next;
}
@@ -1444,14 +1486,20 @@
if(ast_msg_get_var(message, "base64_body")) { \
submit.sm_length = ast_base64decode(submit.short_message, ast_msg_get_var(message, "base64_body"), \
sizeof(submit.short_message) - 1); \
- }
-
-
-
- submit.source_addr_ton = 0;
- submit.source_addr_npi = 0;
- submit.dest_addr_ton = 0;
- submit.dest_addr_npi = 0;
+ } \
+ if(ast_msg_get_var(message, "src_ton")) { \
+ submit.source_addr_ton = atoi(ast_msg_get_var(message, "src_ton")); \
+ } \
+ if(ast_msg_get_var(message, "src_npi")) { \
+ submit.source_addr_npi = atoi(ast_msg_get_var(message, "src_npi")); \
+ } \
+ if(ast_msg_get_var(message, "dst_ton")) { \
+ submit.dest_addr_ton = atoi(ast_msg_get_var(message, "dst_ton")); \
+ } \
+ if(ast_msg_get_var(message, "dst_npi")) { \
+ submit.dest_addr_npi = atoi(ast_msg_get_var(message, "dst_npi")); \
+ }
+
snprintf((char*)submit.source_addr, sizeof(submit.source_addr), "%s", /* (from) ? */ from /*: msg->from */);
snprintf((char*)submit.destination_addr, sizeof(submit.destination_addr), "%s", /* (to) ? */ tonum /* : msg->to */);
@@ -1472,6 +1520,15 @@
}
FILL_SMPP_HEADERS(message, submit);
+
+ if (smsc->addr_ton >= 0) {
+ submit.source_addr_ton = smsc->addr_ton;
+ submit.dest_addr_ton = smsc->addr_ton;
+ }
+ if (smsc->addr_npi >= 0) {
+ submit.source_addr_npi = smsc->addr_npi;
+ submit.dest_addr_npi = smsc->addr_npi;
+ }
if (!submit.sm_length) {
submit.sm_length = strlen((char *)submit.short_message);
@@ -1488,11 +1545,6 @@
deliver.command_status = ESME_ROK;
deliver.sequence_number = sequence_number = smsc->seq++;
- deliver.source_addr_ton = 0;
- deliver.source_addr_npi = 0;
- deliver.dest_addr_ton = 0;
- deliver.dest_addr_npi = 0;
-
snprintf((char*)deliver.source_addr, sizeof(deliver.source_addr), "%s", /* (from) ? */ from /*: msg->from */);
snprintf((char*)deliver.destination_addr, sizeof(deliver.destination_addr), "%s", /* (to) ? */ tonum /* : msg->to */);
@@ -1512,6 +1564,15 @@
}
FILL_SMPP_HEADERS(message, deliver);
+
+ if (smsc->addr_ton >= 0) {
+ deliver.source_addr_ton = smsc->addr_ton;
+ deliver.dest_addr_ton = smsc->addr_ton;
+ }
+ if (smsc->addr_npi >= 0) {
+ deliver.source_addr_npi = smsc->addr_npi;
+ deliver.dest_addr_npi = smsc->addr_npi;
+ }
if (!deliver.sm_length) {
deliver.sm_length = strlen((char *)deliver.short_message);
More information about the svn-commits
mailing list