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.1 by pcg, Fri Mar 28 04:05:10 2003 UTC vs.
Revision 1.3 by pcg, Wed Apr 2 05:15:00 2003 UTC

16 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include "config.h" 19#include "config.h"
20 20
21#include "arpa/inet.h" 21#include <arpa/inet.h>
22#include <netdb.h>
22 23
23#include "gettext.h" 24#include "gettext.h"
24 25
25#include "sockinfo.h" 26#include "sockinfo.h"
26#include "slog.h" 27#include "slog.h"
31 port = prot_ == PROT_IPv4 ? 0 : sa->sin_port; 32 port = prot_ == PROT_IPv4 ? 0 : sa->sin_port;
32 prot = prot_; 33 prot = prot_;
33} 34}
34 35
35void 36void
36sockinfo::set (const conf_node *conf) 37sockinfo::set (const conf_node *conf, u8 prot_)
37{ 38{
39 prot = prot_;
38 host = 0; 40 host = 0;
39 port = htons (conf->udp_port); 41 port = prot_ == PROT_UDPv4 ? htons (conf->udp_port)
42 : prot_ == PROT_TCPv4 ? htons (conf->tcp_port)
43 : 0;
40 44
41 if (conf->hostname) 45 if (conf->hostname)
42 { 46 {
43 struct hostent *he = gethostbyname (conf->hostname); 47 struct hostent *he = gethostbyname (conf->hostname);
44 48
46 && he->h_addrtype == AF_INET && he->h_length == 4 && he->h_addr_list[0]) 50 && he->h_addrtype == AF_INET && he->h_length == 4 && he->h_addr_list[0])
47 { 51 {
48 //sa->sin_family = he->h_addrtype; 52 //sa->sin_family = he->h_addrtype;
49 memcpy (&host, he->h_addr_list[0], 4); 53 memcpy (&host, he->h_addr_list[0], 4);
50 54
51 prot = PROT_UDPv4 | PROT_IPv4;
52 } 55 }
53 else 56 else
54 slog (L_NOTICE, _("unable to resolve host '%s'"), conf->hostname); 57 slog (L_NOTICE, _("unable to resolve host '%s'"), conf->hostname);
55 } 58 }
56} 59}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines