]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/address_conf.h
!!! I didn't run the regression tests.!!!
[bacula/bacula] / bacula / src / lib / address_conf.h
index cc148404cb20ba652e751272be0fc060d51e26fc..3741d37a230cf0476e9d151c41f164232adb3c68 100644 (file)
  */
 
 
-class IPADDR {
+class IPADDR : public SMARTALLOC {
  public:
    typedef enum { R_SINGLE, R_SINGLE_PORT, R_SINGLE_ADDR, R_MULTIPLE,
-      R_DEFAULT, R_EMPTY
+                  R_DEFAULT, R_EMPTY
    } i_type;
    IPADDR(int af);
    IPADDR(const IPADDR & src);
  private:
-   IPADDR() {
-      /* block this construction */ 
-   } 
+   IPADDR() {  /* block this construction */ } 
    i_type type;
    union {
       struct sockaddr dontuse;
@@ -53,8 +51,12 @@ class IPADDR {
  public:
    void set_type(i_type o);
    i_type get_type() const;
-   unsigned short get_port() const;
-   void set_port(unsigned short port);
+   unsigned short get_port_net_order() const;
+   unsigned short get_port_host_order() const
+   {
+      return ntohs(get_port_net_order());
+   }
+   void set_port_net(unsigned short port);
    int get_family() const;
    struct sockaddr *get_sockaddr();
    int get_sockaddr_len();
@@ -66,13 +68,8 @@ class IPADDR {
 #endif
    const char *get_address(char *outputbuf, int outlen);
 
-   const char *build_address_str(char *buf, int blen) {
-      char tmp[1024];
-      snprintf(buf, blen, "host[%s:%s:%hu] ",
-                get_family() == AF_INET ? "ipv4" : "ipv6",
-                get_address(tmp, sizeof(tmp) - 1), ntohs(get_port()));
-      return buf;
-   }
+   const char *build_address_str(char *buf, int blen);
+
    /* private */
    dlink link;
 };
@@ -81,14 +78,13 @@ extern void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass);
 extern void free_addresses(dlist * addrs);
 extern void store_addresses_address(LEX * lc, RES_ITEM * item, int index, int pass);
 extern void store_addresses_port(LEX * lc, RES_ITEM * item, int index, int pass);
-extern int add_address(dlist ** out, IPADDR::i_type type, unsigned short defaultport,
-                       int family, const char *hostname_str,
-                       const char *port_str, char **errstr);
-
 extern void init_default_addresses(dlist ** addr, int port);
 
 extern const char *get_first_address(dlist * addrs, char *outputbuf, int outlen);
-extern int get_first_port(dlist * addrs);
+extern int get_first_port_net_order(dlist * addrs);
+extern int get_first_port_host_order(dlist * addrs);
 
 extern const char *build_addresses_str(dlist *addrs, char *buf, int blen);
 
+extern int sockaddr_get_port_net_order(const struct sockaddr *sa);
+extern int sockaddr_to_ascii(const struct sockaddr *sa, char *buf, int len);