From 5a45b156d4165fed159a290c46676d1383ffcc80 Mon Sep 17 00:00:00 2001 From: Jonathan Santos Date: Wed, 17 Aug 2011 15:33:57 -0400 Subject: New upstream version 0.9.14 --- src/libtrau/Makefile.am | 2 +- src/libtrau/Makefile.in | 6 ++-- src/libtrau/rtp_proxy.c | 72 ++++++++++++++++++++++----------------------- src/libtrau/subchan_demux.c | 30 +++++++++---------- src/libtrau/trau_frame.c | 28 +++++++++--------- src/libtrau/trau_mux.c | 21 +++++++------ 6 files changed, 80 insertions(+), 79 deletions(-) (limited to 'src/libtrau') diff --git a/src/libtrau/Makefile.am b/src/libtrau/Makefile.am index 01ed251d8..6b70a9acc 100644 --- a/src/libtrau/Makefile.am +++ b/src/libtrau/Makefile.am @@ -1,6 +1,6 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) -AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(COVERAGE_LDFLAGS) +AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS) noinst_LIBRARIES = libtrau.a diff --git a/src/libtrau/Makefile.in b/src/libtrau/Makefile.in index 9da0496be..0aacd1c4b 100644 --- a/src/libtrau/Makefile.in +++ b/src/libtrau/Makefile.in @@ -35,7 +35,7 @@ POST_UNINSTALL = : subdir = src/libtrau DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -111,6 +111,8 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBOSMOCORE_CFLAGS = @LIBOSMOCORE_CFLAGS@ LIBOSMOCORE_LIBS = @LIBOSMOCORE_LIBS@ +LIBOSMOGSM_CFLAGS = @LIBOSMOGSM_CFLAGS@ +LIBOSMOGSM_LIBS = @LIBOSMOGSM_LIBS@ LIBOSMOSCCP_CFLAGS = @LIBOSMOSCCP_CFLAGS@ LIBOSMOSCCP_LIBS = @LIBOSMOSCCP_LIBS@ LIBOSMOVTY_CFLAGS = @LIBOSMOVTY_CFLAGS@ @@ -181,7 +183,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) -AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(COVERAGE_LDFLAGS) +AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS) noinst_LIBRARIES = libtrau.a libtrau_a_SOURCES = rtp_proxy.c subchan_demux.c trau_frame.c trau_mux.c trau_upqueue.c all: all-am diff --git a/src/libtrau/rtp_proxy.c b/src/libtrau/rtp_proxy.c index eefc0e1d6..4c5f12eb5 100644 --- a/src/libtrau/rtp_proxy.c +++ b/src/libtrau/rtp_proxy.c @@ -28,15 +28,15 @@ #include /* clock() */ #include /* uname() */ -#include +#include #include -#include -#include +#include +#include #include #include +#include /* attempt to determine byte order */ -#include #include #include @@ -60,9 +60,9 @@ enum rtp_bfd_priv { /* according to RFC 1889 */ struct rtcp_hdr { - u_int8_t byte0; - u_int8_t type; - u_int16_t length; + uint8_t byte0; + uint8_t type; + uint16_t length; } __attribute__((packed)); #define RTCP_TYPE_SDES 202 @@ -72,40 +72,40 @@ struct rtcp_hdr { /* according to RFC 3550 */ struct rtp_hdr { #if __BYTE_ORDER == __LITTLE_ENDIAN - u_int8_t csrc_count:4, + uint8_t csrc_count:4, extension:1, padding:1, version:2; - u_int8_t payload_type:7, + uint8_t payload_type:7, marker:1; #elif __BYTE_ORDER == __BIG_ENDIAN - u_int8_t version:2, + uint8_t version:2, padding:1, extension:1, csrc_count:4; - u_int8_t marker:1, + uint8_t marker:1, payload_type:7; #endif - u_int16_t sequence; - u_int32_t timestamp; - u_int32_t ssrc; + uint16_t sequence; + uint32_t timestamp; + uint32_t ssrc; } __attribute__((packed)); struct rtp_x_hdr { - u_int16_t by_profile; - u_int16_t length; + uint16_t by_profile; + uint16_t length; } __attribute__((packed)); #define RTP_VERSION 2 /* decode an rtp frame and create a new buffer with payload */ -static int rtp_decode(struct msgb *msg, u_int32_t callref, struct msgb **data) +static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data) { struct msgb *new_msg; struct gsm_data_frame *frame; struct rtp_hdr *rtph = (struct rtp_hdr *)msg->data; struct rtp_x_hdr *rtpxh; - u_int8_t *payload; + uint8_t *payload; int payload_len; int msg_type; int x_len; @@ -286,11 +286,11 @@ int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame) /* iterate over all chunks in one RTCP message, look for CNAME IEs and * replace all of those with 'new_cname' */ static int rtcp_sdes_cname_mangle(struct msgb *msg, struct rtcp_hdr *rh, - u_int16_t *rtcp_len, const char *new_cname) + uint16_t *rtcp_len, const char *new_cname) { - u_int8_t *rtcp_end; - u_int8_t *cur = (u_int8_t *) rh; - u_int8_t tag, len = 0; + uint8_t *rtcp_end; + uint8_t *cur = (uint8_t *) rh; + uint8_t tag, len = 0; rtcp_end = cur + *rtcp_len; /* move cur to end of RTP header */ @@ -343,7 +343,7 @@ static int rtcp_mangle(struct msgb *msg, struct rtp_socket *rs) { struct rtp_sub_socket *rss = &rs->rtcp; struct rtcp_hdr *rtph; - u_int16_t old_len; + uint16_t old_len; int rc; if (!mangle_rtcp_cname) @@ -483,7 +483,7 @@ static int rtp_socket_write(struct rtp_socket *rs, struct rtp_sub_socket *rss) /* callback for the select.c:bfd_* layer */ -static int rtp_bfd_cb(struct bsc_fd *bfd, unsigned int flags) +static int rtp_bfd_cb(struct osmo_fd *bfd, unsigned int flags) { struct rtp_socket *rs = bfd->data; struct rtp_sub_socket *rss; @@ -537,7 +537,7 @@ struct rtp_socket *rtp_socket_create(void) goto out_free; init_rss(&rs->rtp, rs, rc, RTP_PRIV_RTP); - rc = bsc_register_fd(&rs->rtp.bfd); + rc = osmo_fd_register(&rs->rtp.bfd); if (rc < 0) goto out_rtp_socket; @@ -546,7 +546,7 @@ struct rtp_socket *rtp_socket_create(void) goto out_rtp_bfd; init_rss(&rs->rtcp, rs, rc, RTP_PRIV_RTCP); - rc = bsc_register_fd(&rs->rtcp.bfd); + rc = osmo_fd_register(&rs->rtcp.bfd); if (rc < 0) goto out_rtcp_socket; @@ -559,11 +559,11 @@ struct rtp_socket *rtp_socket_create(void) return rs; out_rtcp_bfd: - bsc_unregister_fd(&rs->rtcp.bfd); + osmo_fd_unregister(&rs->rtcp.bfd); out_rtcp_socket: close(rs->rtcp.bfd.fd); out_rtp_bfd: - bsc_unregister_fd(&rs->rtp.bfd); + osmo_fd_unregister(&rs->rtp.bfd); out_rtp_socket: close(rs->rtp.bfd.fd); out_free: @@ -572,8 +572,8 @@ out_free: return NULL; } -static int rtp_sub_socket_bind(struct rtp_sub_socket *rss, u_int32_t ip, - u_int16_t port) +static int rtp_sub_socket_bind(struct rtp_sub_socket *rss, uint32_t ip, + uint16_t port) { int rc; socklen_t alen = sizeof(rss->sin_local); @@ -598,7 +598,7 @@ static int rtp_sub_socket_bind(struct rtp_sub_socket *rss, u_int32_t ip, static unsigned int next_udp_port = RTP_PORT_BASE; /* bind a RTP socket to a local address */ -int rtp_socket_bind(struct rtp_socket *rs, u_int32_t ip) +int rtp_socket_bind(struct rtp_socket *rs, uint32_t ip) { int rc = -EIO; struct in_addr ia; @@ -630,7 +630,7 @@ int rtp_socket_bind(struct rtp_socket *rs, u_int32_t ip) } static int rtp_sub_socket_connect(struct rtp_sub_socket *rss, - u_int32_t ip, u_int16_t port) + uint32_t ip, uint16_t port) { int rc; socklen_t alen = sizeof(rss->sin_local); @@ -649,7 +649,7 @@ static int rtp_sub_socket_connect(struct rtp_sub_socket *rss, } /* 'connect' a RTP socket to a remote peer */ -int rtp_socket_connect(struct rtp_socket *rs, u_int32_t ip, u_int16_t port) +int rtp_socket_connect(struct rtp_socket *rs, uint32_t ip, uint16_t port) { int rc; struct in_addr ia; @@ -682,7 +682,7 @@ int rtp_socket_proxy(struct rtp_socket *this, struct rtp_socket *other) /* bind RTP/RTCP socket to application */ int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net, - u_int32_t callref) + uint32_t callref) { DEBUGP(DMUX, "rtp_socket_proxy(this=%p, callref=%u)\n", this, callref); @@ -714,11 +714,11 @@ int rtp_socket_free(struct rtp_socket *rs) rs->proxy.other_sock) rs->proxy.other_sock->proxy.other_sock = NULL; - bsc_unregister_fd(&rs->rtp.bfd); + osmo_fd_unregister(&rs->rtp.bfd); close(rs->rtp.bfd.fd); free_tx_queue(&rs->rtp); - bsc_unregister_fd(&rs->rtcp.bfd); + osmo_fd_unregister(&rs->rtcp.bfd); close(rs->rtcp.bfd.fd); free_tx_queue(&rs->rtcp); diff --git a/src/libtrau/subchan_demux.c b/src/libtrau/subchan_demux.c index 6bcf279fe..740d2caaf 100644 --- a/src/libtrau/subchan_demux.c +++ b/src/libtrau/subchan_demux.c @@ -27,22 +27,22 @@ #include #include #include -#include +#include #include void *tall_tqe_ctx; -static inline void append_bit(struct demux_subch *sch, u_int8_t bit) +static inline void append_bit(struct demux_subch *sch, uint8_t bit) { sch->out_bitbuf[sch->out_idx++] = bit; } #define SYNC_HDR_BITS 16 -static const u_int8_t nullbytes[SYNC_HDR_BITS]; +static const uint8_t nullbytes[SYNC_HDR_BITS]; /* check if we have just completed the 16 bit zero sync header, * in accordance with GSM TS 08.60 Chapter 4.8.1 */ -static int sync_hdr_complete(struct demux_subch *sch, u_int8_t bit) +static int sync_hdr_complete(struct demux_subch *sch, uint8_t bit) { if (bit == 0) sch->consecutive_zeros++; @@ -83,7 +83,7 @@ int subch_demux_init(struct subch_demux *dmx) /* input some arbitrary (modulo 4) number of bytes of a 64k E1 channel, * split it into the 16k subchannels */ -int subch_demux_in(struct subch_demux *dmx, u_int8_t *data, int len) +int subch_demux_in(struct subch_demux *dmx, uint8_t *data, int len) { int i, c; @@ -92,12 +92,12 @@ int subch_demux_in(struct subch_demux *dmx, u_int8_t *data, int len) return -EINVAL; for (i = 0; i < len; i++) { - u_int8_t inbyte = data[i]; + uint8_t inbyte = data[i]; for (c = 0; c < NR_SUBCH; c++) { struct demux_subch *sch = &dmx->subch[c]; - u_int8_t inbits; - u_int8_t bit; + uint8_t inbits; + uint8_t bit; /* ignore inactive subchannels */ if (!(dmx->chan_activ & (1 << c))) @@ -171,7 +171,7 @@ static int alloc_add_idle_frame(struct subch_mux *mx, int sch_nr) /* return the requested number of bits from the specified subchannel */ static int get_subch_bits(struct subch_mux *mx, int subch, - u_int8_t *bits, int num_requested) + uint8_t *bits, int num_requested) { struct mux_subch *sch = &mx->subch[subch]; int num_bits = 0; @@ -215,9 +215,9 @@ static int get_subch_bits(struct subch_mux *mx, int subch, } /* compact an array of 8 single-bit bytes into one byte of 8 bits */ -static u_int8_t compact_bits(const u_int8_t *bits) +static uint8_t compact_bits(const uint8_t *bits) { - u_int8_t ret = 0; + uint8_t ret = 0; int i; for (i = 0; i < 8; i++) @@ -227,9 +227,9 @@ static u_int8_t compact_bits(const u_int8_t *bits) } /* obtain a single output byte from the subchannel muxer */ -static int mux_output_byte(struct subch_mux *mx, u_int8_t *byte) +static int mux_output_byte(struct subch_mux *mx, uint8_t *byte) { - u_int8_t bits[8]; + uint8_t bits[8]; int rc; /* combine two bits of every subchan */ @@ -244,7 +244,7 @@ static int mux_output_byte(struct subch_mux *mx, u_int8_t *byte) } /* Request the output of some muxed bytes from the subchan muxer */ -int subchan_mux_out(struct subch_mux *mx, u_int8_t *data, int len) +int subchan_mux_out(struct subch_mux *mx, uint8_t *data, int len) { int i; @@ -285,7 +285,7 @@ static void tx_queue_evict(struct mux_subch *sch, int num_evict) } /* enqueue some data into the tx_queue of a given subchannel */ -int subchan_mux_enqueue(struct subch_mux *mx, int s_nr, const u_int8_t *data, +int subchan_mux_enqueue(struct subch_mux *mx, int s_nr, const uint8_t *data, int len) { struct mux_subch *sch = &mx->subch[s_nr]; diff --git a/src/libtrau/trau_frame.c b/src/libtrau/trau_frame.c index d4d6447cc..15cbe4ff9 100644 --- a/src/libtrau/trau_frame.c +++ b/src/libtrau/trau_frame.c @@ -28,10 +28,10 @@ #include #include -static u_int32_t get_bits(const u_int8_t *bitbuf, int offset, int num) +static uint32_t get_bits(const uint8_t *bitbuf, int offset, int num) { int i; - u_int32_t ret = 0; + uint32_t ret = 0; for (i = offset; i < offset + num; i++) { ret = ret << 1; @@ -42,7 +42,7 @@ static u_int32_t get_bits(const u_int8_t *bitbuf, int offset, int num) } /* Decode according to 3.1.1 */ -static void decode_fr(struct decoded_trau_frame *fr, const u_int8_t *trau_bits) +static void decode_fr(struct decoded_trau_frame *fr, const uint8_t *trau_bits) { int i; int d_idx = 0; @@ -63,7 +63,7 @@ static void decode_fr(struct decoded_trau_frame *fr, const u_int8_t *trau_bits) } /* Decode according to 3.1.2 */ -static void decode_amr(struct decoded_trau_frame *fr, const u_int8_t *trau_bits) +static void decode_amr(struct decoded_trau_frame *fr, const uint8_t *trau_bits) { int i; int d_idx = 0; @@ -85,9 +85,9 @@ static void decode_amr(struct decoded_trau_frame *fr, const u_int8_t *trau_bits) memcpy(fr->d_bits + d_idx, trau_bits + 305, 11); } -int decode_trau_frame(struct decoded_trau_frame *fr, const u_int8_t *trau_bits) +int decode_trau_frame(struct decoded_trau_frame *fr, const uint8_t *trau_bits) { - u_int8_t cbits5 = get_bits(trau_bits, 17, 5); + uint8_t cbits5 = get_bits(trau_bits, 17, 5); switch (cbits5) { case TRAU_FT_FR_UP: @@ -120,13 +120,13 @@ int decode_trau_frame(struct decoded_trau_frame *fr, const u_int8_t *trau_bits) return 0; } -const u_int8_t ft_fr_down_bits[] = { 1, 1, 1, 0, 0 }; -const u_int8_t ft_idle_down_bits[] = { 0, 1, 1, 1, 0 }; +const uint8_t ft_fr_down_bits[] = { 1, 1, 1, 0, 0 }; +const uint8_t ft_idle_down_bits[] = { 0, 1, 1, 1, 0 }; /* modify an uplink TRAU frame so we can send it downlink */ int trau_frame_up2down(struct decoded_trau_frame *fr) { - u_int8_t cbits5 = get_bits(fr->c_bits, 0, 5); + uint8_t cbits5 = get_bits(fr->c_bits, 0, 5); switch (cbits5) { case TRAU_FT_FR_UP: @@ -178,7 +178,7 @@ int trau_frame_up2down(struct decoded_trau_frame *fr) } -static void encode_fr(u_int8_t *trau_bits, const struct decoded_trau_frame *fr) +static void encode_fr(uint8_t *trau_bits, const struct decoded_trau_frame *fr) { int i; int d_idx = 0; @@ -205,9 +205,9 @@ static void encode_fr(u_int8_t *trau_bits, const struct decoded_trau_frame *fr) } -int encode_trau_frame(u_int8_t *trau_bits, const struct decoded_trau_frame *fr) +int encode_trau_frame(uint8_t *trau_bits, const struct decoded_trau_frame *fr) { - u_int8_t cbits5 = get_bits(fr->c_bits, 0, 5); + uint8_t cbits5 = get_bits(fr->c_bits, 0, 5); /* 16 bits of sync header */ memset(trau_bits, 0, 16); @@ -245,10 +245,10 @@ static struct decoded_trau_frame fr_idle_frame = { .c_bits = { 0, 1, 1, 1, 0 }, /* IDLE DOWNLINK 3.5.5 */ .t_bits = { 1, 1, 1, 1 }, }; -static u_int8_t encoded_idle_frame[TRAU_FRAME_BITS]; +static uint8_t encoded_idle_frame[TRAU_FRAME_BITS]; static int dbits_initted; -u_int8_t *trau_idle_frame(void) +uint8_t *trau_idle_frame(void) { /* only initialize during the first call */ if (!dbits_initted) { diff --git a/src/libtrau/trau_mux.c b/src/libtrau/trau_mux.c index 712e22d85..b8b90bd02 100644 --- a/src/libtrau/trau_mux.c +++ b/src/libtrau/trau_mux.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -29,9 +28,9 @@ #include #include #include -#include +#include -u_int8_t gsm_fr_map[] = { +uint8_t gsm_fr_map[] = { 6, 6, 5, 5, 4, 4, 3, 3, 7, 2, 2, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -53,7 +52,7 @@ struct upqueue_entry { struct llist_head list; struct gsm_network *net; struct gsm_e1_subslot src; - u_int32_t callref; + uint32_t callref; }; static LLIST_HEAD(ss_map); @@ -102,7 +101,7 @@ int trau_mux_map_lchan(const struct gsm_lchan *src, /* unmap one particular subslot from another subslot */ -int trau_mux_unmap(const struct gsm_e1_subslot *ss, u_int32_t callref) +int trau_mux_unmap(const struct gsm_e1_subslot *ss, uint32_t callref) { struct map_entry *me, *me2; struct upqueue_entry *ue, *ue2; @@ -156,14 +155,14 @@ lookup_trau_upqueue(const struct gsm_e1_subslot *src) return NULL; } -static const u_int8_t c_bits_check[] = { 0, 0, 0, 1, 0 }; +static const uint8_t c_bits_check[] = { 0, 0, 0, 1, 0 }; /* we get called by subchan_demux */ int trau_mux_input(struct gsm_e1_subslot *src_e1_ss, - const u_int8_t *trau_bits, int num_bits) + const uint8_t *trau_bits, int num_bits) { struct decoded_trau_frame tf; - u_int8_t trau_bits_out[TRAU_FRAME_BITS]; + uint8_t trau_bits_out[TRAU_FRAME_BITS]; struct gsm_e1_subslot *dst_e1_ss = lookup_trau_mux_map(src_e1_ss); struct subch_mux *mx; struct upqueue_entry *ue; @@ -186,7 +185,7 @@ int trau_mux_input(struct gsm_e1_subslot *src_e1_ss, return -EINVAL; if (memcmp(tf.c_bits, c_bits_check, sizeof(c_bits_check))) DEBUGPC(DMUX, "illegal trau (C1-C5) %s\n", - hexdump(tf.c_bits, sizeof(c_bits_check))); + osmo_hexdump(tf.c_bits, sizeof(c_bits_check))); msg = msgb_alloc(sizeof(struct gsm_data_frame) + 33, "GSM-DATA"); if (!msg) @@ -231,7 +230,7 @@ int trau_mux_input(struct gsm_e1_subslot *src_e1_ss, } /* add receiver instance for lchan and callref */ -int trau_recv_lchan(struct gsm_lchan *lchan, u_int32_t callref) +int trau_recv_lchan(struct gsm_lchan *lchan, uint32_t callref) { struct gsm_e1_subslot *src_ss; struct upqueue_entry *ue; @@ -260,7 +259,7 @@ int trau_recv_lchan(struct gsm_lchan *lchan, u_int32_t callref) int trau_send_frame(struct gsm_lchan *lchan, struct gsm_data_frame *frame) { - u_int8_t trau_bits_out[TRAU_FRAME_BITS]; + uint8_t trau_bits_out[TRAU_FRAME_BITS]; struct gsm_e1_subslot *dst_e1_ss = &lchan->ts->e1_link; struct subch_mux *mx; int i, j, k, l, o; -- cgit v1.2.3