diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2017-05-29 13:14:18 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-06-18 17:50:08 +0200 |
commit | e818b91729de56db7643c0961f810c1652f65701 (patch) | |
tree | 8d4b447c1a6f1ea53470d53b83dff329f0aa265f /openbsc/src/osmo-bsc/osmo_bsc_bssap.c | |
parent | 805b83a1ef41bbc1d0d6c944e949dbbd33fcfc75 (diff) |
osmo-bsc: Negotiate rtp ip address/port with BTS
This patch adds the support for the RTP IP-Address/Port assignment.
The post communicated via the assignment request is now transmitted
via RSL/IPACC to the BTS. The Response containing the RX-Port at
the BTS side is communicated back to the MSC.
Since we plan to add a private MGCPGW to each BSC, this has to
be extended. Currently it only creates a direct connection to
the BTS. This will be introduced with a future patch.
Diffstat (limited to 'openbsc/src/osmo-bsc/osmo_bsc_bssap.c')
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_bssap.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c index 57a62a5eb..e705e708d 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c @@ -29,7 +29,11 @@ #include <osmocom/gsm/protocol/gsm_08_08.h> #include <osmocom/gsm/gsm0808.h> +#include <osmocom/gsm/gsm0808_utils.h> #include <openbsc/osmo_bsc_sigtran.h> +#include <osmocom/core/byteswap.h> + +#define IP_V4_ADDR_LEN 4 /* * helpers for the assignment command @@ -305,10 +309,14 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn, struct bsc_msc_data *msc; struct tlv_parsed tp; uint8_t *data; - uint8_t timeslot; - uint8_t multiplex; + uint8_t timeslot = 0; + uint8_t multiplex = 0; enum gsm48_chan_mode chan_mode = GSM48_CMODE_SIGN; int i, supported, port, full_rate = -1; + bool aoip = false; + struct sockaddr_storage rtp_addr; + struct sockaddr_in *rtp_addr_in; + int rc; if (!conn->conn) { LOGP(DMSC, LOGL_ERROR, "No lchan/msc_data in cipher mode command.\n"); @@ -322,15 +330,25 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn, goto reject; } - if (!TLVP_PRESENT(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE)) { - LOGP(DMSC, LOGL_ERROR, "Identity code missing. Audio routing will not work.\n"); + /* Detect if a CIC code is present, if so, we use the classic ip.access + * method to calculate the RTP port */ + if (TLVP_PRESENT(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE)) { + conn->cic = osmo_load16be(TLVP_VAL(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE)); + timeslot = conn->cic & 0x1f; + multiplex = (conn->cic & ~0x1f) >> 5; + } else if(TLVP_PRESENT(&tp, GSM0808_IE_AOIP_TRASP_ADDR)) { + /* Decode AoIP transport address element */ + rc = gsm0808_dec_aoip_trasp_addr(&rtp_addr, TLVP_VAL(&tp, GSM0808_IE_AOIP_TRASP_ADDR), TLVP_LEN(&tp, GSM0808_IE_AOIP_TRASP_ADDR)); + if (rc < 0) { + LOGP(DMSC, LOGL_ERROR, "Unable to decode aoip transport address.\n"); + goto reject; + } + aoip = true; + } else { + LOGP(DMSC, LOGL_ERROR, "transport address missing. Audio routing will not work.\n"); goto reject; } - conn->cic = osmo_load16be(TLVP_VAL(&tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE)); - timeslot = conn->cic & 0x1f; - multiplex = (conn->cic & ~0x1f) >> 5; - /* * Currently we only support a limited subset of all * possible channel types. The limitation ends by not using @@ -383,9 +401,25 @@ static int bssmap_handle_assignm_req(struct osmo_bsc_sccp_con *conn, goto reject; } - /* map it to a MGCP Endpoint and a RTP port */ - port = mgcp_timeslot_to_endpoint(multiplex, timeslot); - conn->rtp_port = rtp_calculate_port(port, msc->rtp_base); + if (aoip == false) { + /* map it to a MGCP Endpoint and a RTP port */ + port = mgcp_timeslot_to_endpoint(multiplex, timeslot); + conn->rtp_port = rtp_calculate_port(port, msc->rtp_base); + conn->rtp_ip = 0; + } else { + /* use address / port supplied with the AoIP + * transport address element */ + if(rtp_addr.ss_family == AF_INET) + { + rtp_addr_in = (struct sockaddr_in *)&rtp_addr; + conn->rtp_port = osmo_ntohs(rtp_addr_in->sin_port); + memcpy(&conn->rtp_ip, &rtp_addr_in->sin_addr.s_addr, IP_V4_ADDR_LEN); + conn->rtp_ip = osmo_ntohl(conn->rtp_ip); + } else { + LOGP(DMSC, LOGL_ERROR, "Unsopported addressing scheme. (supports only IPV4)\n"); + goto reject; + } + } return gsm0808_assign_req(conn->conn, chan_mode, full_rate); |