From 49b8ffd2d8b235793f32f0c65f72d4bfdbd664ad Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Fri, 5 Nov 2010 15:11:16 +0300 Subject: [PATCH] Make "from" address for bounce messages configurable. --- public-trunk/smqueue/smqueue.config.example | 7 +++++-- public-trunk/smqueue/smqueue.cpp | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/public-trunk/smqueue/smqueue.config.example b/public-trunk/smqueue/smqueue.config.example index 618619f..44f0bb3 100644 --- a/public-trunk/smqueue/smqueue.config.example +++ b/public-trunk/smqueue/smqueue.config.example @@ -52,8 +52,11 @@ SMS.FakeSrcSMSC 0000 # return SMS messages -BounceMessage.IMSILookupFailed Cannot determine return address; bouncing message. Text your phone number to 101 to register and try again. -BounceMessage.NotRegistered Phone not registered here. +Bounce.Message.IMSILookupFailed Cannot determine return address; bouncing message. Text your phone number to 101 to register and try again. +Bounce.Message.NotRegistered Phone not registered here. + +# Bounce from address +Bounce.Code 411 diff --git a/public-trunk/smqueue/smqueue.cpp b/public-trunk/smqueue/smqueue.cpp index 7c2ab35..82f0c7f 100644 --- a/public-trunk/smqueue/smqueue.cpp +++ b/public-trunk/smqueue/smqueue.cpp @@ -1173,19 +1173,19 @@ SMq::bounce_message(short_msg_pending *sent_msg, const char *errstr) else errmsg << "can't send: " << thetext; - // Don't bounce a message from 411, makes endless loops. + // Don't bounce a message from us - it makes endless loops. status = 1; - if (0 != strcmp("411", sent_msg->parsed->from->url->username)) { + if (0 != strcmp(gConfig.getStr("Bounce.Code"), sent_msg->parsed->from->url->username)) + { // But do bounce anything else. - char *bounceto = sent_msg->parsed->from->url->username; + char *bounceto = sent_msg->parsed->from->url->username; bool bounce_to_imsi = 0 == strncmp("IMSI", bounceto, 4) - || 0 == strncmp("imsi", bounceto, 4); - status = originate_sm("411", // from "411"? FIXME? + || 0 == strncmp("imsi", bounceto, 4); + status = originate_sm(gConfig.getStr("Bounce.Code"), // Read from a config bounceto, // to his phonenum or IMSI errmsg.str().c_str(), // error msg - bounce_to_imsi? - REQUEST_DESTINATION_SIPURL: // dest is IMSI - REQUEST_DESTINATION_IMSI); // dest is phonenum + bounce_to_imsi? REQUEST_DESTINATION_SIPURL: // dest is IMSI + REQUEST_DESTINATION_IMSI); // dest is phonenum } if (status == 0) { return DELETE_ME_STATE; @@ -1513,7 +1513,7 @@ SMq::lookup_from_address (short_msg_pending *qmsg) << "> to phonenum failed."; LOG(DEBUG) << qmsg->text; return bounce_message (qmsg, - gConfig.getStr("BounceMessage.IMSILookupFailed") + gConfig.getStr("Bounce.Message.IMSILookupFailed") ); // return NO_STATE; // Put it into limbo for debug. } @@ -1592,7 +1592,7 @@ SMq::lookup_uri_imsi (short_msg_pending *qmsg) || !my_hlr.useGateway(username)) { // There's no global relay -- or the HLR says not to // use the global relay for it -- so send a bounce. - return bounce_message (qmsg, gConfig.getStr("BounceMessage.NotRegistered")); + return bounce_message (qmsg, gConfig.getStr("Bounce.Message.NotRegistered")); } else { // Send the message to our global relay. // We leave the username as a phone number, and