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>
... | ... |
@@ -2905,7 +2905,7 @@ options_string (const struct options *o, |
2905 | 2905 |
buf_printf (&out, ",dev-type %s", dev_type_string (o->dev, o->dev_type)); |
2906 | 2906 |
buf_printf (&out, ",link-mtu %d", EXPANDED_SIZE (frame)); |
2907 | 2907 |
buf_printf (&out, ",tun-mtu %d", PAYLOAD_SIZE (frame)); |
2908 |
- buf_printf (&out, ",proto %s", proto2ascii (proto_remote (o->ce.proto, remote),o->ce.af, true)); |
|
2908 |
+ buf_printf (&out, ",proto %s", proto_remote (o->ce.proto, remote)); |
|
2909 | 2909 |
|
2910 | 2910 |
/* send tun_ipv6 only in peer2peer mode - in client/server mode, it |
2911 | 2911 |
* is usually pushed by the server, triggering a non-helpful warning |
... | ... |
@@ -2599,19 +2599,21 @@ addr_family_name (int af) |
2599 | 2599 |
* has always sent UDPv4, TCPv4 over the wire. Keep these |
2600 | 2600 |
* strings for backward compatbility |
2601 | 2601 |
*/ |
2602 |
-int |
|
2602 |
+const char* |
|
2603 | 2603 |
proto_remote (int proto, bool remote) |
2604 | 2604 |
{ |
2605 | 2605 |
ASSERT (proto >= 0 && proto < PROTO_N); |
2606 |
- if (remote) |
|
2607 |
- { |
|
2608 |
- switch (proto) |
|
2609 |
- { |
|
2610 |
- case PROTO_TCP_SERVER: return PROTO_TCP_CLIENT; |
|
2611 |
- case PROTO_TCP_CLIENT: return PROTO_TCP_SERVER; |
|
2612 |
- } |
|
2613 |
- } |
|
2614 |
- return proto; |
|
2606 |
+ if (proto == PROTO_UDP) |
|
2607 |
+ return "UDPv4"; |
|
2608 |
+ |
|
2609 |
+ if ( (remote && proto == PROTO_TCP_CLIENT) || |
|
2610 |
+ (!remote && proto == PROTO_TCP_SERVER)) |
|
2611 |
+ return "TCPv4_SERVER"; |
|
2612 |
+ if ( (remote && proto == PROTO_TCP_SERVER) || |
|
2613 |
+ (!remote && proto == PROTO_TCP_CLIENT)) |
|
2614 |
+ return "TCPv4_CLIENT"; |
|
2615 |
+ |
|
2616 |
+ ASSERT (0); |
|
2615 | 2617 |
} |
2616 | 2618 |
|
2617 | 2619 |
/* |
... | ... |
@@ -532,7 +532,7 @@ int ascii2proto (const char* proto_name); |
532 | 532 |
sa_family_t ascii2af (const char* proto_name); |
533 | 533 |
const char *proto2ascii (int proto, sa_family_t af, bool display_form); |
534 | 534 |
const char *proto2ascii_all (struct gc_arena *gc); |
535 |
-int proto_remote (int proto, bool remote); |
|
535 |
+const char *proto_remote (int proto, bool remote); |
|
536 | 536 |
const char *addr_family_name(int af); |
537 | 537 |
|
538 | 538 |
/* |