]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Change proto_remote() function to return a constant string
authorArne Schwabe <arne@rfc2549.org>
Mon, 25 Nov 2013 12:31:13 +0000 (13:31 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 26 Nov 2013 14:34:59 +0000 (15:34 +0100)
Instead of using the implicit protocol string that is returned by the
proto/af to names function return a constant string. The strings have
become part of the wire protocl and we do not want them to change if
the printing of proto/af changes.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1385382680-5912-2-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8055

Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/options.c
src/openvpn/socket.c
src/openvpn/socket.h

index 2543ca52614290807ceb4b7ffcbfa7ddaf7a66aa..809bfa0525ad49331b5c83e18aed08c5e53524b8 100644 (file)
@@ -2905,7 +2905,7 @@ options_string (const struct options *o,
   buf_printf (&out, ",dev-type %s", dev_type_string (o->dev, o->dev_type));
   buf_printf (&out, ",link-mtu %d", EXPANDED_SIZE (frame));
   buf_printf (&out, ",tun-mtu %d", PAYLOAD_SIZE (frame));
-  buf_printf (&out, ",proto %s", proto2ascii (proto_remote (o->ce.proto, remote),o->ce.af, true));
+  buf_printf (&out, ",proto %s",  proto_remote (o->ce.proto, remote));
 
   /* send tun_ipv6 only in peer2peer mode - in client/server mode, it
    * is usually pushed by the server, triggering a non-helpful warning
index f0e091432b51249b35c2652b37ded06a00af4af8..1117e30dd835e17bf4f700a851d3aca825deb9ec 100644 (file)
@@ -2599,19 +2599,21 @@ addr_family_name (int af)
  * has always sent UDPv4, TCPv4 over the wire. Keep these
  * strings for backward compatbility
  */
-int
+const char*
 proto_remote (int proto, bool remote)
 {
   ASSERT (proto >= 0 && proto < PROTO_N);
-  if (remote)
-    {
-      switch (proto)
-      {
-       case PROTO_TCP_SERVER: return PROTO_TCP_CLIENT;
-       case PROTO_TCP_CLIENT: return PROTO_TCP_SERVER;
-      }
-    }
-  return proto;
+  if (proto == PROTO_UDP)
+       return "UDPv4";
+
+  if ( (remote && proto == PROTO_TCP_CLIENT) ||
+       (!remote && proto == PROTO_TCP_SERVER))
+       return "TCPv4_SERVER";
+  if ( (remote && proto == PROTO_TCP_SERVER) ||
+       (!remote && proto == PROTO_TCP_CLIENT))
+       return "TCPv4_CLIENT";
+
+  ASSERT (0);
 }
 
 /*
index 223c70dfdcef177b139d47867174d9fc8bb77e85..a41a3d979b423df327e4abe419881d9732946b9d 100644 (file)
@@ -532,7 +532,7 @@ int ascii2proto (const char* proto_name);
 sa_family_t ascii2af (const char* proto_name);
 const char *proto2ascii (int proto, sa_family_t af, bool display_form);
 const char *proto2ascii_all (struct gc_arena *gc);
-int proto_remote (int proto, bool remote);
+const char *proto_remote (int proto, bool remote);
 const char *addr_family_name(int af);
 
 /*