3 * Written by Meno Abels, June MMIV
8 Bacula® - The Network Backup Solution
10 Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
12 The main author of Bacula is Kern Sibbald, with contributions from
13 many others, a complete list can be found in the file AUTHORS.
14 This program is Free Software; you can redistribute it and/or
15 modify it under the terms of version two of the GNU General Public
16 License as published by the Free Software Foundation plus additions
17 that are listed in the file LICENSE.
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 Bacula® is a registered trademark of John Walker.
30 The licensor of Bacula is the Free Software Foundation Europe
31 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
32 Switzerland, email:ftf@fsfeurope.org.
35 class IPADDR : public SMARTALLOC {
37 typedef enum { R_SINGLE, R_SINGLE_PORT, R_SINGLE_ADDR, R_MULTIPLE,
41 IPADDR(const IPADDR & src);
43 IPADDR() { /* block this construction */ }
46 struct sockaddr dontuse;
47 struct sockaddr_in dontuse4;
49 struct sockaddr_in6 dontuse6;
52 struct sockaddr *saddr;
53 struct sockaddr_in *saddr4;
55 struct sockaddr_in6 *saddr6;
58 void set_type(i_type o);
59 i_type get_type() const;
60 unsigned short get_port_net_order() const;
61 unsigned short get_port_host_order() const
63 return ntohs(get_port_net_order());
65 void set_port_net(unsigned short port);
66 int get_family() const;
67 struct sockaddr *get_sockaddr();
68 int get_sockaddr_len();
69 void copy_addr(IPADDR * src);
71 void set_addr4(struct in_addr *ip4);
73 void set_addr6(struct in6_addr *ip6);
75 const char *get_address(char *outputbuf, int outlen);
77 const char *build_address_str(char *buf, int blen);
83 extern void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass);
84 extern void free_addresses(dlist * addrs);
85 extern void store_addresses_address(LEX * lc, RES_ITEM * item, int index, int pass);
86 extern void store_addresses_port(LEX * lc, RES_ITEM * item, int index, int pass);
87 extern void init_default_addresses(dlist ** addr, int port);
89 extern const char *get_first_address(dlist * addrs, char *outputbuf, int outlen);
90 extern int get_first_port_net_order(dlist * addrs);
91 extern int get_first_port_host_order(dlist * addrs);
93 extern const char *build_addresses_str(dlist *addrs, char *buf, int blen);
95 extern int sockaddr_get_port_net_order(const struct sockaddr *sa);
96 extern int sockaddr_get_port(const struct sockaddr *sa);
97 extern char *sockaddr_to_ascii(const struct sockaddr *sa, char *buf, int len);
99 #undef HAVE_OLD_SOCKOPT
101 #ifdef HAVE_OLD_SOCKOPT
102 extern int inet_aton(const char *cp, struct in_addr *inp);