Change in osmo-mgw[master]: endp: add name generator function for E1 endpoints

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Jun 18 11:21:15 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/18745 )

Change subject: endp: add name generator function for E1 endpoints
......................................................................

endp: add name generator function for E1 endpoints

Currently the endpoint name that is generated for an E1 endpoint is not
correct. Let's add an endpoint name generator function that derives a
full endpoint name for a given E1 index

Change-Id: I70e0c3f96aa3947165f9926666815ee5614c8f57
Related: OS#2547
---
M src/libosmo-mgcp/mgcp_endp.c
1 file changed, 39 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  tnt: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index 3f1213b..db8898b 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -41,6 +41,44 @@
 		 MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK, index, domain);
 }
 
+/* Generate E1 endpoint name from given numeric parameters */
+static char *gen_e1_epname(void *ctx, uint8_t trunk_nr, uint8_t ts_nr,
+			  uint8_t ss_nr)
+{
+	/* A 64k timeslot on an E1 line can be subdevied into the following
+	 * subslot combinations:
+	 *
+	 * subslot:                                          offset:
+	 * [          ][          ][   16k    ][8k_subslot]  0
+	 * [          ][   32k    ][_subslot__][8k_subslot]  1
+	 * [          ][ subslot  ][   16k    ][8k_subslot]  2
+	 * [   64k    ][__________][_subslot__][8k_subslot]  3
+	 * [ timeslot ][          ][   16k    ][8k_subslot]  4
+	 * [          ][   32K    ][_subslot__][8k_subslot]  5
+	 * [          ][ subslot  ][   16k    ][8k_subslot]  6
+	 * [          ][          ][ subslot  ][8k_subslot]  7
+	 *
+	 * Since overlapping assignment of subsolts is not possible there is
+	 * a limited set of subsolt assignments possible. The rates array
+	 * lists the possible assignments as depicted above. Also each subslot
+	 * assignment comes along with a bit offset in the E1 bitstream. The
+	 * offsets arrays lists the bit offsets. */
+	static const uint8_t rates[] =
+		{ 64, 32, 32, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 };
+	static const uint8_t offsets[] =
+		{ 0, 0, 4, 0, 2, 4, 6, 0, 1, 2, 3, 4, 5, 6, 7 };
+	unsigned int rate;
+	unsigned int offset;
+
+	OSMO_ASSERT(ss_nr < sizeof(rates));
+
+	rate = rates[ss_nr];
+	offset = offsets[ss_nr];
+
+	return talloc_asprintf(ctx, "%s%u/s-%u/su%u-%u",
+			MGCP_ENDPOINT_PREFIX_E1_TRUNK, trunk_nr, ts_nr, rate, offset);
+}
+
 /*! allocate an endpoint and set default values.
  *  \param[in] trunk configuration.
  *  \param[in] name endpoint index.
@@ -64,11 +102,8 @@
 		endp->name = gen_virtual_epname(endp, trunk->cfg->domain, index);
 		break;
 	case MGCP_TRUNK_E1:
-		/* FIXME: E1 trunk implementation is work in progress, this endpoint
-		 * name is incomplete (subslots) */
-		endp->name = talloc_asprintf(endp, "%s-1/%x", MGCP_ENDPOINT_PREFIX_E1_TRUNK, index);
-		LOGP(DLMGCP, LOGL_FATAL, "E1 trunks not implemented!\n");
 		endp->type = &ep_typeset.rtp;
+		endp->name = gen_e1_epname(endp, trunk->trunk_nr, index / 15, index % 15);
 		break;
 	default:
 		osmo_panic("Cannot allocate unimplemented trunk type %d! %s:%d\n",

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/18745
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I70e0c3f96aa3947165f9926666815ee5614c8f57
Gerrit-Change-Number: 18745
Gerrit-PatchSet: 7
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200618/bc5a144f/attachment.htm>


More information about the gerrit-log mailing list