X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=gsm.cpp;h=e747ff01a36e34786289c50517b3295a0a5929c8;hp=50a8b1d8bd365902cee9af23b1d73af0330d99bf;hb=473d6569efcad130f9a5044b182b75a1c07a1eee;hpb=2188efe2cc9dfb473bf41540960382d7c43b892e diff --git a/gsm.cpp b/gsm.cpp index 50a8b1d..e747ff0 100644 --- a/gsm.cpp +++ b/gsm.cpp @@ -32,6 +32,7 @@ extern int bsc_shutdown_net(struct gsm_network *net); void talloc_ctx_init(void); void on_dso_load_token(void); void on_dso_load_rrlp(void); +static struct debug_target *stderr_target; #include "gsm_audio.h" @@ -185,9 +186,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 +204,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 +228,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]; } @@ -809,8 +760,15 @@ void Pgsm::rel_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc /* NOTIFY INDICATION */ void Pgsm::notify_ind(unsigned int msg_type, unsigned int callref, struct gsm_mncc *mncc) { + struct lcr_msg *message; + gsm_trace_header(p_m_mISDNport, this, msg_type, DIRECTION_IN); + add_trace("notify", NULL, "%d", mncc->notify); end_trace(); + + message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_NOTIFY); + message->param.notifyinfo.notify = mncc->notify; + message_put(message); } @@ -906,9 +864,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; } @@ -1589,7 +1547,7 @@ static int gsm_sock_open(char *portname) PERROR_RUNTIME("GSM port %d does not support TE PRI or TE BRI.\n", gsm->gsm_port); } /* open socket */ - if ((gsm->gsm_sock = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_TE_S0)) < 0) { + if ((gsm->gsm_sock = socket(PF_ISDN, SOCK_DGRAM, (pri)?ISDN_P_TE_E1:ISDN_P_TE_S0)) < 0) { PERROR_RUNTIME("GSM port %d failed to open socket.\n", gsm->gsm_port); gsm_sock_close(); return gsm->gsm_sock; @@ -1660,8 +1618,9 @@ int gsm_init(void) } /* set debug */ + stderr_target = debug_target_create_stderr(); if (gsm->conf.debug[0]) - debug_parse_category_mask(gsm->conf.debug); + debug_parse_category_mask(stderr_target, gsm->conf.debug); /* open pcap file */ if (gsm->conf.pcapfile[0]) { @@ -1677,13 +1636,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] == '/')