mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	mgcp: Make the base port of the transcoder configurable
The code assumes a static mapping from endpoint to RTP port, be able to configure the start of such a mapping.
This commit is contained in:
		@@ -109,14 +109,17 @@ struct mgcp_config {
 | 
			
		||||
	unsigned int number_endpoints;
 | 
			
		||||
	char *bts_ip;
 | 
			
		||||
	char *call_agent_addr;
 | 
			
		||||
	char *transcoder_ip;
 | 
			
		||||
 | 
			
		||||
	struct in_addr bts_in;
 | 
			
		||||
	struct in_addr transcoder_in;
 | 
			
		||||
	char *audio_name;
 | 
			
		||||
	int audio_payload;
 | 
			
		||||
	int audio_loop;
 | 
			
		||||
 | 
			
		||||
	/* transcoder handling */
 | 
			
		||||
	char *transcoder_ip;
 | 
			
		||||
	struct in_addr transcoder_in;
 | 
			
		||||
	int transcoder_remote_base;
 | 
			
		||||
 | 
			
		||||
	struct write_queue gw_fd;
 | 
			
		||||
 | 
			
		||||
	struct mgcp_port_range bts_ports;
 | 
			
		||||
 
 | 
			
		||||
@@ -174,7 +174,7 @@ static int send_transcoder(struct mgcp_endpoint *endp, int is_rtp,
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	port = rtp_calculate_port(ENDPOINT_NUMBER(endp), 4000);
 | 
			
		||||
	port = rtp_calculate_port(ENDPOINT_NUMBER(endp), cfg->transcoder_remote_base);
 | 
			
		||||
	if (!is_rtp)
 | 
			
		||||
		port += 1;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -780,6 +780,7 @@ struct mgcp_config *mgcp_config_alloc(void)
 | 
			
		||||
	cfg->source_addr = talloc_strdup(cfg, "0.0.0.0");
 | 
			
		||||
	cfg->audio_name = talloc_strdup(cfg, "AMR/8000");
 | 
			
		||||
	cfg->audio_payload = 126;
 | 
			
		||||
	cfg->transcoder_remote_base = 4000;
 | 
			
		||||
 | 
			
		||||
	cfg->bts_ports.base_port = RTP_PORT_DEFAULT;
 | 
			
		||||
	cfg->net_ports.base_port = RTP_PORT_NET_DEFAULT;
 | 
			
		||||
@@ -934,7 +935,7 @@ static void create_transcoder(struct mgcp_endpoint *endp)
 | 
			
		||||
	send_msg(endp, out_endp, endp->transcoder_end.local_port, "CRCX", "sendrecv");
 | 
			
		||||
	send_msg(endp, out_endp, endp->transcoder_end.local_port, "MDCX", "sendrecv");
 | 
			
		||||
 | 
			
		||||
	port = rtp_calculate_port(out_endp, 4000);
 | 
			
		||||
	port = rtp_calculate_port(out_endp, endp->cfg->transcoder_remote_base);
 | 
			
		||||
	endp->transcoder_end.rtp_port = htons(port);
 | 
			
		||||
	endp->transcoder_end.rtcp_port = htons(port + 1);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -86,6 +86,7 @@ static int config_write_mgcp(struct vty *vty)
 | 
			
		||||
	else
 | 
			
		||||
		vty_out(vty, "  rtp transcoder-range %u %u%s",
 | 
			
		||||
			g_cfg->transcoder_ports.range_start, g_cfg->transcoder_ports.range_end, VTY_NEWLINE);
 | 
			
		||||
	vty_out(vty, "  transcoder-remote-base %u%s", g_cfg->transcoder_remote_base, VTY_NEWLINE);
 | 
			
		||||
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
@@ -329,6 +330,16 @@ DEFUN(cfg_mgcp_transcoder,
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN(cfg_mgcp_transcoder_remote_base,
 | 
			
		||||
      cfg_mgcp_transcoder_remote_base_cmd,
 | 
			
		||||
      "transcoder-remote-base <0-65534>",
 | 
			
		||||
      "Set the base port for the transcoder\n" "The RTP base port on the transcoder")
 | 
			
		||||
{
 | 
			
		||||
	g_cfg->transcoder_remote_base = atoi(argv[0]);
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DEFUN(loop_endp,
 | 
			
		||||
      loop_endp_cmd,
 | 
			
		||||
      "loop-endpoint NAME (0|1)",
 | 
			
		||||
@@ -453,6 +464,7 @@ int mgcp_vty_init(void)
 | 
			
		||||
	install_element(MGCP_NODE, &cfg_mgcp_number_endp_cmd);
 | 
			
		||||
	install_element(MGCP_NODE, &cfg_mgcp_agent_addr_cmd);
 | 
			
		||||
	install_element(MGCP_NODE, &cfg_mgcp_transcoder_cmd);
 | 
			
		||||
	install_element(MGCP_NODE, &cfg_mgcp_transcoder_remote_base_cmd);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user