/* link_socket_mode allows CM_CHILD_TCP
instances to inherit acceptable fds
from a top-level parent */
+ if (c->options.ce.proto == PROTO_TCPv4_SERVER
#ifdef USE_PF_INET6
- if (c->options.ce.proto == PROTO_TCPv4_SERVER || c->options.ce.proto == PROTO_TCPv6_SERVER)
-#else
- if (c->options.ce.proto == PROTO_TCPv4_SERVER)
+ || c->options.ce.proto == PROTO_TCPv6_SERVER
#endif
+ )
{
if (c->mode == CM_TOP)
link_socket_mode = LS_MODE_TCP_LISTEN;
}
}
}
-#else /* old pre IPV6 1-line code: */
+#else /* old, pre USE_PF_INET6 code */
buf_printf (&out, "IPV6");
#endif
break;
else
tunnel_server_tcp(top);
#else
- switch (top->options.ce.proto) {
- case PROTO_UDPv4:
- tunnel_server_udp (top);
- break;
- case PROTO_TCPv4_SERVER:
- tunnel_server_tcp (top);
- break;
- default:
- ASSERT (0);
- }
+ switch (top->options.ce.proto)
+ {
+ case PROTO_UDPv4:
+ tunnel_server_udp (top);
+ break;
+ case PROTO_TCPv4_SERVER:
+ tunnel_server_tcp (top);
+ break;
+ default:
+ ASSERT (0);
+ }
#endif
}
" p = udp (default), tcp-server, or tcp-client\n"
"--proto-force p : only consider protocol p in list of connection profiles.\n"
#ifdef USE_PF_INET6
- " p = udp6, tcp6-server, or tcp6-client (IPv6)\n"
+ " p = udp6, tcp6-server, or tcp6-client (ipv6)\n"
#endif
"--connect-retry n : For --proto tcp-client, number of seconds to wait\n"
" between connection retries (default=%d).\n"
* Sanity check on TCP mode options
*/
- if (ce->connect_retry_defined && ce->proto != PROTO_TCPv4_CLIENT && ce->proto != PROTO_TCPv6_CLIENT)
+ if (ce->connect_retry_defined && ce->proto != PROTO_TCPv4_CLIENT
+#ifdef USE_PF_INET6
+ && ce->proto != PROTO_TCPv6_CLIENT
+#endif
+ )
msg (M_USAGE, "--connect-retry doesn't make sense unless also used with --proto tcp-client");
- if (ce->connect_timeout_defined && ce->proto != PROTO_TCPv4_CLIENT && ce->proto != PROTO_TCPv6_CLIENT)
+ 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, "--explicit-exit-notify can only be used with --proto udp");
#endif
- if (!ce->remote && (ce->proto == PROTO_TCPv4_CLIENT || ce->proto == PROTO_TCPv6_CLIENT))
+ if (!ce->remote && (ce->proto == PROTO_TCPv4_CLIENT
+#ifdef USE_PF_INET6
+ || ce->proto == PROTO_TCPv6_CLIENT
+#endif
+ ))
msg (M_USAGE, "--remote MUST be used in TCP Client mode");
#ifdef ENABLE_HTTP_PROXY
msg (M_USAGE, "--socks-proxy can not be used in TCP Server mode");
#endif
- if ((ce->proto == PROTO_TCPv4_SERVER || ce->proto == PROTO_TCPv6_SERVER)
+ if ((ce->proto == PROTO_TCPv4_SERVER
+#ifdef USE_PF_INET6
+ || ce->proto == PROTO_TCPv6_SERVER
+#endif
+ )
&& connection_list_defined (options))
msg (M_USAGE, "TCP server mode allows at most one --remote address");
msg (M_USAGE, "--mode server only works with --dev tun or --dev tap");
if (options->pull)
msg (M_USAGE, "--pull cannot be used with --mode server");
- if (!(proto_is_udp(ce->proto) || ce->proto == PROTO_TCPv4_SERVER || ce->proto == PROTO_TCPv6_SERVER))
+ if (!(proto_is_udp(ce->proto) || ce->proto == PROTO_TCPv4_SERVER
+#ifdef USE_PF_INET6
+ || ce->proto == PROTO_TCPv6_SERVER
+#endif
+ ))
msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server");
#if PORT_SHARE
if ((options->port_share_host || options->port_share_port) &&
- (ce->proto != PROTO_TCPv4_SERVER && ce->proto != PROTO_TCPv6_SERVER))
+ (ce->proto != PROTO_TCPv4_SERVER
+#ifdef USE_PF_INET6
+ && ce->proto != PROTO_TCPv6_SERVER
+#endif
+ ))
msg (M_USAGE, "--port-share only works in TCP server mode (--proto tcp-server)");
#endif
if (!options->tls_server)
msg (M_USAGE, "--inetd cannot be used with --mode server");
if (options->ipchange)
msg (M_USAGE, "--ipchange cannot be used with --mode server (use --client-connect instead)");
- if (!(proto_is_dgram(ce->proto) || ce->proto == PROTO_TCPv4_SERVER || ce->proto == PROTO_TCPv6_SERVER ))
+ if (!(proto_is_dgram(ce->proto) || ce->proto == PROTO_TCPv4_SERVER
+#ifdef USE_PF_INET6
+ || ce->proto == PROTO_TCPv6_SERVER
+#endif
+ ))
msg (M_USAGE, "--mode server currently only supports --proto udp or --proto tcp-server");
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.");
/* resolve local address if undefined */
if (!addr_defined (&sock->info.lsa->local))
{
+#ifdef USE_PF_INET6
/* may return AF_{INET|INET6} guessed from local_host */
switch(addr_guess_family(sock->info.proto, sock->local_host))
{
case AF_INET:
+#endif
sock->info.lsa->local.addr.in4.sin_family = AF_INET;
sock->info.lsa->local.addr.in4.sin_addr.s_addr =
(sock->local_host ? getaddr (GETADDR_RESOLVE | GETADDR_WARN_ON_SIGNAL | GETADDR_FATAL,
NULL)
: htonl (INADDR_ANY));
sock->info.lsa->local.addr.in4.sin_port = htons (sock->local_port);
- break;
#ifdef USE_PF_INET6
+ break;
case AF_INET6:
{
int success;
sock->info.lsa->local.addr.in6.sin6_port = htons (sock->local_port);
}
break;
-#endif
}
+#endif /* USE_PF_INET6 */
}
/* bind to local address/port */
/* TCP client/server */
if (sock->info.proto == PROTO_TCPv4_SERVER
#ifdef USE_PF_INET6
- ||sock->info.proto == PROTO_TCPv6_SERVER
+ ||sock->info.proto == PROTO_TCPv6_SERVER
#endif
)
{
}
else if (sock->info.proto == PROTO_TCPv4_CLIENT
#ifdef USE_PF_INET6
- ||sock->info.proto == PROTO_TCPv6_CLIENT
+ ||sock->info.proto == PROTO_TCPv6_CLIENT
#endif
)
{
* by now just ignore it
*
*/
-#if defined ( USE_PF_INET6 )
+#ifdef USE_PF_INET6
if(lsa->actual.dest.addr.sa.sa_family != AF_INET)
return 0;
#else
#if ENABLE_IP_PKTINFO
if ((flags & PS_SHOW_PKTINFO) && addr_defined_ipi(act))
{
+#ifdef USE_PF_INET6
switch(act->dest.addr.sa.sa_family)
{
case AF_INET:
+#endif
{
struct openvpn_sockaddr sa;
CLEAR (sa);
sa.addr.in4.sin_addr = act->pi.in4.ipi_spec_dst;
buf_printf (&out, " (via %s)", print_sockaddr_ex (&sa, separator, 0, gc));
}
- break;
#ifdef USE_PF_INET6
+ break;
case AF_INET6:
{
struct sockaddr_in6 sin6;
}
}
break;
-#endif
}
+#endif /* USE_PF_INET6 */
}
#endif
addr_guess_family(int proto, const char *name)
{
sa_family_t ret;
- if (proto) {
- return proto_sa_family(proto); /* already stamped */
- }
+ if (proto)
+ {
+ return proto_sa_family(proto); /* already stamped */
+ }
#ifdef USE_PF_INET6
- else {
- struct addrinfo hints , *ai;
- int err;
- memset(&hints, 0, sizeof hints);
- hints.ai_flags=AI_NUMERICHOST;
- err = getaddrinfo(name, NULL, &hints, &ai);
- if ( 0 == err )
- {
- ret=ai->ai_family;
- freeaddrinfo(ai);
- return ret;
- }
- }
+ else
+ {
+ struct addrinfo hints , *ai;
+ int err;
+ memset(&hints, 0, sizeof hints);
+ hints.ai_flags=AI_NUMERICHOST;
+ err = getaddrinfo(name, NULL, &hints, &ai);
+ if ( 0 == err )
+ {
+ ret=ai->ai_family;
+ freeaddrinfo(ai);
+ return ret;
+ }
+ }
#endif
return AF_INET; /* default */
}
const char *
addr_family_name (int af)
{
- switch (af) {
- case AF_INET: return "AF_INET";
+ switch (af)
+ {
+ case AF_INET: return "AF_INET";
case AF_INET6: return "AF_INET6";
- }
+ }
return "AF_UNSPEC";
}
* Transport protocol naming and other details.
*/
-#if 0 /* PRE UDPv6/TCPv6 code */
-#define PROTO_NONE 0 /* catch for uninitialized */
-#define PROTO_UDPv4 1
-#define PROTO_TCPv4_SERVER 2
-#define PROTO_TCPv4_CLIENT 3
-#define PROTO_TCPv4 4
-#define PROTO_UDPv6 5
-#define PROTO_TCPv6_SERVER 6
-#define PROTO_TCPv6_CLIENT 7
-#define PROTO_TCPv6 8
-#define PROTO_N 9
-#endif /* if 0 */
-
/*
* Use enum's instead of #define to allow for easier
* optional proto support
PROTO_TCPv4_SERVER,
PROTO_TCPv4_CLIENT,
PROTO_TCPv4,
+#ifdef USE_PF_INET6
PROTO_UDPv6,
PROTO_TCPv6_SERVER,
PROTO_TCPv6_CLIENT,
PROTO_TCPv6,
+#endif
PROTO_N
};