]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bsock.h
Implement first cut of Copy Job
[bacula/bacula] / bacula / src / lib / bsock.h
index 0cfe61203e0f858b4a14e11913a33bef781e96e9..118da0b2091330cba4102109006d1b9905ee0194 100644 (file)
@@ -7,8 +7,8 @@
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
    modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
  *   Version $Id$
  */
 
+#ifndef __BSOCK_H_
+#define __BSOCK_H_
+
+struct btimer_t;                      /* forward reference */
+class BSOCK;
+btimer_t *start_bsock_timer(BSOCK *bs, uint32_t wait);
+void stop_bsock_timer(btimer_t *wid);
+
 
 class BSOCK {
 private:
@@ -49,6 +57,11 @@ private:
    char *m_who;                       /* Name of daemon to which we are talking */
    char *m_host;                      /* Host name/IP */
    int m_port;                        /* desired port */
+   btimer_t *m_tid;                   /* timer id */
+   volatile bool m_timed_out: 1;      /* timed out in read/write */
+   volatile bool m_terminated: 1;     /* set when BNET_TERMINATE arrives */
+   bool m_duped: 1;                   /* set if duped BSOCK */
+   bool m_spool: 1;                   /* set for spooling */
 
    void fin_init(JCR * jcr, int sockfd, const char *who, const char *host, int port,
                struct sockaddr *lclient_addr);
@@ -66,10 +79,6 @@ public:
    int m_blocking;                    /* blocking state (0 = nonblocking, 1 = blocking) */
    volatile int errors;               /* incremented for each error on socket */
    volatile bool m_suppress_error_msgs: 1; /* set to suppress error messages */
-   volatile bool m_timed_out: 1;      /* timed out in read/write */
-   volatile bool m_terminated: 1;     /* set when BNET_TERMINATE arrives */
-   bool m_duped: 1;                   /* set if duped BSOCK */
-   bool m_spool: 1;                   /* set for spooling */
    volatile time_t timer_start;       /* time started read/write */
    volatile time_t timeout;           /* timeout BSOCK after this interval */
    POOLMEM *msg;                      /* message pool buffer */
@@ -82,6 +91,7 @@ public:
    /* methods -- in bsock.c */
    void init();
    void free_bsock();
+   void free_tls();
    bool connect(JCR * jcr, int retry_interval, utime_t max_retry_time,
                 utime_t heart_beat, const char *name, char *host, 
                 char *service, int port, int verbose);
@@ -100,6 +110,8 @@ public:
    void restore_blocking(int flags);
    int wait_data(int sec);
    int wait_data_intr(int sec);
+   bool authenticate_director(const char *name, const char *password,
+                  TLS_CONTEXT *tls_ctx, char *msg, int msglen);
 
    /* Inline functions */
    void set_jcr(JCR *jcr) { m_jcr = jcr; };
@@ -111,9 +123,20 @@ public:
    int port() { return m_port; };
    JCR *jcr() { return m_jcr; };
    JCR *get_jcr() { return m_jcr; };
+   bool is_spooling() { return m_spool; };
+   bool is_duped() { return m_duped; };
    bool is_terminated() { return m_terminated; };
    bool is_timed_out() { return m_timed_out; };
+   bool is_stop() { return errors || is_terminated(); }
+   bool is_error() { errno = b_errno; return errors; }
+   void set_spooling() { m_spool = true; };
+   void clear_spooling() { m_spool = false; };
+   void set_duped() { m_duped = true; };
+   void set_timed_out() { m_timed_out = true; };
+   void clear_timed_out() { m_timed_out = false; };
    void set_terminated() { m_terminated = true; };
+   void start_timer(int sec) { m_tid = start_bsock_timer(this, sec); };
+   void stop_timer() { stop_bsock_timer(m_tid); };
 };
 
 /* 
@@ -144,7 +167,10 @@ enum {
    BNET_WARNING_MSG    = -20,         /* Warning message */
    BNET_ERROR_MSG      = -21,         /* Error message -- command failed */
    BNET_INFO_MSG       = -22,         /* Info message -- status line */
-   BNET_RUN_CMD        = -23          /* Run command follows */
+   BNET_RUN_CMD        = -23,         /* Run command follows */
+   BNET_YESNO          = -24,         /* Request yes no response */
+   BNET_START_RTREE    = -25,         /* Start restore tree mode */
+   BNET_END_RTREE      = -26          /* End restore tree mode */ 
 };
 
 #define BNET_SETBUF_READ  1           /* Arg for bnet_set_buffer_size */
@@ -175,3 +201,5 @@ int32_t read_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes);
 int32_t write_nbytes(BSOCK * bsock, char *ptr, int32_t nbytes);
 
 BSOCK *new_bsock();
+
+#endif /* __BSOCK_H_ */