… | |
… | |
113 | sprintf (hostport, "%.15s", inet_ntoa (ia)); |
113 | sprintf (hostport, "%.15s", inet_ntoa (ia)); |
114 | |
114 | |
115 | return hostport; |
115 | return hostport; |
116 | } |
116 | } |
117 | |
117 | |
|
|
118 | bool |
|
|
119 | sockinfo::valid () const |
|
|
120 | { |
|
|
121 | return (prot & THISNODE->protocols) && host; |
|
|
122 | } |
|
|
123 | |
118 | sockinfo::operator const char *() const |
124 | sockinfo::operator const char *() const |
119 | { |
125 | { |
120 | in_addr ia = { host }; |
126 | in_addr ia = { host }; |
121 | |
127 | |
122 | sprintf (hostport, "%s/%.15s:%d", strprotocol (prot), inet_ntoa (ia), ntohs (port) & 0xffff); |
128 | sprintf (hostport, "%s/%.15s:%d", strprotocol (prot), inet_ntoa (ia), ntohs (port) & 0xffff); |
… | |
… | |
127 | u8 |
133 | u8 |
128 | sockinfo::supported_protocols (conf_node *conf) |
134 | sockinfo::supported_protocols (conf_node *conf) |
129 | { |
135 | { |
130 | u8 protocols = prot; |
136 | u8 protocols = prot; |
131 | |
137 | |
132 | if (prot & (PROT_UDPv4 | PROT_TCPv4)) |
138 | if (prot & (PROT_IPv4 | PROT_ICMPv4 | PROT_UDPv4 | PROT_TCPv4)) |
133 | protocols |= PROT_IPv4 | PROT_ICMPv4; |
139 | protocols |= PROT_IPv4 | PROT_ICMPv4; |
134 | |
140 | |
135 | if (conf |
|
|
136 | && prot & PROTv4 |
141 | if (conf && prot & PROTv4) |
137 | && conf->protocols & PROT_UDPv4 |
142 | { |
138 | && conf->udp_port) |
143 | if (conf->protocols & PROT_UDPv4 && conf->udp_port) |
139 | protocols |= PROT_UDPv4; |
144 | protocols |= PROT_UDPv4; |
140 | |
145 | |
141 | if (conf |
146 | if (conf->protocols & PROT_TCPv4 && conf->tcp_port) |
142 | && prot & PROTv4 |
|
|
143 | && conf->protocols & PROT_TCPv4 |
|
|
144 | && conf->tcp_port) |
|
|
145 | protocols |= PROT_TCPv4; |
147 | protocols |= PROT_TCPv4; |
146 | |
148 | |
147 | if (conf |
149 | if (conf->protocols & PROT_DNSv4 && conf->dns_port) |
148 | && prot & PROTv4 |
|
|
149 | && conf->protocols & PROT_DNSv4 |
|
|
150 | && conf->dns_port) |
|
|
151 | protocols |= PROT_DNSv4; |
150 | protocols |= PROT_DNSv4; |
|
|
151 | } |
152 | |
152 | |
153 | return protocols; |
153 | return protocols; |
154 | } |
154 | } |
155 | |
155 | |
156 | bool |
156 | bool |