diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-08-28 14:33:57 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-08-30 15:04:15 +0200 |
commit | 01d47a82b316f29a6a937ab939105eec9f810fa4 (patch) | |
tree | 25fc8cbd5d8b4e354d413c5d8824dea2bbb30d5f | |
parent | 1185d344e23838f17fad9570ed25f62d1fd24367 (diff) |
rtp: Move the RTP header and defines into a shared header file
-rw-r--r-- | openbsc/include/openbsc/Makefile.am | 2 | ||||
-rw-r--r-- | openbsc/include/openbsc/rtp_rfc.h | 50 | ||||
-rw-r--r-- | openbsc/src/libmgcp/mgcp_network.c | 27 | ||||
-rw-r--r-- | openbsc/src/libtrau/rtp_proxy.c | 43 |
4 files changed, 53 insertions, 69 deletions
diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 4f4113490..3e2ef70e7 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -12,7 +12,7 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ gprs_ns_frgre.h auth.h osmo_msc.h bsc_msc.h bsc_nat.h \ osmo_bsc_rf.h osmo_bsc.h network_listen.h bsc_nat_sccp.h \ osmo_msc_data.h osmo_bsc_grace.h sms_queue.h abis_om2000.h \ - bss.h gsm_data_shared.h control_cmd.h + bss.h gsm_data_shared.h control_cmd.h ipaccess.h rtp_rfc.h openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h openbscdir = $(includedir)/openbsc diff --git a/openbsc/include/openbsc/rtp_rfc.h b/openbsc/include/openbsc/rtp_rfc.h new file mode 100644 index 000000000..68a8e7c97 --- /dev/null +++ b/openbsc/include/openbsc/rtp_rfc.h @@ -0,0 +1,50 @@ +#ifndef OPENSC_RTP_RFC_H +#define OPENSC_RTP_RFC_H + +#include <stdint.h> +#include <unistd.h> + +/* attempt to determine byte order */ +#include <sys/param.h> +#include <limits.h> + +#ifndef __BYTE_ORDER +#error "__BYTE_ORDER should be defined by someone" +#endif + +#define RTP_VERSION 2 + +#define RTCP_TYPE_SDES 202 +#define RTCP_IE_CNAME 1 + +/* according to RFC 1889 */ +struct rtcp_hdr { + uint8_t byte0; + uint8_t type; + uint16_t length; +} __attribute__((packed)); + +/* according to rtp_proxy.c RFC 3550 */ +struct rtp_hdr { +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint8_t csrc_count:4, + extension:1, + padding:1, + version:2; + uint8_t payload_type:7, + marker:1; +#elif __BYTE_ORDER == __BIG_ENDIAN + uint8_t version:2, + padding:1, + extension:1, + csrc_count:4; + uint8_t marker:1, + payload_type:7; +#endif + uint16_t sequence; + uint32_t timestamp; + uint32_t ssrc; +} __attribute__((packed)); + + +#endif diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index 9ff29439e..91a97047e 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -34,6 +34,7 @@ #include <openbsc/mgcp.h> #include <openbsc/mgcp_internal.h> +#include <openbsc/rtp_rfc.h> #warning "Make use of the rtp proxy code" @@ -41,32 +42,6 @@ #include <sys/param.h> #include <limits.h> -#ifndef __BYTE_ORDER -#error "__BYTE_ORDER should be defined by someone" -#endif - -/* according to rtp_proxy.c RFC 3550 */ -struct rtp_hdr { -#if __BYTE_ORDER == __LITTLE_ENDIAN - uint8_t csrc_count:4, - extension:1, - padding:1, - version:2; - uint8_t payload_type:7, - marker:1; -#elif __BYTE_ORDER == __BIG_ENDIAN - uint8_t version:2, - padding:1, - extension:1, - csrc_count:4; - uint8_t marker:1, - payload_type:7; -#endif - uint16_t sequence; - uint32_t timestamp; - uint32_t ssrc; -} __attribute__((packed)); - enum { DEST_NETWORK = 0, diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c index 4c5f12eb5..c28d34d25 100644 --- a/openbsc/src/libtrau/rtp_proxy.c +++ b/openbsc/src/libtrau/rtp_proxy.c @@ -34,16 +34,9 @@ #include <osmocom/core/select.h> #include <openbsc/debug.h> #include <openbsc/rtp_proxy.h> +#include <openbsc/rtp_rfc.h> #include <openbsc/mncc.h> -/* attempt to determine byte order */ -#include <sys/param.h> -#include <limits.h> - -#ifndef __BYTE_ORDER -#error "__BYTE_ORDER should be defined by someone" -#endif - static LLIST_HEAD(rtp_sockets); /* should we mangle the CNAME inside SDES of RTCP packets? We disable @@ -58,46 +51,12 @@ enum rtp_bfd_priv { #define RTP_ALLOC_SIZE 1500 -/* according to RFC 1889 */ -struct rtcp_hdr { - uint8_t byte0; - uint8_t type; - uint16_t length; -} __attribute__((packed)); - -#define RTCP_TYPE_SDES 202 - -#define RTCP_IE_CNAME 1 - -/* according to RFC 3550 */ -struct rtp_hdr { -#if __BYTE_ORDER == __LITTLE_ENDIAN - uint8_t csrc_count:4, - extension:1, - padding:1, - version:2; - uint8_t payload_type:7, - marker:1; -#elif __BYTE_ORDER == __BIG_ENDIAN - uint8_t version:2, - padding:1, - extension:1, - csrc_count:4; - uint8_t marker:1, - payload_type:7; -#endif - uint16_t sequence; - uint32_t timestamp; - uint32_t ssrc; -} __attribute__((packed)); struct rtp_x_hdr { 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, uint32_t callref, struct msgb **data) { |