Hi,

attached patch adds ack/nack support in communication between bearerbox and 
smsbox. This patch implement only bearerbox part , because we don't use 
smsbox... With this patch smsbox will allways receive "really" status of sms 
(e.g. buffered/success/failed) so smsbox can forward received status to the 
user.

Comments and votes are welcom...

-- 
Best Regards / Mit besten Gr��en aus K�ln

Dipl.-Ing.
Alexander Malysh
___________________________________

Centrium GmbH
Ehrenstrasse 2
50672 K�ln

Fon: +49 (0221) 277 49 240
Fax: +49 (0221) 277 49 109

email: [EMAIL PROTECTED]
web: http://www.centrium.de
msn: [EMAIL PROTECTED]
Index: gw/bb_boxc.c
===================================================================
RCS file: /home/cvs/gateway/gw/bb_boxc.c,v
retrieving revision 1.63
diff -a -u -r1.63 bb_boxc.c
--- gw/bb_boxc.c	4 Mar 2003 14:43:51 -0000	1.63
+++ gw/bb_boxc.c	9 Mar 2003 19:24:22 -0000
@@ -122,6 +122,55 @@
 }
 
 
+/*
+ * Try deliver sms to internal or smscconn queue
+ * and generate ack/nack for smsbox.
+ */
+static void deliver_sms_to_queue(Msg *msg, Boxc *conn)
+{
+    Msg *mack, *mack_store;
+    int rc;
+
+    /* 
+     * save modifies ID and time , so if the smsbox uses it, save
+     * it FIRST for the reply message!!! 
+     */
+    mack = msg_create(ack);
+    gw_assert(mack != NULL);
+    mack->ack.id = msg->sms.id;
+    mack->ack.time = msg->sms.time;
+    store_save(msg);
+    rc = smsc2_rout(msg);
+    switch(rc) {
+        case 1:
+           mack->ack.nack = ack_success;
+           break;
+        case 0:
+           mack->ack.nack = ack_buffered;
+           break;
+        case -1:
+           warning(0, "Message rejected by bearerbox, no router!");
+           /* 
+            * first create nack for store-file, in order to delete
+            * message from store-file.
+            */
+            mack_store = msg_create(ack);
+            gw_assert(mack_store != NULL);
+            mack_store->ack.id = msg->sms.id;
+            mack_store->ack.time = msg->sms.time;
+            mack_store->ack.nack = ack_failed;
+            store_save(mack_store);
+            msg_destroy(mack_store);
+            /* now set nack for smsbox */
+            mack->ack.nack = ack_failed;
+            /* destroy original message */
+            msg_destroy(msg);
+            break;
+    }
+    /* put ack into incoming queue */
+    list_produce(conn->incoming, mack);
+}
+
 static void boxc_receiver(void *arg)
 {
     Boxc *conn = arg;
@@ -141,25 +190,7 @@
 
         if (msg_type(msg) == sms && conn->is_wap == 0) {
             debug("bb.boxc", 0, "boxc_receiver: sms received");
-
-            /* 
-             * XXX save modifies ID, so if the smsbox uses it, save
-             * it FIRST for the reply message!!! 
-             */
-            store_save(msg);
-            if (smsc2_rout(msg)== -1) {
-                warning(0, "Message rejected by bearerbox, no router!");
-                /* send NACK */
-                bb_smscconn_send_failed(NULL, msg, SMSCCONN_FAILED_DISCARDED);
-            }
-            if (msg->sms.sms_type == mt_push) {
-                /* 
-                 * XXX generate ack-message and send it - in fact, this
-                 * should include information did it succeed, wa sit queued
-                 * or rejected... 
-                 */
-            }
-
+            deliver_sms_to_queue(msg, conn);
         } else if (msg_type(msg) == wdp_datagram  && conn->is_wap) {
             debug("bb.boxc", 0, "boxc_receiver: got wdp from wapbox");
             
@@ -168,6 +199,7 @@
         } else if (msg_type(msg) == sms  && conn->is_wap) {
             debug("bb.boxc", 0, "boxc_receiver: got sms from wapbox");
 
+            /* XXX should we call derive_sms_to_queue here too ??? */
             store_save(msg);
             if (smsc2_rout(msg)== -1) {
                 warning(0, "Message rejected by bearerbox, no router!");
Index: gw/bb_smscconn.c
===================================================================
RCS file: /home/cvs/gateway/gw/bb_smscconn.c,v
retrieving revision 1.56
diff -a -u -r1.56 bb_smscconn.c
--- gw/bb_smscconn.c	3 Dec 2002 00:24:17 -0000	1.56
+++ gw/bb_smscconn.c	9 Mar 2003 19:24:23 -0000
@@ -130,7 +130,7 @@
     /* write ACK to store file */
 
     mack = msg_create(ack);
-    mack->ack.nack = 0;
+    mack->ack.nack = ack_success;
     mack->ack.time = sms->sms.time;
     mack->ack.id = sms->sms.id;
     
@@ -159,7 +159,7 @@
 	/* write NACK to store file */
 
 	mnack = msg_create(ack);
-	mnack->ack.nack = 1;
+	mnack->ack.nack = ack_failed;
 	mnack->ack.time = sms->sms.time;
 	mnack->ack.id = sms->sms.id;
 
Index: gw/msg.h
===================================================================
RCS file: /home/cvs/gateway/gw/msg.h,v
retrieving revision 1.13
diff -a -u -r1.13 msg.h
--- gw/msg.h	14 Nov 2002 02:29:25 -0000	1.13
+++ gw/msg.h	9 Mar 2003 19:24:23 -0000
@@ -47,6 +47,14 @@
     cmd_identify = 3
 };
 
+/* ack message status */
+enum {
+    ack_success = 0,
+    ack_failed = 1, /* do not try again (e.g. no route) */
+    ack_failed_tmp = 2, /* temporary failed , try again (e.g. queue full)*/
+    ack_buffered = 3
+};
+
 /*
  * Create a new, empty Msg object. Panics if fails.
  */
Index: gw/smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.218
diff -a -u -r1.218 smsbox.c
--- gw/smsbox.c	4 Mar 2003 15:16:08 -0000	1.218
+++ gw/smsbox.c	9 Mar 2003 19:24:29 -0000
@@ -1485,7 +1485,7 @@
 	/* create reply message to be sent afterwards */
 
 	reply_msg = msg_create(ack);
-	reply_msg->ack.nack = 0;
+	reply_msg->ack.nack = ack_success;
 	reply_msg->ack.time = msg->sms.time;
 	reply_msg->ack.id = msg->sms.id;
     

Attachment: smime.p7s
Description: signature

Reply via email to