mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-03 13:33:29 +00:00
TW-TS-001 and TW-TS-002 are enhanced RTP transport formats for GSM FR/HR/EFR codecs that restore the lost semantics of GSM 08.60 and 08.61 TRAU-UL frames. TW-TS-003 BSSMAP extension provides a way for a core network to ask the BSS to use these TRAU-like enhanced RTP formats instead of those specified in 3GPP TS 48.103; OsmoBSC already supports this mechanism when the BSS is comprised of IP-native OsmoBTS. However, in order to achieve the same effect when using E1-based legacy BTS hardware, the task of generating TW-TS-001/002 RTP packets for UL and accepting them for DL moves from OsmoBTS to the E1-Abis-interfacing MGW. osmo_trau2rtp() is already capable of generating these extended RTP formats on request, but until now there was no mechanism to signal from OsmoBSC to its associated E1 Abis MGW whether and when these extensions should be used. Considering that MGCP as it is used in Osmocom is essentially a private interface between OsmoBSC or OsmoMSC masters and OsmoMGW slaves, while the externally defined and generally interoperable interface is 3GPP TS 48.008, possibly extended with TW-TS-003, the sensible solution is to make a private extension to the way FR, EFR and HR codecs are described in SDP in the context of Osmocom-MGCP. The SDP extension birthed in the present patch consists of an fmtp parameter for GSM, GSM-EFR and GSM-HR-08 codecs that is structured just like the already implemented octet-align parameter for AMR. TW-TS-001 for FR and EFR shall be described as follows: m=audio 1234 RTP/AVP 3 110 a=rtpmap:3 GSM/8000/1 a=fmtp:3 tw-ts-001=1 a=rtpmap:110 GSM-EFR/8000/1 a=fmtp:110 tw-ts-001=1 TW-TS-002 for HR codec shall be described as follows: m=audio 1234 RTP/AVP 111 a=rtpmap:111 GSM-HR-08/8000/1 a=fmtp:111 tw-ts-002=1 The present patch affects two areas: * Experimental support for the newly defined extension is added to OsmoMGW-E1. This support is deemed experimental (not for production use) because even with this extension added, OsmoMGW-E1 is still unable to satisfy ThemWi requirements: neither ThemWi RTP endpoint library nor the TFO transform of TS 28.062 section C.3.2.1.1 are currently available in the repertoire of libraries whose use is allowed in mainline OsmoCNI components, yet both are required. * Support is added to libosmo-mgcp-client whereby OsmoBSC will be able to issue CRCX and MDCX commands to E1 Abis MGW endpoints with TW-TS-001 and/or TW-TS-002 enabled. Adding the necessary support to OsmoBSC will allow a complete working system to be deployed using OsmoBSC plus tw-e1abis-mgw, a replacement for OsmoMGW-E1 that works by using both Osmocom and ThemWi libraries. Related: OS#6614 Change-Id: I0d58e6d84418f50670c8ab7cf8490af3bc2f5c26
117 lines
3.7 KiB
C
117 lines
3.7 KiB
C
/* MGCP common implementations.
|
|
* These are used in libosmo-mgcp as well as libosmo-mgcp-client.
|
|
* To avoid interdependency, these are implemented in .h file only. */
|
|
|
|
/*
|
|
* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
|
|
* (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
* (C) 2009-2012 by On-Waves
|
|
* All Rights Reserved
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
/* Two copies of this file are kept in osmocom/mgcp/ and osmocom/mgcp_client/.
|
|
* Since both are by definition identical, use the old header exclusion ifdefs
|
|
* instead of '#pragma once' to avoid including both of these files.
|
|
* Though at the time of writing there are no such users, this allows including
|
|
* both libosmo-mgcp and libosmo-mgcp-client headers in the same file. */
|
|
#ifndef OSMO_MGCP_COMMON_H
|
|
#define OSMO_MGCP_COMMON_H
|
|
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include <osmocom/core/msgb.h>
|
|
#include <osmocom/core/logging.h>
|
|
|
|
#define for_each_non_empty_line(line, save) \
|
|
for (line = strtok_r(NULL, "\r\n", &save); line; \
|
|
line = strtok_r(NULL, "\r\n", &save))
|
|
|
|
enum mgcp_connection_mode {
|
|
MGCP_CONN_NONE = 0,
|
|
MGCP_CONN_RECV_ONLY = 1,
|
|
MGCP_CONN_SEND_ONLY = 2,
|
|
MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
|
|
MGCP_CONN_LOOPBACK = 4 | MGCP_CONN_RECV_SEND,
|
|
MGCP_CONN_CONFECHO = 8 | MGCP_CONN_RECV_SEND,
|
|
};
|
|
|
|
#define MGCP_X_OSMO_IGN_HEADER "X-Osmo-IGN:"
|
|
#define MGCP_X_OSMO_OSMUX_HEADER "X-Osmux:"
|
|
|
|
/* Values should be bitwise-OR-able */
|
|
enum mgcp_x_osmo_ign {
|
|
MGCP_X_OSMO_IGN_NONE = 0,
|
|
MGCP_X_OSMO_IGN_CALLID = 1,
|
|
};
|
|
|
|
/* Codec parameters (communicated via SDP/fmtp) */
|
|
struct mgcp_codec_param {
|
|
bool amr_octet_aligned_present;
|
|
bool amr_octet_aligned;
|
|
bool fr_efr_twts001_present;
|
|
bool fr_efr_twts001;
|
|
bool hr_twts002_present;
|
|
bool hr_twts002;
|
|
};
|
|
|
|
/* Ensure that the msg->l2h is NUL terminated. */
|
|
static inline int mgcp_msg_terminate_nul(struct msgb *msg)
|
|
{
|
|
unsigned char *tail = msg->tail; /* char after l2 data */
|
|
if (tail[-1] == '\0')
|
|
/* nothing to do */;
|
|
else if (msgb_tailroom(msg) > 0)
|
|
msgb_put_u8(msg, (uint8_t)'\0');
|
|
else if (tail[-1] == '\r' || tail[-1] == '\n')
|
|
tail[-1] = '\0';
|
|
else {
|
|
LOGP(DLMGCP, LOGL_ERROR, "Cannot NUL terminate MGCP message: "
|
|
"Length: %d, Buffer size: %d\n",
|
|
msgb_l2len(msg), msg->data_len);
|
|
return -ENOTSUP;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* Maximum length of the comment field */
|
|
#define MGCP_COMMENT_MAXLEN 256
|
|
|
|
/* Maximum allowed String length of Connection Identifiers as per spec
|
|
* (see also RFC3435 2.1.3.2 Names of Connections), plus one for '\0'. */
|
|
#define MGCP_CONN_ID_MAXLEN 32+1
|
|
|
|
/* Deprecated: old name of MGCP_CONN_ID_MAXLEN. */
|
|
#define MGCP_CONN_ID_LENGTH MGCP_CONN_ID_MAXLEN
|
|
|
|
/* String length of Endpoint Identifiers.
|
|
/ (see also RFC3435 section 3.2.1.3) */
|
|
#define MGCP_ENDPOINT_MAXLEN (255*2+1+1)
|
|
|
|
/* A prefix to denote the virtual trunk (RTP on both ends) */
|
|
#define MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK "rtpbridge/"
|
|
|
|
/* A prefix to denote the e1 trunk
|
|
* (see also RFC3435 section E.2) */
|
|
#define MGCP_ENDPOINT_PREFIX_E1_TRUNK "ds/e1-"
|
|
|
|
/* Maximal number of payload types / codecs that can be negotiated via SDP at
|
|
* at once. */
|
|
#define MGCP_MAX_CODECS 10
|
|
|
|
#endif
|