aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo_client_vty.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-01-17 09:00:30 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-01-17 09:06:42 +0100
commit40c1e85499ec152a26bfd07433765730e3782104 (patch)
tree54b5769e4ccf08f8e6981f1c6a6d65427bc851ae /src/osmo_client_vty.c
parentfdebd88059df3a8f717614548dcd7247e8890f9a (diff)
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
Diffstat (limited to 'src/osmo_client_vty.c')
-rw-r--r--src/osmo_client_vty.c18
1 files changed, 18 insertions, 0 deletions
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);