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.4 by pcg, Sat Apr 5 02:32:40 2003 UTC vs.
Revision 1.5 by pcg, Sat Apr 5 17:54:22 2003 UTC

90 sprintf (hostport, "%s/%.15s:%d", strprotocol (prot), inet_ntoa (ia), ntohs (port) & 0xffff); 90 sprintf (hostport, "%s/%.15s:%d", strprotocol (prot), inet_ntoa (ia), ntohs (port) & 0xffff);
91 91
92 return hostport; 92 return hostport;
93} 93}
94 94
95u8
96sockinfo::supported_protocols (conf_node *conf)
97{
98 u8 protocols = prot;
99
100 if (prot & (PROT_UDPv4 | PROT_TCPv4))
101 protocols |= PROT_IPv4;
102
103 if (conf
104 && prot & (PROT_IPv4 | PROT_UDPv4 | PROT_TCPv4)
105 && conf->protocols & PROT_UDPv4
106 && conf->udp_port)
107 protocols |= PROT_UDPv4;
108
109 if (conf
110 && prot & (PROT_IPv4 | PROT_UDPv4 | PROT_TCPv4)
111 && conf->protocols & PROT_TCPv4
112 && conf->tcp_port)
113 protocols |= PROT_TCPv4;
114
115 return protocols;
116}
117
118bool
119sockinfo::upgrade_protocol (u8 prot_, conf_node *conf)
120{
121 if (prot_ == prot)
122 return true;
123
124 if (prot & (PROT_IPv4 | PROT_UDPv4 | PROT_TCPv4)
125 && prot_ & (PROT_IPv4 | PROT_UDPv4 | PROT_TCPv4))
126 {
127 if (prot_ & PROT_IPv4)
128 {
129 prot = prot_;
130 port = 0;
131 return true;
132 }
133
134 if (conf
135 && prot_ & PROT_UDPv4
136 && conf->protocols & PROT_UDPv4
137 && conf->udp_port)
138 {
139 prot = prot_;
140 port = conf->udp_port;
141 return true;
142 }
143
144 if (conf
145 && prot_ & PROT_TCPv4
146 && conf->protocols & PROT_TCPv4
147 && conf->tcp_port)
148 {
149 prot = prot_;
150 port = conf->tcp_port;
151 return true;
152 }
153 }
154
155 return false;
156}
157
95bool 158bool
96operator == (const sockinfo &a, const sockinfo &b) 159operator == (const sockinfo &a, const sockinfo &b)
97{ 160{
98 return a.host == b.host && a.port == b.port && a.prot == b.prot; 161 return a.host == b.host && a.port == b.port && a.prot == b.prot;
99} 162}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines