[svn-commits] may: branch may/smpp r420984 - /team/may/smpp/branches/10/addons/res_smpp.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Aug 14 07:09:22 CDT 2014
Author: may
Date: Thu Aug 14 07:09:18 2014
New Revision: 420984
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=420984
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)
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=420984&r1=420983&r2=420984
==============================================================================
--- team/may/smpp/branches/10/addons/res_smpp.c (original)
+++ team/may/smpp/branches/10/addons/res_smpp.c Thu Aug 14 07:09:18 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];
@@ -422,7 +425,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");
@@ -596,6 +607,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;
@@ -720,12 +735,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);
@@ -1243,6 +1255,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);
@@ -1261,7 +1277,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;
}
@@ -1272,6 +1288,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;
}
@@ -1443,14 +1485,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 */);
@@ -1471,6 +1519,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);
@@ -1487,11 +1544,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 */);
@@ -1511,6 +1563,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