Re: [PATCH] smsc-dlr-alias on SMSC connections

Alejandro Guerrieri <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Ok, here it is.

As usual, you were right: this approach is neater :)

I've also modified the status page to display the admin-id enclosed in  
brackets next to the connection id.

Regards
--
Alejandro Guerrieri
[email protected]


On 05/05/2009, at 12:43, Alexander Malysh wrote:

> Am 05.05.2009 um 11:20 schrieb Alejandro Guerrieri:
>
>> Ok, got it.
>>
>> So what you propose is to turn the parameter into a special "id" to  
>> be given to each bind, so they can be individually targeted on  
>> admin commands even when they have the same smsc-id.
>
> yes... And it can be easily done in generic code for SMSCconn :)
>
>>
>> Regards,
>> --
>> Alejandro Guerrieri
>> [email protected]
>>
>>
>>
>> On 05/05/2009, at 9:35, Alexander Malysh wrote:
>>
>>> Hi Alex,
>>>
>>> not really -1 but I think smsc-dlr-alias is the wrong option. It  
>>> should be called smsc-admin-id or the like
>>> because it really only admin issue...
>>>
>>> what do you think about it?
>>>
>>> Thanks,
>>> Alex
>>>
>>> Am 04.05.2009 um 23:53 schrieb Alejandro Guerrieri:
>>>
>>>> Shall I interpret that as a -1? ;)
>>>>
>>>> --
>>>> Alejandro Guerrieri
>>>> [email protected]
>>>>
>>>>
>>>>
>>>> On 04/05/2009, at 23:40, Alexander Malysh wrote:
>>>>
>>>>>
>>>>> Am 04.05.2009 um 23:23 schrieb Alejandro Guerrieri:
>>>>>
>>>>>> Well, we tried that approach in the first place. While it might  
>>>>>> be appropriate on many cases, we'd lose control over the  
>>>>>> individual links that way.
>>>>>>
>>>>>> For our particular case, that's a showstopper, and it might be  
>>>>>> for others as well:
>>>>>>
>>>>>> * You wouldn't be able to manually shutdown one of the binds  
>>>>>> with shutdown-smsc, since all of them would share the same smsc- 
>>>>>> id. I've confirmed this with 2 fakesmsc instances: stop-smsc  
>>>>>> kills both instances. I can imagine this would be specially  
>>>>>> painful with AT modems.
>>>>>
>>>>> this is the only issue that count...
>>>>>
>>>>>> * Your carrier may require you to route all your outbound  
>>>>>> traffic to a particular bind according to rules that exceed  
>>>>>> kannel's routing capabilities (time slots and other "non- 
>>>>>> standard" requirements some carriers _love_ to do ;)).
>>>>>
>>>>> This can be handled with my config example
>>>>>
>>>>>> * mt-routing rules over particular binds wouldn't be possible  
>>>>>> either.
>>>>>
>>>>> ditto...
>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> --
>>>>>> Alejandro Guerrieri
>>>>>> [email protected]
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 04/05/2009, at 22:47, Alexander Malysh wrote:
>>>>>>
>>>>>>> Hi Alex,
>>>>>>>
>>>>>>> why do you need this?
>>>>>>>
>>>>>>> here is needed config for you:
>>>>>>>
>>>>>>> # first connection
>>>>>>> group = smsc
>>>>>>> smsc-id = mylink
>>>>>>> allowed-smsc = mylink;mylink1
>>>>>>>
>>>>>>> # second connection
>>>>>>> group = smsc
>>>>>>> smsc-id = mylink
>>>>>>> allowed-smsc = mylink;mylink2
>>>>>>>
>>>>>>> So you can send with &smsc=mylink and bearerbox loadbalance  
>>>>>>> between two links,
>>>>>>> with &smsc=mylink[1|2] you can choose between two links.
>>>>>>> In both cases DLRs added to DB with mylink as SMSC.
>>>>>>>
>>>>>>> Why do you need dlr alias?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Alex
>>>>>>>
>>>>>>> Am 04.05.2009 um 21:34 schrieb Alejandro Guerrieri:
>>>>>>>
>>>>>>>> We were facing a problem when dealing with multiple binds to  
>>>>>>>> the same carriers.
>>>>>>>>
>>>>>>>>
>>>>>>>> Some of the carriers we're working with have SMSC's on  
>>>>>>>> twogeographically-distant places. They asked us to connect to  
>>>>>>>> both of them from our also replicated kannel clients.
>>>>>>>>
>>>>>>>> So, we have two identical connections on each of our servers  
>>>>>>>> to both of their smsc's. This guarantees that I could use  
>>>>>>>> "&smsc=mylink" on my send-sms url and kannel will choose one  
>>>>>>>> of the available links to send the messages.
>>>>>>>>
>>>>>>>> The problem is, in this particular scenario, the DLR for that  
>>>>>>>> MT could come back from the _other_ link (which has a  
>>>>>>>> different "id"), so even on the same server it wouldn't be  
>>>>>>>> possible to match the incoming DLR with the records stored on  
>>>>>>>> the DB.
>>>>>>>>
>>>>>>>> To solve this, I've created a patch that adds a new parameter  
>>>>>>>> to SMSC connections: smsc-dlr-alias. This parameter, if not  
>>>>>>>> defined, gets loaded with the value on smsc-id. If defined,  
>>>>>>>> that value is used when inserting to/reading from the dlr  
>>>>>>>> database, making it possible to find the dlr's despite being  
>>>>>>>> created on another bind.
>>>>>>>>
>>>>>>>> Please see this post for more info and the patch:
>>>>>>>>
>>>>>>>> http://www.blogalex.com/archives/121
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> --
>>>>>>>> Alejandro Guerrieri
>>>>>>>> [email protected]
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
kannel-conn-admin-id.patch (application/octet-stream, 4.8 KB)
Index: gwlib/cfg.def
===================================================================
--- gwlib/cfg.def	(revision 33)
+++ gwlib/cfg.def	(working copy)
@@ -295,6 +295,7 @@
 MULTI_GROUP(smsc,
     OCTSTR(smsc)
     OCTSTR(smsc-id)
+    OCTSTR(smsc-admin-id)
     OCTSTR(denied-smsc-id)
     OCTSTR(allowed-smsc-id)
     OCTSTR(preferred-smsc-id)
Index: gw/bb_smscconn.c
===================================================================
--- gw/bb_smscconn.c	(revision 33)
+++ gw/bb_smscconn.c	(working copy)
@@ -690,7 +690,7 @@
 
     for (i = start; i < gwlist_len(smsc_list); i++) {
         conn = gwlist_get(smsc_list, i);
-        if (conn != NULL && octstr_compare(conn->id, id) == 0) {
+        if (conn != NULL && octstr_compare(conn->admin_id, id) == 0) {
             break;
         }
     }
@@ -914,6 +914,7 @@
     SMSCConn *conn;
     StatusInfo info;
     const Octstr *conn_id = NULL;
+    const Octstr *conn_admin_id = NULL;
     const Octstr *conn_name = NULL;
 
     if ((lb = bb_status_linebreak(status_type)) == NULL)
@@ -949,22 +950,29 @@
 
         conn_id = conn ? smscconn_id(conn) : octstr_imm("unknown");
         conn_id = conn_id ? conn_id : octstr_imm("unknown");
+        conn_admin_id = conn ? smscconn_admin_id(conn) : octstr_imm("unknown");
+        conn_admin_id = conn_admin_id ? conn_admin_id : octstr_imm("unknown");
         conn_name = conn ? smscconn_name(conn) : octstr_imm("unknown");
 
         if (status_type == BBSTATUS_HTML) {
             octstr_append_cstr(tmp, "&nbsp;&nbsp;&nbsp;&nbsp;<b>");
             octstr_append(tmp, conn_id);
-            octstr_append_cstr(tmp, "</b>&nbsp;&nbsp;&nbsp;&nbsp;");
+            octstr_append_cstr(tmp, "</b>[");
+            octstr_append(tmp, conn_admin_id);
+            octstr_append_cstr(tmp, "]&nbsp;&nbsp;&nbsp;&nbsp;");
         } else if (status_type == BBSTATUS_TEXT) {
             octstr_append_cstr(tmp, "    ");
             octstr_append(tmp, conn_id);
-            octstr_append_cstr(tmp, "    ");
+            octstr_append_cstr(tmp, "[");
+            octstr_append(tmp, conn_admin_id);
+            octstr_append_cstr(tmp, "]    ");
         } 
         if (status_type == BBSTATUS_XML) {
             octstr_append_cstr(tmp, "<smsc>\n\t\t<name>");
             octstr_append(tmp, conn_name);
-            octstr_append_cstr(tmp, "</name>\n\t\t");
-            octstr_append_cstr(tmp, "<id>");
+            octstr_append_cstr(tmp, "</name>\n\t\t<admin-id>");
+            octstr_append(tmp, conn_admin_id);
+            octstr_append_cstr(tmp, "</admin-id>\n\t\t<id>");
             octstr_append(tmp, conn_id);
             octstr_append_cstr(tmp, "</id>\n\t\t");
         } else
Index: gw/smscconn.c
===================================================================
--- gw/smscconn.c	(revision 32)
+++ gw/smscconn.c	(working copy)
@@ -222,6 +222,10 @@
         octstr_destroy(tmp);
         info(0, "Set throughput to %.3f for smsc id <%s>", conn->throughput, octstr_get_cstr(conn->id));
     }
+    /* Sets the admin_id. Equals to connection id if empty */
+    GET_OPTIONAL_VAL(conn->admin_id, "smsc-admin-id");
+    if (conn->admin_id == NULL)
+        conn->admin_id = octstr_duplicate(conn->id);
 
     /* configure the internal rerouting rules for this smsc id */
     init_reroute(conn, grp);
@@ -335,6 +339,7 @@
 
     octstr_destroy(conn->name);
     octstr_destroy(conn->id);
+    octstr_destroy(conn->admin_id);
     gwlist_destroy(conn->allowed_smsc_id, octstr_destroy_item);
     gwlist_destroy(conn->denied_smsc_id, octstr_destroy_item);
     gwlist_destroy(conn->preferred_smsc_id, octstr_destroy_item);
@@ -412,6 +417,13 @@
 }
 
 
+const Octstr *smscconn_admin_id(SMSCConn *conn)
+{
+    gw_assert(conn != NULL);
+    return conn->admin_id;
+}
+
+
 int smscconn_usable(SMSCConn *conn, Msg *msg)
 {
     gw_assert(conn != NULL);
Index: gw/smscconn_p.h
===================================================================
--- gw/smscconn_p.h	(revision 32)
+++ gw/smscconn_p.h	(working copy)
@@ -168,6 +168,7 @@
     Octstr *name;		/* Descriptive name filled from connection info */
     Octstr *id;			/* Abstract name specified in configuration and
 				   used for logging and routing */
+    Octstr *admin_id;
     List *allowed_smsc_id;
     List *denied_smsc_id;
     List *preferred_smsc_id;
Index: gw/smscconn.h
===================================================================
--- gw/smscconn.h	(revision 32)
+++ gw/smscconn.h	(working copy)
@@ -166,6 +166,9 @@
 /* Return ID of the SMSC, as reference - caller may not free it! */
 const Octstr *smscconn_id(SMSCConn *conn);
 
+/* Return Admin ID of the SMSC, as reference - caller may not free it! */
+const Octstr *smscconn_admin_id(SMSCConn *conn);
+
 /* Check if this SMSC Connection is usable as sender for given
  * message. The bearerbox must then select the good SMSC for sending
  * according to load levels and connected/disconnected status, this
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.