]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/address_conf.h
crypto: convert EVP_PKEY access and remainings bits for OpenSSL 1.1
[bacula/bacula] / bacula / src / lib / address_conf.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2016 Kern Sibbald
5
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.
8
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.
13
14    This notice must be preserved when any source code is 
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  *
21  *   Written by Meno Abels, June MMIV
22  *
23  */
24
25
26 class IPADDR : public SMARTALLOC {
27  public:
28    typedef enum { R_SINGLE, R_SINGLE_PORT, R_SINGLE_ADDR, R_MULTIPLE,
29                   R_DEFAULT, R_EMPTY
30    } i_type;
31    IPADDR(int af);
32    IPADDR(const IPADDR & src);
33  private:
34    IPADDR() {  /* block this construction */ }
35    i_type type;
36    union {
37       struct sockaddr dontuse;
38       struct sockaddr_in dontuse4;
39 #ifdef HAVE_IPV6
40       struct sockaddr_in6 dontuse6;
41 #endif
42    } saddrbuf;
43    struct sockaddr *saddr;
44    struct sockaddr_in *saddr4;
45 #ifdef HAVE_IPV6
46    struct sockaddr_in6 *saddr6;
47 #endif
48  public:
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
53    {
54       return ntohs(get_port_net_order());
55    }
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);
61    void set_addr_any();
62    void set_addr4(struct in_addr *ip4);
63 #ifdef HAVE_IPV6
64    void set_addr6(struct in6_addr *ip6);
65 #endif
66    const char *get_address(char *outputbuf, int outlen);
67
68    const char *build_address_str(char *buf, int blen);
69
70    /* private */
71    dlink link;
72 };
73
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);
79
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);
83
84 extern const char *build_addresses_str(dlist *addrs, char *buf, int blen);
85
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);
89 #ifdef WIN32
90 #undef HAVE_OLD_SOCKOPT
91 #endif
92 #ifdef HAVE_OLD_SOCKOPT
93 extern int inet_aton(const char *cp, struct in_addr *inp);
94 #endif