From 40c1e85499ec152a26bfd07433765730e3782104 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 17 Jan 2017 09:00:30 +0100 Subject: client: Allow to bind to a specific source_ip Modify the osmo_sock_init (code clone to be integrated upstream) to allow binding to a specific source ip and source port. Allow the source ip to be configured but allow the kernel to pick a random port for us. This is necessary for systems with multiple interfaces where the default route is not necessarily the right one to connect to the pcap server. Change-Id: I84e728b0752213d28f970fcbbfd6565c441ccfeb --- src/osmo_client_vty.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/osmo_client_vty.c') diff --git a/src/osmo_client_vty.c b/src/osmo_client_vty.c index 5cf3aa1..4cd2908 100644 --- a/src/osmo_client_vty.c +++ b/src/osmo_client_vty.c @@ -91,6 +91,9 @@ static void write_client_conn_data( if (conn->srv_port > 0) vty_out(vty, "%s server port %d%s", indent, conn->srv_port, VTY_NEWLINE); + if (conn->source_ip) + vty_out(vty, "%s source ip %s%s", indent, + conn->source_ip, VTY_NEWLINE); } static int config_write_server(struct vty *vty) @@ -393,6 +396,19 @@ DEFUN(cfg_server_port, return CMD_SUCCESS; } +DEFUN(cfg_source_ip, + cfg_source_ip_cmd, + "source ip A.B.C.D", + SERVER_STRING "Source IP Address\n" "IP\n") +{ + struct osmo_pcap_client_conn *conn = get_conn(vty); + + talloc_free(conn->source_ip); + conn->source_ip = talloc_strdup(pcap_client, argv[0]); + return CMD_SUCCESS; +} + + DEFUN(cfg_pcap_store, cfg_pcap_store_cmd, "pcap-store-connection .NAME", @@ -465,6 +481,7 @@ int vty_client_init(struct osmo_pcap_client *pcap) install_element(CLIENT_NODE, &cfg_server_ip_cmd); install_element(CLIENT_NODE, &cfg_server_port_cmd); + install_element(CLIENT_NODE, &cfg_source_ip_cmd); install_element(CLIENT_NODE, &cfg_enable_tls_cmd); install_element(CLIENT_NODE, &cfg_disable_tls_cmd); @@ -491,6 +508,7 @@ int vty_client_init(struct osmo_pcap_client *pcap) install_element(CLIENT_NODE, &cfg_no_pcap_store_cmd); install_element(CLIENT_SERVER_NODE, &cfg_server_ip_cmd); install_element(CLIENT_SERVER_NODE, &cfg_server_port_cmd); + install_element(CLIENT_SERVER_NODE, &cfg_source_ip_cmd); install_element(CLIENT_SERVER_NODE, &cfg_enable_tls_cmd); install_element(CLIENT_SERVER_NODE, &cfg_disable_tls_cmd); install_element(CLIENT_SERVER_NODE, &cfg_tls_hostname_cmd); -- cgit v1.2.3