… | |
… | |
40 | host = 0; |
40 | host = 0; |
41 | port = prot == PROT_UDPv4 ? htons (conf->udp_port) |
41 | port = prot == PROT_UDPv4 ? htons (conf->udp_port) |
42 | : prot == PROT_TCPv4 ? htons (conf->tcp_port) |
42 | : prot == PROT_TCPv4 ? htons (conf->tcp_port) |
43 | : 0; |
43 | : 0; |
44 | |
44 | |
|
|
45 | if (prot & (PROT_UDPv4 | PROT_TCPv4 | PROT_IPv4) |
45 | if (prot && conf->hostname) |
46 | && conf->hostname) |
46 | { |
47 | { |
47 | struct hostent *he = gethostbyname (conf->hostname); |
48 | struct hostent *he = gethostbyname (conf->hostname); |
48 | |
49 | |
49 | if (he |
50 | if (he |
50 | && he->h_addrtype == AF_INET && he->h_length == 4 && he->h_addr_list[0]) |
51 | && he->h_addrtype == AF_INET && he->h_length == 4 && he->h_addr_list[0]) |
51 | { |
52 | { |
52 | //sa->sin_family = he->h_addrtype; |
53 | //sa->sin_family = he->h_addrtype; |
53 | memcpy (&host, he->h_addr_list[0], 4); |
54 | memcpy (&host, he->h_addr_list[0], 4); |
54 | |
|
|
55 | } |
55 | } |
56 | else |
56 | else |
57 | slog (L_NOTICE, _("unable to resolve host '%s'"), conf->hostname); |
57 | slog (L_NOTICE, _("unable to resolve host '%s'"), conf->hostname); |
58 | } |
58 | } |
59 | } |
59 | } |
… | |
… | |
135 | && prot_ & PROT_UDPv4 |
135 | && prot_ & PROT_UDPv4 |
136 | && conf->protocols & PROT_UDPv4 |
136 | && conf->protocols & PROT_UDPv4 |
137 | && conf->udp_port) |
137 | && conf->udp_port) |
138 | { |
138 | { |
139 | prot = prot_; |
139 | prot = prot_; |
140 | port = conf->udp_port; |
140 | port = htons (conf->udp_port); |
141 | return true; |
141 | return true; |
142 | } |
142 | } |
143 | |
143 | |
144 | if (conf |
144 | if (conf |
145 | && prot_ & PROT_TCPv4 |
145 | && prot_ & PROT_TCPv4 |
146 | && conf->protocols & PROT_TCPv4 |
146 | && conf->protocols & PROT_TCPv4 |
147 | && conf->tcp_port) |
147 | && conf->tcp_port) |
148 | { |
148 | { |
149 | prot = prot_; |
149 | prot = prot_; |
150 | port = conf->tcp_port; |
150 | port = htons (conf->tcp_port); |
151 | return true; |
151 | return true; |
152 | } |
152 | } |
153 | } |
153 | } |
154 | |
154 | |
155 | return false; |
155 | return false; |