--- gvpe/src/sockinfo.C 2011/02/08 23:11:36 1.24 +++ gvpe/src/sockinfo.C 2012/01/17 21:38:11 1.28 @@ -115,6 +115,12 @@ return hostport; } +bool +sockinfo::valid () const +{ + return (prot & THISNODE->protocols) && host; +} + sockinfo::operator const char *() const { in_addr ia = { host }; @@ -129,26 +135,20 @@ { u8 protocols = prot; - if (prot & (PROT_UDPv4 | PROT_TCPv4)) + if (prot & (PROT_IPv4 | PROT_ICMPv4 | PROT_UDPv4 | PROT_TCPv4)) protocols |= PROT_IPv4 | PROT_ICMPv4; - if (conf - && prot & PROTv4 - && conf->protocols & PROT_UDPv4 - && conf->udp_port) - protocols |= PROT_UDPv4; - - if (conf - && prot & PROTv4 - && conf->protocols & PROT_TCPv4 - && conf->tcp_port) - protocols |= PROT_TCPv4; - - if (conf - && prot & PROTv4 - && conf->protocols & PROT_DNSv4 - && conf->dns_port) - protocols |= PROT_DNSv4; + if (conf && prot & PROTv4) + { + if (conf->protocols & PROT_UDPv4 && conf->udp_port) + protocols |= PROT_UDPv4; + + if (conf->protocols & PROT_TCPv4 && conf->tcp_port) + protocols |= PROT_TCPv4; + + if (conf->protocols & PROT_DNSv4 && conf->dns_port) + protocols |= PROT_DNSv4; + } return protocols; }