1 | /* |
1 | /* |
2 | sockinfo.C -- socket address management |
2 | sockinfo.C -- socket address management |
|
|
3 | Copyright (C) 2003 Marc Lehmann <pcg@goof.com> |
3 | |
4 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
16 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ |
18 | */ |
18 | |
19 | |
19 | #include "config.h" |
20 | #include "config.h" |
20 | |
21 | |
21 | #include <arpa/inet.h> |
|
|
22 | #include <netdb.h> |
22 | #include <netdb.h> |
23 | |
23 | |
24 | #include "gettext.h" |
24 | #include "gettext.h" |
25 | |
25 | |
26 | #include "sockinfo.h" |
26 | #include "sockinfo.h" |
… | |
… | |
62 | sockinfo::set (const conf_node *conf, u8 prot_) |
62 | sockinfo::set (const conf_node *conf, u8 prot_) |
63 | { |
63 | { |
64 | set (conf->hostname, |
64 | set (conf->hostname, |
65 | prot_ == PROT_UDPv4 ? conf->udp_port |
65 | prot_ == PROT_UDPv4 ? conf->udp_port |
66 | : prot_ == PROT_TCPv4 ? conf->tcp_port |
66 | : prot_ == PROT_TCPv4 ? conf->tcp_port |
|
|
67 | : prot_ == PROT_DNSv4 ? conf->dns_port |
67 | : 0, |
68 | : 0, |
68 | prot_); |
69 | prot_); |
69 | } |
70 | } |
70 | |
71 | |
71 | const sockaddr * |
72 | const sockaddr * |
… | |
… | |
118 | if (conf |
119 | if (conf |
119 | && prot & PROTv4 |
120 | && prot & PROTv4 |
120 | && conf->protocols & PROT_TCPv4 |
121 | && conf->protocols & PROT_TCPv4 |
121 | && conf->tcp_port) |
122 | && conf->tcp_port) |
122 | protocols |= PROT_TCPv4; |
123 | protocols |= PROT_TCPv4; |
|
|
124 | |
|
|
125 | if (conf |
|
|
126 | && prot & PROTv4 |
|
|
127 | && conf->protocols & PROT_DNSv4) |
|
|
128 | protocols |= PROT_DNSv4; |
123 | |
129 | |
124 | return protocols; |
130 | return protocols; |
125 | } |
131 | } |
126 | |
132 | |
127 | bool |
133 | bool |