]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/bsock.h
cbb79513eff487b54966cd1bd6b894b11010c3a8
[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, 2001, 2002 Kern Sibbald and John Walker
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 as
19    published by the Free Software Foundation; either version 2 of
20    the License, or (at your option) any later version.
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 GNU
25    General Public License for more details.
26
27    You should have received a copy of the GNU General Public
28    License along with this program; if not, write to the Free
29    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30    MA 02111-1307, USA.
31
32  */
33
34 typedef struct s_bsock {
35    uint64_t read_seqno;               /* read sequence number */
36    uint32_t in_msg_no;                /* intput message number */
37    uint32_t out_msg_no;               /* output message number */
38    int fd;                            /* socket file descriptor */
39    int32_t msglen;                    /* message length */
40    int port;                          /* desired port */
41    int errors;                        /* set if errors on socket */
42    int b_errno;                       /* bsock errno */
43    time_t timer_start;                /* time started read/write */
44    int timed_out;                     /* timed out in read/write */
45    int timeout;                       /* time out after this value */
46    int terminated;                    /* set when BNET_TERMINATE arrives */
47    int duped;                         /* set if duped BSOCK */
48    POOLMEM *msg;                      /* message pool buffer */
49    char *who;                         /* Name of daemon to which we are talking */
50    char *host;                        /* Host name/IP */
51    POOLMEM *errmsg;                   /* edited error message (to be implemented) */
52    RES *res;                          /* Resource to which we are connected */
53    struct s_bsock *next;              /* next BSOCK if duped */
54 } BSOCK;
55
56 /* Signal definitions for use in bnet_sig() */
57 #define BNET_EOF          0           /* Deprecated, use BNET_EOD */
58 #define BNET_EOD         -1           /* End of data stream, new data may follow */
59 #define BNET_EOD_POLL    -2           /* End of data and poll all in one */
60 #define BNET_STATUS      -3           /* Send full status */
61 #define BNET_TERMINATE   -4           /* Conversation terminated, doing close() */
62 #define BNET_POLL        -5           /* Poll request, I'm hanging on a read */
63 #define BNET_HEARTBEAT   -6           /* Heartbeat Response requested */
64 #define BNET_HB_RESPONSE -7           /* Only response permited to HB */
65 #define BNET_PROMPT      -8           /* Prompt for UA */
66
67 #define BNET_SETBUF_READ  1           /* Arg for bnet_set_buffer_size */
68 #define BNET_SETBUF_WRITE 2           /* Arg for bnet_set_buffer_size */
69
70 /*
71  * This is the structure of the in memory BPKT
72  */
73 typedef struct s_bpkt {
74    char *id;                          /* String identifier or name of field */
75    uint8_t type;                      /* field type */
76    uint32_t len;                      /* field length for string, name, bytes */
77    void *value;                       /* pointer to value */
78 } BPKT;
79
80 /*  
81  * These are the data types that can be sent.
82  * For all values other than string, the storage space
83  *  is assumed to be allocated in the receiving packet.
84  *  For BP_STRING if the *value is non-zero, it is a        
85  *  pointer to a POOLMEM buffer, and the Memory Pool
86  *  routines will be used to assure that the length is
87  *  adequate. NOTE!!! This pointer will be changed
88  *  if the memory is reallocated (sort of like Mmsg(&pool)
89  *  does). If the pointer is NULL, a POOLMEM
90  *  buffer will be allocated.
91  */
92 #define BP_EOF       0                /* end of file */
93 #define BP_CHAR      1                /* Character */
94 #define BP_INT32     1                /* 32 bit integer */
95 #define BP_UINT32    3                /* Unsigned 32 bit integer */
96 #define BP_INT64     4                /* 64 bit integer */
97 #define BP_STRING    5                /* string */
98 #define BP_NAME      6                /* Name string -- limited length */
99 #define BP_BYTES     7                /* Binary bytes */
100 #define BP_FLOAT32   8                /* 32 bit floating point */
101 #define BP_FLOAT64   9                /* 64 bit floating point */
102