endp: do not cache cfg pointer

There is no obvious reason why we would want to complicate the code by
caching pointers, since pointer traversal is probably not a performance
bottleneck, and if it is we should rather take a look at our dozens of
linked lists first..

Change-Id: I2456ba63598f76200d53e00223abf60bb36a49c0
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 736b071..6341f07 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -144,7 +144,7 @@
 static int setup_rtp_processing(struct mgcp_endpoint *endp,
 				struct mgcp_conn_rtp *conn)
 {
-	struct mgcp_config *cfg = endp->cfg;
+	struct mgcp_config *cfg = endp->trunk->cfg;
 	struct mgcp_conn_rtp *conn_src = NULL;
 	struct mgcp_conn_rtp *conn_dst = conn;
 	struct mgcp_conn *_conn;
@@ -273,7 +273,7 @@
 	 * us for OSMUX connections. Perhaps adding a new internal API to get it
 	 * based on conn type.
 	 */
-	const char *addr = strlen(endp->cfg->local_ip) ? endp->cfg->local_ip : conn->end.local_addr;
+	const char *addr = strlen(endp->trunk->cfg->local_ip) ? endp->trunk->cfg->local_ip : conn->end.local_addr;
 	struct msgb *sdp;
 	int rc;
 	struct msgb *result;
@@ -477,7 +477,7 @@
 
 	OSMO_ASSERT(conn);
 
-	range = &endp->cfg->net_ports;
+	range = &endp->trunk->cfg->net_ports;
 
 	pthread_mutex_lock(&range->lock);
 	/* attempt to find a port */
@@ -741,8 +741,8 @@
  */
 static int mgcp_osmux_setup(struct mgcp_endpoint *endp, const char *line)
 {
-	if (!endp->cfg->osmux_init) {
-		if (osmux_init(OSMUX_ROLE_BSC, endp->cfg) < 0) {
+	if (!endp->trunk->cfg->osmux_init) {
+		if (osmux_init(OSMUX_ROLE_BSC, endp->trunk->cfg) < 0) {
 			LOGPENDP(endp, DLMGCP, LOGL_ERROR, "Cannot init OSMUX\n");
 			return -3;
 		}
@@ -887,7 +887,7 @@
 		case 'X':
 			if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) {
 				/* If osmux is disabled, just skip setting it up */
-				if (!rq->endp->cfg->osmux)
+				if (!rq->endp->trunk->cfg->osmux)
 					break;
 				osmux_cid = mgcp_osmux_setup(endp, line);
 				break;
@@ -1001,7 +1001,7 @@
 			rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
 			goto error2;
 		}
-	} else if (endp->cfg->osmux == OSMUX_USAGE_ONLY) {
+	} else if (endp->trunk->cfg->osmux == OSMUX_USAGE_ONLY) {
 		LOGPCONN(_conn, DLMGCP, LOGL_ERROR,
 			 "CRCX: osmux only and no osmux offered\n");
 		rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
@@ -1165,7 +1165,7 @@
 		case 'X':
 			if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) {
 				/* If osmux is disabled, just skip setting it up */
-				if (!endp->cfg->osmux)
+				if (!endp->trunk->cfg->osmux)
 					break;
 				osmux_cid = mgcp_osmux_setup(endp, line);
 				break;
@@ -1680,7 +1680,7 @@
 	if (len < 0)
 		return -1;
 
-	rc = send_agent(endp->cfg, buf, len);
+	rc = send_agent(endp->trunk->cfg, buf, len);
 	if (rc <= 0)
 		return -1;