]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/bsock.h
kes Eliminate some compile warnings in dird_conf.c
[bacula/bacula] / bacula / src / lib / bsock.h
1 /*
2  * Bacula Sock Structure definition
3  *
4  * Kern Sibbald, May MM
5  *
6  * Zero msglen from other end indicates soft eof (usually
7  *   end of some binary data stream, but not end of conversation).
8  *
9  * Negative msglen, is special "signal" (no data follows).
10  *   See below for SIGNAL codes.
11  *
12  *   Version $Id$
13  */
14 /*
15    Copyright (C) 2000-2006 Kern Sibbald
16
17    This program is free software; you can redistribute it and/or
18    modify it under the terms of the GNU General Public License
19    version 2 as amended with additional clauses defined in the
20    file LICENSE in the main source directory.
21
22    This program is distributed in the hope that it will be useful,
23    but WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
25    the file LICENSE for additional details.
26
27  */
28
29 struct BSOCK {
30    uint64_t read_seqno;               /* read sequence number */
31    uint32_t in_msg_no;                /* input message number */
32    uint32_t out_msg_no;               /* output message number */
33    int fd;                            /* socket file descriptor */
34    TLS_CONNECTION *tls;               /* associated tls connection */
35    int32_t msglen;                    /* message length */
36    int b_errno;                       /* bsock errno */
37    int port;                          /* desired port */
38    int blocking;                      /* blocking state (0 = nonblocking, 1 = blocking) */
39    volatile int errors;               /* incremented for each error on socket */
40    volatile bool suppress_error_msgs: 1; /* set to suppress error messages */
41    volatile bool timed_out: 1;        /* timed out in read/write */
42    volatile bool terminated: 1;       /* set when BNET_TERMINATE arrives */
43    bool duped: 1;                     /* set if duped BSOCK */
44    bool spool: 1;                     /* set for spooling */
45    volatile time_t timer_start;       /* time started read/write */
46    volatile time_t timeout;           /* timeout BSOCK after this interval */
47    POOLMEM *msg;                      /* message pool buffer */
48    char *who;                         /* Name of daemon to which we are talking */
49    char *host;                        /* Host name/IP */
50    POOLMEM *errmsg;                   /* edited error message */
51    RES *res;                          /* Resource to which we are connected */
52    BSOCK *next;                       /* next BSOCK if duped */
53    FILE *spool_fd;                    /* spooling file */
54    JCR *jcr;                          /* jcr or NULL for error msgs */
55    struct sockaddr client_addr;    /* client's IP address */
56    struct sockaddr_in peer_addr;    /* peer's IP address */
57 };
58
59 /* Signal definitions for use in bnet_sig() */
60 enum {
61    BNET_EOD            = -1,          /* End of data stream, new data may follow */
62    BNET_EOD_POLL       = -2,          /* End of data and poll all in one */
63    BNET_STATUS         = -3,          /* Send full status */
64    BNET_TERMINATE      = -4,          /* Conversation terminated, doing close() */
65    BNET_POLL           = -5,          /* Poll request, I'm hanging on a read */
66    BNET_HEARTBEAT      = -6,          /* Heartbeat Response requested */
67    BNET_HB_RESPONSE    = -7,          /* Only response permited to HB */
68    BNET_PROMPT         = -8,          /* Prompt for UA */
69    BNET_BTIME          = -9,          /* Send UTC btime */
70    BNET_BREAK          = -10,         /* Stop current command -- ctl-c */
71    BNET_START_SELECT   = -11,         /* Start of a selection list */
72    BNET_END_SELECT     = -12          /* End of a select list */
73 };
74
75 #define BNET_SETBUF_READ  1           /* Arg for bnet_set_buffer_size */
76 #define BNET_SETBUF_WRITE 2           /* Arg for bnet_set_buffer_size */
77
78 /* Return status from bnet_recv() */
79 #define BNET_SIGNAL  -1
80 #define BNET_HARDEOF -2
81 #define BNET_ERROR   -3
82
83 /*
84  * TLS enabling values. Value is important for comparison, ie:
85  * if (tls_remote_need < BNET_TLS_REQUIRED) { ... }
86  */
87 #define BNET_TLS_NONE     0           /* cannot do TLS */
88 #define BNET_TLS_OK       1           /* can do, but not required on my end */
89 #define BNET_TLS_REQUIRED 2           /* TLS is required */