]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
* no new funcionality, just small cleanups:
authorJuanJo Ciarlante <jjo@google.com>
Tue, 20 Oct 2009 20:38:50 +0000 (22:38 +0200)
committerJuanJo Ciarlante <juanjosec@gmail.com>
Fri, 25 Mar 2011 12:30:30 +0000 (13:30 +0100)
- cmdline options help: add tcp6/udp6 missing messages
- win32: expand usage of proto_is_udp(), proto_is_tcp()
- replace some memset(&obj, 0, sizeof obj) by openvpn's CLEAR(obj)

TODO.ipv6
mroute.c
options.c
socket.c

index dbf539efac4b50a920eb851f6580d9b3a3cae017..565cbf62134f5619e9135562eef3c317a84aa29d 100644 (file)
--- a/TODO.ipv6
+++ b/TODO.ipv6
@@ -1,3 +1,5 @@
+[ Last updated: 20-Oct-2009. ]
+
 * All platforms:
   o mgmt console: as currently passes straight in_addr_t bits around
 
@@ -5,6 +7,8 @@
     use ipv4/6 if DNS returns A/AAAA without specifying protocol.
     Hard: requires deep changes in initialization/calling logic
 
+  o use AI_PASSIVE
+
   o the getaddr()/getaddr6() interface is not prepared for handling socktype
     "tagging", currently I abuse the sockflags bits for getting the ai_socktype
     downstream.
index a2c66f3c11c6a0fc622e1c2bc5d31bf3cf7731ff..56e01a2f8698663232c6d67f2a3d1014168aed75 100644 (file)
--- a/mroute.c
+++ b/mroute.c
@@ -365,7 +365,7 @@ mroute_addr_print_ex (const struct mroute_addr *ma,
            struct sockaddr_in6 sin6;
            int port;
            char buf6[INET6_ADDRSTRLEN] = "";
-           memset(&sin6, 0, sizeof sin6);
+           CLEAR(sin6);
            sin6.sin6_family = AF_INET6;
            buf_set_read (&buf, maddr.addr, maddr.len);
             if (buf_read(&buf, &sin6.sin6_addr, sizeof (sin6.sin6_addr)))
index ea42f3cb914e5f20f8528f523bb89e21941ccb03..83017b81432df8f3bcce4689dfc658e5e93595b2 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1708,14 +1708,22 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
       && ce->proto != PROTO_TCPv6_CLIENT
 #endif
       )
-    msg (M_USAGE, "--connect-retry doesn't make sense unless also used with --proto tcp-client");
+    msg (M_USAGE, "--connect-retry doesn't make sense unless also used with --proto tcp-client"
+#ifdef USE_PF_INET6
+        " or tcp6-client"
+#endif
+        );
 
   if (ce->connect_timeout_defined && ce->proto != PROTO_TCPv4_CLIENT
 #ifdef USE_PF_INET6
       && ce->proto != PROTO_TCPv6_CLIENT
 #endif
       )
-    msg (M_USAGE, "--connect-timeout doesn't make sense unless also used with --proto tcp-client");
+    msg (M_USAGE, "--connect-timeout doesn't make sense unless also used with --proto tcp-client"
+#ifdef USE_PF_INET6
+        " or tcp6-client"
+#endif
+        );
 
   /*
    * Sanity check on MTU parameters
@@ -1858,7 +1866,11 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
            || ce->proto == PROTO_TCPv6_SERVER
 #endif
            ))
-       msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server");
+       msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server"
+#ifdef USE_PF_INET6
+           " or proto tcp6-server"
+#endif
+            );
 #if PORT_SHARE
       if ((options->port_share_host || options->port_share_port) && 
             (ce->proto != PROTO_TCPv4_SERVER
@@ -1866,7 +1878,11 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
             && ce->proto != PROTO_TCPv6_SERVER
 #endif
             ))
-       msg (M_USAGE, "--port-share only works in TCP server mode (--proto tcp-server)");
+       msg (M_USAGE, "--port-share only works in TCP server mode (--proto tcp-server"
+#ifdef USE_PF_INET6
+            " or tcp6-server"
+#endif
+         ")");
 #endif
       if (!options->tls_server)
        msg (M_USAGE, "--mode server requires --tls-server");
@@ -1899,7 +1915,11 @@ options_postprocess_verify_ce (const struct options *options, const struct conne
            || ce->proto == PROTO_TCPv6_SERVER
 #endif
            ))
-       msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server");
+       msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server"
+#ifdef USE_PF_INET6
+           " or --proto tcp6-server"
+#endif
+            );
       if (!proto_is_udp(ce->proto) && (options->cf_max || options->cf_per))
        msg (M_USAGE, "--connect-freq only works with --mode server --proto udp.  Try --max-clients instead.");
       if (!(dev == DEV_TYPE_TAP || (dev == DEV_TYPE_TUN && options->topology == TOP_SUBNET)) && options->ifconfig_pool_netmask)
index 52b7b68846fe7d3356bde6b38c5ca66b7500913b..bade47e1f79b3f6b8a45fcccad602153a88222ef 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -2146,10 +2146,10 @@ link_socket_current_remote (const struct link_socket_info *info)
  *
  */
 #ifdef USE_PF_INET6
-  if(lsa->actual.dest.addr.sa.sa_family != AF_INET)
+  if (lsa->actual.dest.addr.sa.sa_family != AF_INET)
     return 0;
 #else
-  ASSERT(lsa->actual.dest.addr.sa.sa_family == AF_INET);
+  ASSERT (lsa->actual.dest.addr.sa.sa_family == AF_INET);
 #endif
 
   if (link_socket_actual_defined (&lsa->actual))
@@ -2475,7 +2475,7 @@ print_link_socket_actual_ex (const struct link_socket_actual *act,
                {
                  struct sockaddr_in6 sin6;
                  char buf[INET6_ADDRSTRLEN] = "[undef]";
-                 memset(&sin6, 0, sizeof sin6);
+                 CLEAR(sin6);
                  sin6.sin6_family = AF_INET6;
                  sin6.sin6_addr = act->pi.in6.ipi6_addr;
                    {
@@ -2699,8 +2699,8 @@ addr_guess_family(int proto, const char *name)
     {
       struct addrinfo hints , *ai;
       int err;
-      memset(&hints, 0, sizeof hints);
-      hints.ai_flags=AI_NUMERICHOST;
+      CLEAR(hints);
+      hints.ai_flags = AI_NUMERICHOST;
       err = getaddrinfo(name, NULL, &hints, &ai);
       if ( 0 == err )
        {
@@ -3001,19 +3001,11 @@ socket_recv_queue (struct link_socket *sock, int maxsize)
       int status;
 
       /* reset buf to its initial state */
-      if (sock->info.proto == PROTO_UDPv4
-#ifdef USE_PF_INET6
-          || sock->info.proto == PROTO_UDPv6
-#endif
-        )
+      if (proto_is_udp(sock->info.proto))
        {
          sock->reads.buf = sock->reads.buf_init;
        }
-      else if (sock->info.proto == PROTO_TCPv4_CLIENT || sock->info.proto == PROTO_TCPv4_SERVER
-#ifdef USE_PF_INET6
-              || sock->info.proto == PROTO_TCPv6_CLIENT || sock->info.proto == PROTO_TCPv6_SERVER
-#endif
-              )
+      else if (proto_is_tcp(sock->info.proto))
        {
          stream_buf_get_next (&sock->stream_buf, &sock->reads.buf);
        }
@@ -3033,11 +3025,7 @@ socket_recv_queue (struct link_socket *sock, int maxsize)
       ASSERT (ResetEvent (sock->reads.overlapped.hEvent));
       sock->reads.flags = 0;
 
-      if (sock->info.proto == PROTO_UDPv4
-#ifdef USE_PF_INET6
-          || sock->info.proto == PROTO_UDPv6
-#endif
-         )
+      if (proto_is_udp(sock->info.proto))
        {
          sock->reads.addr_defined = true;
 #ifdef USE_PF_INET6
@@ -3057,12 +3045,7 @@ socket_recv_queue (struct link_socket *sock, int maxsize)
                               &sock->reads.overlapped,
                               NULL);
        }
-      else if (sock->info.proto == PROTO_TCPv4_CLIENT || sock->info.proto == PROTO_TCPv4_SERVER
-#ifdef USE_PF_INET6
-              || sock->info.proto == PROTO_TCPv6_CLIENT || sock->info.proto == PROTO_TCPv6_SERVER
-#endif
-              )
-
+      else if (proto_is_tcp(sock->info.proto))
        {
          sock->reads.addr_defined = false;
          status = WSARecv(
@@ -3148,11 +3131,7 @@ socket_send_queue (struct link_socket *sock, struct buffer *buf, const struct li
       ASSERT (ResetEvent (sock->writes.overlapped.hEvent));
       sock->writes.flags = 0;
 
-      if (sock->info.proto == PROTO_UDPv4
-#ifdef USE_PF_INET6
-         || sock->info.proto == PROTO_UDPv6
-#endif
-        )
+      if (proto_is_udp(sock->info.proto))
        {
          /* set destination address for UDP writes */
          sock->writes.addr_defined = true;
@@ -3180,11 +3159,7 @@ socket_send_queue (struct link_socket *sock, struct buffer *buf, const struct li
                               &sock->writes.overlapped,
                               NULL);
        }
-      else if (sock->info.proto == PROTO_TCPv4_CLIENT || sock->info.proto == PROTO_TCPv4_SERVER
-#ifdef USE_PF_INET6
-              || sock->info.proto == PROTO_TCPv6_CLIENT || sock->info.proto == PROTO_TCPv6_SERVER
-#endif
-             )
+      else if (proto_is_tcp(sock->info.proto))
        {
          /* destination address for TCP writes was established on connection initiation */
          sock->writes.addr_defined = false;