diff options
author | Harald Welte <laforge@gnumonks.org> | 2018-05-25 17:35:54 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-05-25 18:58:16 +0000 |
commit | 584ab8e11fd9a4f3699a2167eb4d0eb8ad914190 (patch) | |
tree | 0cff791bb57abbb3e3229790efc063f7704eba91 /include/osmocom/bsc/bsc_msc_data.h | |
parent | 3909d99faeda91befc05c50bf8b3d404bee1e68f (diff) |
bsc: Add mgcp_port_to_cic() to determine CIC from RTP Port
Also: Move mgcp_timeslot_to_port() next to it, as they are
more or less the inverse transformation of each other.
Change-Id: Ica908e2bb8fc4e59e0d146b428c93a9efc385688
Diffstat (limited to 'include/osmocom/bsc/bsc_msc_data.h')
-rw-r--r-- | include/osmocom/bsc/bsc_msc_data.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h index c69a9ca55..2ace1786b 100644 --- a/include/osmocom/bsc/bsc_msc_data.h +++ b/include/osmocom/bsc/bsc_msc_data.h @@ -28,6 +28,7 @@ #define _OSMO_MSC_DATA_H #include "bsc_msc.h" +#include "debug.h" #include <osmocom/core/timer.h> #include <osmocom/gsm/protocol/gsm_04_08.h> @@ -42,6 +43,7 @@ #include <osmocom/gsm/gsm23003.h> #include <regex.h> +#include <errno.h> struct osmo_bsc_rf; struct gsm_network; @@ -164,5 +166,25 @@ int osmo_bsc_audio_init(struct gsm_network *network); struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *, int); struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *, int); +/* Helper function to calculate the port number for a given + * timeslot/multiplex. This functionality is needed to support + * the sccp-lite scenario where the MGW is handled externally */ +static inline int mgcp_timeslot_to_port(int multiplex, int timeslot, int base) +{ + if (timeslot == 0) { + LOGP(DLMGCP, LOGL_ERROR, "Timeslot should not be 0\n"); + timeslot = 255; + } + + return base + (timeslot + (32 * multiplex)) * 2; +} + +static inline int mgcp_port_to_cic(uint16_t port, uint16_t base) +{ + if (port < base) + return -EINVAL; + return (port - base) / 2; +} + #endif |