2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
21 * Written by Meno Abels, June MMIV
26 class IPADDR : public SMARTALLOC {
28 typedef enum { R_SINGLE, R_SINGLE_PORT, R_SINGLE_ADDR, R_MULTIPLE,
32 IPADDR(const IPADDR & src);
34 IPADDR() { /* block this construction */ }
37 struct sockaddr dontuse;
38 struct sockaddr_in dontuse4;
40 struct sockaddr_in6 dontuse6;
43 struct sockaddr *saddr;
44 struct sockaddr_in *saddr4;
46 struct sockaddr_in6 *saddr6;
49 void set_type(i_type o);
50 i_type get_type() const;
51 unsigned short get_port_net_order() const;
52 unsigned short get_port_host_order() const
54 return ntohs(get_port_net_order());
56 void set_port_net(unsigned short port);
57 int get_family() const;
58 struct sockaddr *get_sockaddr();
59 int get_sockaddr_len();
60 void copy_addr(IPADDR * src);
62 void set_addr4(struct in_addr *ip4);
64 void set_addr6(struct in6_addr *ip6);
66 const char *get_address(char *outputbuf, int outlen);
68 const char *build_address_str(char *buf, int blen);
74 extern void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass);
75 extern void free_addresses(dlist * addrs);
76 extern void store_addresses_address(LEX * lc, RES_ITEM * item, int index, int pass);
77 extern void store_addresses_port(LEX * lc, RES_ITEM * item, int index, int pass);
78 extern void init_default_addresses(dlist ** addr, int port);
80 extern const char *get_first_address(dlist * addrs, char *outputbuf, int outlen);
81 extern int get_first_port_net_order(dlist * addrs);
82 extern int get_first_port_host_order(dlist * addrs);
84 extern const char *build_addresses_str(dlist *addrs, char *buf, int blen);
86 extern int sockaddr_get_port_net_order(const struct sockaddr *sa);
87 extern int sockaddr_get_port(const struct sockaddr *sa);
88 extern char *sockaddr_to_ascii(const struct sockaddr *sa, int socklen, char *buf, int buflen);
90 #undef HAVE_OLD_SOCKOPT
92 #ifdef HAVE_OLD_SOCKOPT
93 extern int inet_aton(const char *cp, struct in_addr *inp);