2 Bacula® - The Network Backup Solution
4 Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 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 Bacula® is a registered trademark of Kern Sibbald.
18 * Written by Meno Abels, June MMIV
23 class IPADDR : public SMARTALLOC {
25 typedef enum { R_SINGLE, R_SINGLE_PORT, R_SINGLE_ADDR, R_MULTIPLE,
29 IPADDR(const IPADDR & src);
31 IPADDR() { /* block this construction */ }
34 struct sockaddr dontuse;
35 struct sockaddr_in dontuse4;
37 struct sockaddr_in6 dontuse6;
40 struct sockaddr *saddr;
41 struct sockaddr_in *saddr4;
43 struct sockaddr_in6 *saddr6;
46 void set_type(i_type o);
47 i_type get_type() const;
48 unsigned short get_port_net_order() const;
49 unsigned short get_port_host_order() const
51 return ntohs(get_port_net_order());
53 void set_port_net(unsigned short port);
54 int get_family() const;
55 struct sockaddr *get_sockaddr();
56 int get_sockaddr_len();
57 void copy_addr(IPADDR * src);
59 void set_addr4(struct in_addr *ip4);
61 void set_addr6(struct in6_addr *ip6);
63 const char *get_address(char *outputbuf, int outlen);
65 const char *build_address_str(char *buf, int blen);
71 extern void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass);
72 extern void free_addresses(dlist * addrs);
73 extern void store_addresses_address(LEX * lc, RES_ITEM * item, int index, int pass);
74 extern void store_addresses_port(LEX * lc, RES_ITEM * item, int index, int pass);
75 extern void init_default_addresses(dlist ** addr, int port);
77 extern const char *get_first_address(dlist * addrs, char *outputbuf, int outlen);
78 extern int get_first_port_net_order(dlist * addrs);
79 extern int get_first_port_host_order(dlist * addrs);
81 extern const char *build_addresses_str(dlist *addrs, char *buf, int blen);
83 extern int sockaddr_get_port_net_order(const struct sockaddr *sa);
84 extern int sockaddr_get_port(const struct sockaddr *sa);
85 extern char *sockaddr_to_ascii(const struct sockaddr *sa, int socklen, char *buf, int buflen);
87 #undef HAVE_OLD_SOCKOPT
89 #ifdef HAVE_OLD_SOCKOPT
90 extern int inet_aton(const char *cp, struct in_addr *inp);