aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-06-29 18:57:21 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-06-29 18:57:21 +0000
commite482a63238d3085e96fa698b1c45cf54357038b4 (patch)
tree687dfbd60abb4ef6c5a2017af0d21394730a3699
parentMinor syshead.h change for NetBSD to allow (diff)
downloadopenvpn-e482a63238d3085e96fa698b1c45cf54357038b4.tar.xz
Added two new management states:
OPENVPN_STATE_RESOLVE -- DNS lookup */ OPENVPN_STATE_TCP_CONNECT -- Connecting to TCP server Echo management state change to log. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1068 e7ae566f-a301-0410-adde-c780ea21d3b5
-rw-r--r--manage.c9
-rw-r--r--manage.h4
-rw-r--r--socket.c32
-rw-r--r--socket.h1
4 files changed, 39 insertions, 7 deletions
diff --git a/manage.c b/manage.c
index 3fdca46..1c28485 100644
--- a/manage.c
+++ b/manage.c
@@ -118,6 +118,10 @@ man_state_name (const int state)
return "RECONNECTING";
case OPENVPN_STATE_EXITING:
return "EXITING";
+ case OPENVPN_STATE_RESOLVE:
+ return "RESOLVE";
+ case OPENVPN_STATE_TCP_CONNECT:
+ return "TCP_CONNECT";
default:
return "?";
}
@@ -1536,7 +1540,8 @@ management_set_state (struct management *man,
| LOG_PRINT_STATE
| LOG_PRINT_LOCAL_IP
| LOG_PRINT_REMOTE_IP
- | LOG_PRINT_CRLF, &gc);
+ | LOG_PRINT_CRLF
+ | LOG_ECHO_TO_LOG, &gc);
if (out)
man_output_list_push (man, out);
@@ -2273,6 +2278,8 @@ log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena
buf_printf (&out, ",%s", print_in_addr_t (e->local_ip, IA_EMPTY_IF_UNDEF, gc));
if (flags & LOG_PRINT_REMOTE_IP)
buf_printf (&out, ",%s", print_in_addr_t (e->remote_ip, IA_EMPTY_IF_UNDEF, gc));
+ if (flags & LOG_ECHO_TO_LOG)
+ msg (D_MANAGEMENT, "MANAGEMENT: %s", BSTR (&out));
if (flags & LOG_PRINT_CRLF)
buf_printf (&out, "\r\n");
return BSTR (&out);
diff --git a/manage.h b/manage.h
index 1a776c3..c7cce07 100644
--- a/manage.h
+++ b/manage.h
@@ -117,6 +117,8 @@ struct log_entry
#define LOG_PRINT_REMOTE_IP (1<<10)
+#define LOG_ECHO_TO_LOG (1<<11)
+
const char *log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena *gc);
struct log_history
@@ -331,6 +333,8 @@ management_query_user_pass_enabled (const struct management *man)
#define OPENVPN_STATE_WAIT 7 /* Waiting for initial response from server */
#define OPENVPN_STATE_AUTH 8 /* Authenticating with server */
#define OPENVPN_STATE_GET_CONFIG 9 /* Downloading configuration from server */
+#define OPENVPN_STATE_RESOLVE 10 /* DNS lookup */
+#define OPENVPN_STATE_TCP_CONNECT 11 /* Connecting to TCP server */
#define OPENVPN_STATE_CLIENT_BASE 7 /* Base index of client-only states */
diff --git a/socket.c b/socket.c
index 6fd2673..96e0562 100644
--- a/socket.c
+++ b/socket.c
@@ -37,6 +37,7 @@
#include "gremlin.h"
#include "plugin.h"
#include "ps.h"
+#include "manage.h"
#include "memdbg.h"
@@ -112,6 +113,18 @@ getaddr (unsigned int flags,
goto done;
}
+#ifdef ENABLE_MANAGEMENT
+ if (flags & GETADDR_UPDATE_MANAGEMENT_STATE)
+ {
+ if (management)
+ management_set_state (management,
+ OPENVPN_STATE_RESOLVE,
+ NULL,
+ (in_addr_t)0,
+ (in_addr_t)0);
+ }
+#endif
+
/*
* Resolve hostname
*/
@@ -243,7 +256,7 @@ update_remote (const char* host,
if (host && addr)
{
const in_addr_t new_addr = getaddr (
- GETADDR_RESOLVE,
+ GETADDR_RESOLVE|GETADDR_UPDATE_MANAGEMENT_STATE,
host,
1,
NULL,
@@ -817,6 +830,15 @@ socket_connect (socket_descriptor_t *sd,
{
int status;
+#ifdef ENABLE_MANAGEMENT
+ if (management)
+ management_set_state (management,
+ OPENVPN_STATE_TCP_CONNECT,
+ NULL,
+ (in_addr_t)0,
+ (in_addr_t)0);
+#endif
+
status = openvpn_connect (*sd, remote, connect_timeout, signal_received);
get_signal (signal_received);
@@ -962,13 +984,12 @@ resolve_remote (struct link_socket *sock,
if (sock->remote_host)
{
- unsigned int flags = 0;
+ unsigned int flags = GETADDR_RESOLVE|GETADDR_UPDATE_MANAGEMENT_STATE;
int retry = 0;
bool status = false;
if (remote_list_len (sock->remote_list) > 1 && sock->resolve_retry_seconds == RESOLV_RETRY_INFINITE)
{
- flags = GETADDR_RESOLVE;
if (phase == 2)
flags |= (GETADDR_TRY_ONCE | GETADDR_FATAL);
retry = 0;
@@ -977,12 +998,11 @@ resolve_remote (struct link_socket *sock,
{
if (sock->resolve_retry_seconds)
{
- flags = GETADDR_RESOLVE;
retry = 0;
}
else
{
- flags = GETADDR_RESOLVE | GETADDR_FATAL | GETADDR_MENTION_RESOLVE_RETRY;
+ flags |= (GETADDR_FATAL | GETADDR_MENTION_RESOLVE_RETRY);
retry = 0;
}
}
@@ -990,7 +1010,7 @@ resolve_remote (struct link_socket *sock,
{
if (sock->resolve_retry_seconds)
{
- flags = GETADDR_RESOLVE | GETADDR_FATAL;
+ flags |= GETADDR_FATAL;
retry = sock->resolve_retry_seconds;
}
else
diff --git a/socket.h b/socket.h
index f440659..f0d9a43 100644
--- a/socket.h
+++ b/socket.h
@@ -424,6 +424,7 @@ socket_descriptor_t socket_do_accept (socket_descriptor_t sd,
#define GETADDR_WARN_ON_SIGNAL (1<<5)
#define GETADDR_MSG_VIRT_OUT (1<<6)
#define GETADDR_TRY_ONCE (1<<7)
+#define GETADDR_UPDATE_MANAGEMENT_STATE (1<<8)
in_addr_t getaddr (unsigned int flags,
const char *hostname,