From da12281342317ed9351d3b0fb99596a40b928fd9 Mon Sep 17 00:00:00 2001 From: Mohammed Morsi Date: Wed, 10 Jun 2009 13:31:42 -0400 Subject: [PATCH] add cmd line option for server vnc port --- internal.h | 3 +++ main.c | 3 +++ tunnel.c | 7 ++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal.h b/internal.h index 80e675e..bd65922 100644 --- a/internal.h +++ b/internal.h @@ -71,6 +71,9 @@ extern gboolean check_cert; /* server we're connecting to */ extern const char* hostname; +/* port which to connect to the server via vnc */ +extern int ovirt_server_vnc_port; + /* vm currently in focus */ extern struct vm* vm_in_focus; diff --git a/main.c b/main.c index 23af6fa..dd26c93 100644 --- a/main.c +++ b/main.c @@ -75,6 +75,7 @@ static GSList *vmlist = NULL; /* internal.h shared constructs */ const char* hostname; struct vm* vm_in_focus; +int ovirt_server_vnc_port = 5900; /* Private functions. */ static void start_ui (void); @@ -200,6 +201,8 @@ static const char *help_msg = "Use '" PACKAGE " --help' to see a list of available command line options"; static const GOptionEntry options[] = { + { "port", 'p', 0, G_OPTION_ARG_INT, &ovirt_server_vnc_port, + "set port which to connect to server via vnc", NULL }, { "cainfo", 0, 0, G_OPTION_ARG_STRING, &cainfo, "set the path of the CA certificate bundle", NULL }, { "check-certificate", 0, 0, G_OPTION_ARG_NONE, &check_cert, diff --git a/tunnel.c b/tunnel.c index c6d091d..17b512c 100644 --- a/tunnel.c +++ b/tunnel.c @@ -53,9 +53,6 @@ const int VM_NAME_MAX_LEN = 250; // max length of vnc data const int VNC_DATA_MAX_LEN = 800000; -// port which to connect to on ovirt server -const int OVIRT_SERVER_PORT = 5900; - /* Private thread functions */ static gpointer tunnel_thread(gpointer data); static gpointer client_server_thread(gpointer data); @@ -164,7 +161,7 @@ tunnel_thread (gpointer _data) } ovirt_server_address.sin_family = PF_INET; ovirt_server_address.sin_addr.s_addr = ((struct in_addr*)(dns_serv->h_addr))->s_addr; //inet_addr(hostname); - ovirt_server_address.sin_port = htons(OVIRT_SERVER_PORT); + ovirt_server_address.sin_port = htons(ovirt_server_vnc_port); ovirt_server_len = sizeof(ovirt_server_address); // create local net socket @@ -212,7 +209,7 @@ tunnel_thread (gpointer _data) ovirt_server_socket = socket(PF_INET, SOCK_STREAM, 0); c_socket = malloc(sizeof(int)); *c_socket = ovirt_server_socket; sockets = g_slist_prepend(sockets, c_socket); - DEBUG ("connecting to ovirt server %s on %i", hostname, OVIRT_SERVER_PORT); + DEBUG ("connecting to ovirt server %s on %i", hostname, ovirt_server_vnc_port); if(connect(ovirt_server_socket, (struct sockaddr*)&ovirt_server_address, ovirt_server_len) < 0){ DEBUG ("could not connect to ovirt server"); break; -- 1.8.3.1