1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2012 Free Software Foundation Europe e.V.
5    Copyright (C) 2011-2012 Planets Communications B.V.
6    Copyright (C) 2013-2018 Bareos GmbH & Co. KG
7 
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12 
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    Affero General Public License for more details.
17 
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22 */
23 
24 #ifndef BAREOS_FILED_BACKUP_H_
25 #define BAREOS_FILED_BACKUP_H_
26 
27 namespace filedaemon {
28 
29 struct b_save_ctx {
30    JobControlRecord *jcr;                    /* Current Job Control Record */
31    FindFilesPacket *ff_pkt;              /* File being processed */
32    DIGEST *digest;              /* Encryption Digest */
33    DIGEST *signing_digest;      /* Signing Digest */
34    int digest_stream;           /* Type of Signing Digest */
35 };
36 
37 struct b_ctx {
38    JobControlRecord *jcr;                    /* Current Job Control Record */
39    FindFilesPacket *ff_pkt;              /* File being processed */
40    POOLMEM *msgsave;            /* Saved sd->msg */
41    char *rbuf;                  /* Read buffer */
42    char *wbuf;                  /* Write buffer */
43    int32_t rsize;               /* Read size */
44    uint64_t fileAddr;           /* File address */
45 
46    /*
47     * Compression data.
48     */
49    const unsigned char *chead;  /* Compression header */
50    unsigned char *cbuf;         /* Compression buffer when using generic comp_stream_header */
51    uint32_t compress_len;       /* Actual length after compression */
52    uint32_t max_compress_len;   /* Maximum size that will fit into compression buffer */
53    comp_stream_header ch;       /* Compression Stream Header with info about compression used */
54 
55    /*
56     * Encryption data.
57     */
58    uint32_t cipher_input_len;   /* Actual length of the data to encrypt */
59    const uint8_t *cipher_input; /* Data to encrypt */
60    uint32_t encrypted_len;      /* Actual length after encryption */
61    DIGEST *digest;              /* Encryption Digest */
62    DIGEST *signing_digest;      /* Signing Digest */
63    CIPHER_CONTEXT *cipher_ctx;  /* Cipher context */
64 };
65 
66 bool BlastDataToStorageDaemon(JobControlRecord *jcr, char *addr, crypto_cipher_t cipher);
67 bool EncodeAndSendAttributes(JobControlRecord *jcr, FindFilesPacket *ff_pkt, int &data_stream);
68 void StripPath(FindFilesPacket *ff_pkt);
69 void UnstripPath(FindFilesPacket *ff_pkt);
70 
71 } /* namespace filedaemon */
72 #endif
73