On Wed, Feb 05, 2014 at 09:27:06AM +0100, Holger Hans Peter Freyther wrote:

> anyones wants to come up with a fix?

No one? Fairwaves? Somebody at least want to try the below code and
see if SMS can still be sent?


diff --git a/openbsc/include/openbsc/gsm_data.h 
b/openbsc/include/openbsc/gsm_data.h
index 41fe328..404dfe4 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -106,6 +106,8 @@ struct gsm_subscriber_connection {
 
        /* LU expiration handling */
        uint8_t expire_timer_stopped;
+       /* SMS helpers for libmsc */
+       uint8_t next_rp_ref;
 
        /*
         * Operations that have a state and might be pending
diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c
index 97a67ee..433951a 100644
--- a/openbsc/src/libmsc/gsm_04_11.c
+++ b/openbsc/src/libmsc/gsm_04_11.c
@@ -64,6 +64,18 @@ extern int smpp_try_deliver(struct gsm_sms *sms,
 void *tall_gsms_ctx;
 static uint32_t new_callref = 0x40000001;
 
+uint8_t sms_next_rp_msg_ref(struct gsm_subscriber_connection *conn)
+{
+       const uint8_t rp_msg_ref = conn->next_rp_ref;
+       /*
+        * This should wrap as the valid range is 0 to 255. We only
+        * transfer one SMS at a time so we don't need to check if
+        * the id has been already assigned.
+        */
+       conn->next_rp_ref += 1;
+
+       return rp_msg_ref;
+}
 
 struct gsm_sms *sms_alloc(void)
 {
@@ -450,7 +462,7 @@ static int gsm411_rp_sendmsg(struct gsm411_smr_inst *inst, 
struct msgb *msg,
        rp = (struct gsm411_rp_hdr *)msgb_push(msg, sizeof(*rp));
        rp->len = len + 2;
        rp->msg_type = rp_msg_type;
-       rp->msg_ref = rp_msg_ref; /* FIXME: Choose randomly */
+       rp->msg_ref = rp_msg_ref;
 
        return gsm411_smr_send(inst, rl_msg_type, msg);
 }
@@ -836,7 +848,7 @@ int gsm411_send_sms(struct gsm_subscriber_connection *conn, 
struct gsm_sms *sms)
        struct msgb *msg = gsm411_msgb_alloc();
        struct gsm_trans *trans;
        uint8_t *data, *rp_ud_len;
-       uint8_t msg_ref = 42;
+       uint8_t msg_ref = sms_next_rp_msg_ref(conn);
        int transaction_id;
        int rc;
 

Reply via email to