--- gvpe/src/conf.C 2003/03/28 04:05:10 1.5 +++ gvpe/src/conf.C 2003/04/02 21:02:25 1.10 @@ -53,6 +53,24 @@ struct configuration conf; +u8 best_protocol (u8 protset) +{ + if (protset & PROT_IPv4 ) return PROT_IPv4; + if (protset & PROT_UDPv4) return PROT_UDPv4; + if (protset & PROT_TCPv4) return PROT_TCPv4; + + return 0; +} + +const char *strprotocol (u8 protocol) +{ + if (protocol & PROT_IPv4 ) return "rawip"; + if (protocol & PROT_UDPv4) return "udp"; + if (protocol & PROT_TCPv4) return "tcp"; + + return ""; +} + configuration::configuration () { init (); @@ -73,10 +91,10 @@ ip_proto = IPPROTO_GRE; default_node.udp_port = DEFAULT_UDPPORT; + default_node.tcp_port = DEFAULT_UDPPORT; default_node.connectmode = conf_node::C_ALWAYS; default_node.compress = true; - default_node.can_send = PROT_UDPv4; - default_node.can_recv = PROT_IPv4; + default_node.protocols = PROT_UDPv4; } void configuration::cleanup() @@ -267,6 +285,8 @@ /* node-specific, defaultable */ else if (!strcmp (var, "udp-port")) node->udp_port = atoi (val); + else if (!strcmp (var, "tcp-port")) + node->tcp_port = atoi (val); else if (!strcmp (var, "router-priority")) node->routerprio = atoi (val); else if (!strcmp (var, "connect")) @@ -293,21 +313,17 @@ parse_bool (node->compress, "compress", true, false); } // all these bool options really really cost a lot of executable size! - else if (!strcmp (var, "can-send-udp")) - { - u8 v; parse_bool (v, "can-send-udp", PROT_UDPv4, 0); node->can_send = (node->can_send & ~PROT_UDPv4) | v; - } - else if (!strcmp (var, "can-recv-udp")) + else if (!strcmp (var, "enable-tcp")) { - u8 v; parse_bool (v, "can-recv-udp", PROT_UDPv4, 0); node->can_recv = (node->can_recv & ~PROT_UDPv4) | v; + u8 v; parse_bool (v, "enable-tcp" , PROT_TCPv4, 0); node->protocols = (node->protocols & ~PROT_TCPv4) | v; } - else if (!strcmp (var, "can-send-rawip")) + else if (!strcmp (var, "enable-udp")) { - u8 v; parse_bool (v, "can-send-rawip", PROT_IPv4, 0); node->can_send = (node->can_send & ~PROT_IPv4) | v; + u8 v; parse_bool (v, "enable-udp" , PROT_UDPv4, 0); node->protocols = (node->protocols & ~PROT_UDPv4) | v; } - else if (!strcmp (var, "can-recv-rawip")) + else if (!strcmp (var, "enable-rawip")) { - u8 v; parse_bool (v, "can-recv-rawip", PROT_IPv4, 0); node->can_recv = (node->can_recv & ~PROT_IPv4) | v; + u8 v; parse_bool (v, "enable-rawip", PROT_IPv4, 0); node->protocols = (node->protocols & ~PROT_IPv4 ) | v; } // unknown or misplaced