ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/sockinfo.C
(Generate patch)

Comparing gvpe/src/sockinfo.C (file contents):
Revision 1.12 by pcg, Fri Apr 2 14:42:45 2004 UTC vs.
Revision 1.14 by pcg, Thu Mar 3 07:24:57 2005 UTC

25 25
26#include "sockinfo.h" 26#include "sockinfo.h"
27#include "slog.h" 27#include "slog.h"
28 28
29// all ipv4-based protocols 29// all ipv4-based protocols
30#define PROTv4 (PROT_UDPv4 | PROT_TCPv4 | PROT_ICMPv4 | PROT_IPv4) 30#define PROTv4 (PROT_UDPv4 | PROT_TCPv4 | PROT_ICMPv4 | PROT_IPv4 | PROT_DNSv4)
31 31
32void sockinfo::set (const sockaddr_in *sa, u8 prot_) 32void sockinfo::set (const sockaddr_in *sa, u8 prot_)
33{ 33{
34 host = sa->sin_addr.s_addr; 34 host = sa->sin_addr.s_addr;
35 port = prot_ & (PROT_IPv4 | PROT_ICMPv4) ? 0 : sa->sin_port; 35 port = prot_ & (PROT_IPv4 | PROT_ICMPv4) ? 0 : sa->sin_port;
59} 59}
60 60
61void 61void
62sockinfo::set (const conf_node *conf, u8 prot_) 62sockinfo::set (const conf_node *conf, u8 prot_)
63{ 63{
64 if (prot_ == PROT_DNSv4)
65 set (conf->dns_hostname, conf->dns_hostname ? conf->dns_port : 0, prot_);
66 else
64 set (conf->hostname, 67 set (conf->hostname,
65 prot_ == PROT_UDPv4 ? conf->udp_port 68 prot_ == PROT_UDPv4 ? conf->udp_port
66 : prot_ == PROT_TCPv4 ? conf->tcp_port 69 : prot_ == PROT_TCPv4 ? conf->tcp_port
67 : prot_ == PROT_DNSv4 ? conf->dns_port 70 : prot_ == PROT_DNSv4 ? conf->dns_port
68 : 0, 71 : 0,
69 prot_); 72 prot_);
70} 73}
71 74
72const sockaddr * 75const sockaddr *
73sockinfo::sav4() const 76sockinfo::sav4() const
74{ 77{
122 && conf->tcp_port) 125 && conf->tcp_port)
123 protocols |= PROT_TCPv4; 126 protocols |= PROT_TCPv4;
124 127
125 if (conf 128 if (conf
126 && prot & PROTv4 129 && prot & PROTv4
127 && conf->protocols & PROT_DNSv4) 130 && conf->protocols & PROT_DNSv4
131 && conf->dns_port)
128 protocols |= PROT_DNSv4; 132 protocols |= PROT_DNSv4;
129 133
130 return protocols; 134 return protocols;
131} 135}
132 136
163 { 167 {
164 prot = prot_; 168 prot = prot_;
165 port = htons (conf->tcp_port); 169 port = htons (conf->tcp_port);
166 return true; 170 return true;
167 } 171 }
172
173#if ENABLE_DNS
174 if (conf
175 && prot_ & PROT_DNSv4
176 && conf->protocols & PROT_DNSv4
177 && conf->dns_port)
178 {
179 set (::conf.dns_forw_host, ::conf.dns_forw_port, prot_);
180 return true;
181 }
182#endif
168 } 183 }
169 184
170 return false; 185 return false;
171} 186}
172 187

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines