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.23 by pcg, Thu Aug 7 17:54:27 2008 UTC vs.
Revision 1.25 by root, Thu Mar 24 21:52:49 2011 UTC

42#include <cstdio> 42#include <cstdio>
43 43
44// all ipv4-based protocols 44// all ipv4-based protocols
45#define PROTv4 (PROT_UDPv4 | PROT_TCPv4 | PROT_ICMPv4 | PROT_IPv4 | PROT_DNSv4) 45#define PROTv4 (PROT_UDPv4 | PROT_TCPv4 | PROT_ICMPv4 | PROT_IPv4 | PROT_DNSv4)
46 46
47void
47void sockinfo::set (const sockaddr_in *sa, u8 prot_) 48sockinfo::set (const sockaddr_in *sa, u8 prot_)
48{ 49{
49 host = sa->sin_addr.s_addr; 50 host = sa->sin_addr.s_addr;
50 port = prot_ & (PROT_IPv4 | PROT_ICMPv4) ? 0 : sa->sin_port; 51 port = prot_ & (PROT_IPv4 | PROT_ICMPv4) ? 0 : sa->sin_port;
51 prot = prot_; 52 prot = prot_;
52} 53}
53 54
55void
54void sockinfo::set (const char *hostname, u16 port_, u8 prot_) 56sockinfo::set (const char *hostname, u16 port_, u8 prot_)
55{ 57{
56 prot = prot_; 58 prot = prot_;
57 host = 0; 59 host = 0;
58 port = htons (port_); 60 port = htons (port_);
59 61
125u8 127u8
126sockinfo::supported_protocols (conf_node *conf) 128sockinfo::supported_protocols (conf_node *conf)
127{ 129{
128 u8 protocols = prot; 130 u8 protocols = prot;
129 131
130 if (prot & (PROT_UDPv4 | PROT_TCPv4)) 132 if (prot & (PROT_IPv4 | PROT_ICMPv4 | PROT_UDPv4 | PROT_TCPv4))
131 protocols |= PROT_IPv4 | PROT_ICMPv4; 133 protocols |= PROT_IPv4 | PROT_ICMPv4;
132 134
133 if (conf
134 && prot & PROTv4 135 if (conf && prot & PROTv4)
135 && conf->protocols & PROT_UDPv4 136 {
136 && conf->udp_port) 137 if (conf->protocols & PROT_UDPv4 && conf->udp_port)
137 protocols |= PROT_UDPv4; 138 protocols |= PROT_UDPv4;
138 139
139 if (conf 140 if (conf->protocols & PROT_TCPv4 && conf->tcp_port)
140 && prot & PROTv4
141 && conf->protocols & PROT_TCPv4
142 && conf->tcp_port)
143 protocols |= PROT_TCPv4; 141 protocols |= PROT_TCPv4;
144 142
145 if (conf 143 if (conf->protocols & PROT_DNSv4 && conf->dns_port)
146 && prot & PROTv4
147 && conf->protocols & PROT_DNSv4
148 && conf->dns_port)
149 protocols |= PROT_DNSv4; 144 protocols |= PROT_DNSv4;
145 }
150 146
151 return protocols; 147 return protocols;
152} 148}
153 149
154bool 150bool

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines