Make LCR work with the current openbsc lcr_rtp branch. (soon merged with master branch)
authorAndreas Eversberg <jolly@eversberg.eu>
Sun, 20 Dec 2009 17:55:03 +0000 (18:55 +0100)
committerAndreas Eversberg <jolly@eversberg.eu>
Sun, 20 Dec 2009 17:55:03 +0000 (18:55 +0100)
Minor fix in ss5.cpp.

gsm.cpp
gsm.h
gsm_audio.c
gsm_conf.c
ss5.cpp

diff --git a/gsm.cpp b/gsm.cpp
index 50a8b1d..b1895f8 100644 (file)
--- a/gsm.cpp
+++ b/gsm.cpp
@@ -185,9 +185,7 @@ int Pgsm::bchannel_open(int index)
 /* receive from bchannel */
 void Pgsm::bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len)
 {
-       int i, j, k;
        unsigned char frame[33];
-       struct decoded_trau_frame tf;
 
        /* encoder init failed */
        if (!p_m_g_encoder)
@@ -205,31 +203,7 @@ void Pgsm::bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len)
 
                        /* encode data */
                        gsm_audio_encode(p_m_g_encoder, p_m_g_rxdata, frame);
-
-                       /* set c-bits and t-bits */
-                       tf.c_bits[0] = 1;
-                       tf.c_bits[1] = 1;
-                       tf.c_bits[2] = 1;
-                       tf.c_bits[3] = 0;
-                       tf.c_bits[4] = 0;
-                       memset(&tf.c_bits[5], 0, 6);
-                       memset(&tf.c_bits[11], 1, 10);
-                       memset(&tf.t_bits[0], 1, 4);
-
-                       /* reassemble d-bits */
-                       i = 0;
-                       j = 0;
-                       k = 0;
-                       while(i < 260) {
-                               tf.d_bits[i] = (frame[j] >> k) & 1;
-                               if (++k == 8) {
-                                       k = 0;
-                                       j++;
-                               }
-                               i++;
-                       }
-
-                       trau_send(&tf);
+                       frame_send(frame);
                }
        }
 }
@@ -253,57 +227,33 @@ void Pgsm::bchannel_send(unsigned int prim, unsigned int id, unsigned char *data
                PERROR("Failed to send to socket index %d\n", index);
 }
 
-void Pgsm::trau_send(void *_tf)
+void Pgsm::frame_send(void *_frame)
 {
-       struct decoded_trau_frame *tf = (struct decoded_trau_frame *)_tf;
-       unsigned char data[sizeof(struct gsm_trau_frame) + sizeof(struct decoded_trau_frame)];
-       struct gsm_trau_frame *frame = (struct gsm_trau_frame *)data;
+       unsigned char buffer[sizeof(struct gsm_data_frame) + 33];
+       struct gsm_data_frame *frame = (struct gsm_data_frame *)buffer;
        
-       frame->msg_type = GSM_TRAU_FRAME;
+       frame->msg_type = GSM_TCHF_FRAME;
        frame->callref = p_m_g_callref;
-       memcpy(frame->data, tf, sizeof(struct decoded_trau_frame));
+       memcpy(frame->data, _frame, 33);
        mncc_send((struct gsm_network *)gsm->network, frame->msg_type, frame);
 }
 
 
-void Pgsm::trau_receive(void *_frame)
+void Pgsm::frame_receive(void *_frame)
 {
-       struct gsm_trau_frame *frm = (struct gsm_trau_frame *)_frame;
-       struct decoded_trau_frame *tf = (struct decoded_trau_frame *)frm->data;
-//struct decoded_trau_frame *tf = (struct decoded_trau_frame *)_frame;
-       unsigned char frame[33];
+       struct gsm_data_frame *frame = (struct gsm_data_frame *)_frame;
        signed short samples[160];
        unsigned char data[160];
-       int i, j, k;
+       int i;
 
        if (!p_m_g_decoder)
                return;
 
-//     printf("got trau %d %d %d %d %d\n", tf->c_bits[0], tf->c_bits[1], tf->c_bits[2], tf->c_bits[3], tf->c_bits[4]);
-       if (tf->c_bits[0]!=0 || tf->c_bits[1]!=0 || tf->c_bits[2]!=0 || tf->c_bits[3]!=1 || tf->c_bits[4]!=0)
-               PERROR("illegal trau (C1-C5) %d %d %d %d %d\n", tf->c_bits[0], tf->c_bits[1], tf->c_bits[2], tf->c_bits[3], tf->c_bits[4]);
-
-       /* set GSM_MAGIC */
-       memset(&frame, 0, sizeof(frame));
-//     frame[0] = 0xd << 4;
-
-       /* reassemble bits */
-       i = 0;
-       j = 0;
-       k = 0;
-       while(i < 260) {
-               if (tf->d_bits[i] > 1)
-                       PERROR("fix!\n");
-               frame[j] |= (tf->d_bits[i] << k);
-               if (++k == 8) {
-                       k = 0;
-                       j++;
-               }
-               i++;
-       }
+       if ((frame->data[0]>>4) != 0xd)
+               PERROR("received GSM frame with wrong magig 0x%x\n", frame->data[0]>>4);
        
        /* decode */
-       gsm_audio_decode(p_m_g_decoder, frame, samples);
+       gsm_audio_decode(p_m_g_decoder, frame->data, samples);
        for (i = 0; i < 160; i++) {
                data[i] = audio_s16_to_law[samples[i] & 0xffff];
        }
@@ -906,9 +856,9 @@ static int message_bsc(struct gsm_network *net, int msg_type, void *arg)
                port = port->next;
        }
 
-       if (msg_type == GSM_TRAU_FRAME) {
+       if (msg_type == GSM_TCHF_FRAME) {
                if (port)
-                       pgsm->trau_receive((struct gsm_trau_frame *)arg);
+                       pgsm->frame_receive((struct gsm_trau_frame *)arg);
                return 0;
        }
 
@@ -1677,13 +1627,8 @@ int gsm_init(void)
                e1_set_pcap_fd(pcapfd);
        }
 
-       /* set reject cause */
-       if (gsm->conf.reject_cause)
-               gsm0408_set_reject_cause(gsm->conf.reject_cause);
-
        /* use RTP proxy for audio streaming */
-       if (gsm->conf.rtp_proxy)
-               ipacc_rtp_direct = 0;
+       ipacc_rtp_direct = 0;
 
        /* init database */
        if (gsm->conf.hlr[0] == '/')
@@ -1713,6 +1658,10 @@ int gsm_init(void)
        }
        gsm->network = bsc_gsmnet;
 
+       /* set reject cause */
+       if (gsm->conf.reject_cause)
+               gsm0408_set_reject_cause(gsm->conf.reject_cause);
+
        /* open gsm loop interface */
        if (gsm_sock_open(gsm->conf.interface_bsc)) {
                return gsm_exit(-1);
diff --git a/gsm.h b/gsm.h
index 1fbcee7..15477ef 100644 (file)
--- a/gsm.h
+++ b/gsm.h
@@ -15,7 +15,6 @@ struct gsm_conf {
        int noemergshut;                /* don't shut down on emergency */
        char pcapfile[128];             /* open capture file for BS11 links */
        int reject_cause;               /* reject cause for unsubcribed IMSIs */
-       int rtp_proxy;                  /* enable RTP proxy */
 };
 
 struct lcr_gsm {
@@ -50,8 +49,8 @@ class Pgsm : public PmISDN
        void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
        void bchannel_send(unsigned int prim, unsigned int id, unsigned char *data, int len);
 
-       void trau_send(void *_tf);
-       void trau_receive(void *_frame);
+       void frame_send(void *_frame);
+       void frame_receive(void *_frame);
 
        int hunt_bchannel(void);
        void setup_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc);
index 52b9c05..972ab39 100644 (file)
@@ -21,7 +21,7 @@ void *gsm_audio_create(void)
 
        handle = gsm_create();
        if (handle)
-               gsm_option(handle, GSM_OPT_WAV49, &value);
+               gsm_option(handle, 0/*GSM_OPT_WAV49*/, &value);
 
        return handle;
 }
@@ -35,20 +35,20 @@ void gsm_audio_destroy(void *arg)
 /* decode frame into samples, return error */
 int gsm_audio_decode(void *arg, unsigned char *frame, signed short *samples)
 {
-       int value = 0;
+//     int value = 0;
 
-       gsm_option((gsm)arg, GSM_OPT_FRAME_INDEX, &value);
+//     gsm_option((gsm)arg, GSM_OPT_FRAME_INDEX, &value);
        return gsm_decode((gsm)arg, (gsm_byte *)frame, (gsm_signal *)samples);
 }
 
 /* encode samples into frame */
 void gsm_audio_encode(void *arg, signed short *samples, unsigned char *frame)
 {
-       int value = 0;
+//     int value = 0;
        
-       gsm_option((gsm)arg, GSM_OPT_FRAME_INDEX, &value);
+//     gsm_option((gsm)arg, GSM_OPT_FRAME_INDEX, &value);
        gsm_encode((gsm)arg, (gsm_signal *)samples, (gsm_byte *)frame);
 }
 
-}
+} /* extern "C" */
 
index 9957b86..08d49dd 100644 (file)
@@ -160,9 +160,6 @@ int gsm_conf(struct gsm_conf *gsm_conf)
                if (!strcmp(option,"no-mergency-shutdown")) {
                        gsm_conf->noemergshut = 1;
                } else
-               if (!strcmp(option,"rtp-proxy")) {
-                       gsm_conf->rtp_proxy = 1;
-               } else
                if (!strcmp(option,"pcapfile")) {
                        if (params[0][0]==0) {
                                SPRINT(gsm_conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
diff --git a/ss5.cpp b/ss5.cpp
index 40eb540..0d453e4 100644 (file)
--- a/ss5.cpp
+++ b/ss5.cpp
@@ -227,13 +227,13 @@ static void ss5_trace_header(struct mISDNport *mISDNport, class PmISDN *port, un
 
 
 /*
- * changes release tone int busy signal
- * this makes the line more authentic
+ * changes release tone into silence
+ * this makes the line sound more authentic
  */
 void Pss5::set_tone(const char *dir, const char *name)
 {
        if (name && !strcmp(name, "cause_10"))
-               name = "busy";
+               name = NULL;
 
        PmISDN::set_tone(dir, name);
 }