endp: move endpoint name generation into mgcp_endp.c

When the trunk allocates its endpoints by using mgcp_endp_alloc()
ist passes the name for each endpoint as a parameter. In order to
generate the name endpoint specific knowlege is required.

This process can be simplified, since all what
mgcp_trunk_alloc_endpts() does is calling mgcp_endp_alloc() in a loop in
order to generate a consecuitve series of endpoints. The endpoint names
are generated from the index of the for loop.

When we just pass the index instead of the endpoint name to
mgcp_endp_alloc(), then we can greatly simplify the code since all the
knowledge about the name generation can go into mgcp_endp.c. The
endpoint will name itsself by the trunk properties and the index number
we pass with the allocator function.

Change-Id: I8dee07f1c63037d1f73113f69c612d1f2703cee5
Related: OS#2659
diff --git a/src/libosmo-mgcp/mgcp_trunk.c b/src/libosmo-mgcp/mgcp_trunk.c
index 6736145..3692351 100644
--- a/src/libosmo-mgcp/mgcp_trunk.c
+++ b/src/libosmo-mgcp/mgcp_trunk.c
@@ -66,7 +66,6 @@
 int mgcp_trunk_alloc_endpts(struct mgcp_trunk *trunk)
 {
 	int i;
-	char ep_name_buf[MGCP_ENDPOINT_MAXLEN];
 	struct mgcp_endpoint *endp;
 
 	/* Make sure the amount of requested endpoints does not execeed
@@ -90,22 +89,7 @@
 
 	/* create endpoints */
 	for (i = 0; i < trunk->vty_number_endpoints; ++i) {
-		switch (trunk->trunk_type) {
-		case MGCP_TRUNK_VIRTUAL:
-			snprintf(ep_name_buf, sizeof(ep_name_buf), "%s%x@%s", MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK, i,
-				 trunk->cfg->domain);
-			break;
-		case MGCP_TRUNK_E1:
-			/* FIXME: E1 trunk implementation is work in progress, this endpoint
-			 * name is incomplete (subslots) */
-			snprintf(ep_name_buf, sizeof(ep_name_buf), "%s-1/%x", MGCP_ENDPOINT_PREFIX_E1_TRUNK, i);
-			break;
-		default:
-			osmo_panic("Cannot allocate unimplemented trunk type %d! %s:%d\n",
-				   trunk->trunk_type, __FILE__, __LINE__);
-		}
-
-		endp = mgcp_endp_alloc(trunk, ep_name_buf);
+		endp = mgcp_endp_alloc(trunk, i);
 		if (!endp) {
 			talloc_free(trunk->endpoints);
 			return -1;