- case SUBNET_IPV4: fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\"\n", subnet_str); break;
- case SUBNET_IPV6: fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\"\n", subnet_str); break;
+ case SUBNET_IPV4:
+ fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\"\n", subnet_str);
+ break;
+
+ case SUBNET_IPV6:
+ fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\"\n", subnet_str);
+ break;
+
+ default:
+ return;
+ }
+ }
+
+#else // assume BSD
+
+ if(!*gateway_str) {
+ switch(subnet.type) {
+ case SUBNET_IPV4:
+ if(!ipv4.type) {
+ fprintf(stderr, "Route requested but no Ifconfig\n");
+ return;
+ }
+
+ net2str(gateway_str, sizeof(gateway_str), &ipv4);
+ break;
+
+ case SUBNET_IPV6:
+ if(!ipv6.type) {
+ fprintf(stderr, "Route requested but no Ifconfig\n");
+ return;
+ }
+
+ net2str(gateway_str, sizeof(gateway_str), &ipv6);
+ break;
+
+ default:
+ return;
+ }
+
+ char *slash = strchr(gateway_str, '/');
+
+ if(slash) {
+ *slash = 0;