1 #ifndef _SBUF_H
2 #define _SBUF_H
3 
4 #include "burp.h"
5 #include "bfile.h"
6 #include "conf.h"
7 #include "iobuf.h"
8 #include "protocol1/sbuf_protocol1.h"
9 #include "protocol2/sbuf_protocol2.h"
10 
11 // Bits in sbuf flags.
12 
13 // Protocol2 stuff.
14 // Keep track of what has been sent.
15 #define SBUF_SENT_STAT			0x0001
16 #define SBUF_SENT_PATH			0x0002
17 #define SBUF_SENT_LINK			0x0004
18 // Keep track of what needs to be received.
19 #define SBUF_NEED_LINK			0x0010
20 #define SBUF_NEED_DATA			0x0020
21 #define SBUF_HEADER_WRITTEN_TO_MANIFEST	0x0040
22 #define SBUF_END_WRITTEN_TO_MANIFEST	0x0080
23 
24 // Protocol1 stuff.
25 // Keep track of what needs to be sent.
26 #define SBUF_SEND_STAT			0x0100
27 #define SBUF_SEND_PATH			0x0200
28 #define SBUF_SEND_DATAPTH		0x0400
29 #define SBUF_SEND_ENDOFSIG		0x0800
30 // Keep track of what is being received.
31 #define SBUF_RECV_DELTA			0x1000
32 #define SBUF_CLIENT_RESTORE_HACK	0x2000
33 
34 #define ENCRYPTION_UNSET	-1 // Also legacy
35 #define ENCRYPTION_NONE		0
36 #define ENCRYPTION_KEY_DERIVED	1
37 
38 typedef struct sbuf sbuf_t;
39 
40 struct sbuf
41 {
42 	struct iobuf path; // File data.
43 	struct iobuf link; // Link data.
44 	struct iobuf attr; // Attribute data.
45         struct iobuf endfile; // End file marker.
46 
47 	struct stat statp;
48 	uint64_t winattr;
49 	int32_t compression;
50 	int32_t encryption;
51 
52 	uint16_t flags;
53 
54 	struct protocol1 *protocol1;
55 	struct protocol2 *protocol2;
56 
57 	struct sbuf *next;
58 };
59 
60 enum cntr_manio
61 {
62 	CNTR_MANIO_NEW='n',
63 	CNTR_MANIO_CHANGED='c',
64 	CNTR_MANIO_SAME='u',
65 	CNTR_MANIO_DELETED='d',
66 };
67 
68 extern struct sbuf *sbuf_alloc(enum protocol protocol);
69 extern void sbuf_free_content(struct sbuf *sb);
70 extern void sbuf_free(struct sbuf **sb);
71 
72 extern int sbuf_is_filedata(struct sbuf *sb);
73 extern int sbuf_is_vssdata(struct sbuf *sb);
74 extern int sbuf_is_link(struct sbuf *sb);
75 extern int sbuf_is_encrypted(struct sbuf *sb);
76 extern int sbuf_is_metadata(struct sbuf *sb);
77 extern int sbuf_is_estimatable(struct sbuf *sb);
78 
79 extern int sbuf_to_manifest(struct sbuf *sb, struct fzp *fzp);
80 extern int sbuf_to_manifest_cntr(struct sbuf *sb, struct fzp *fzp,
81 	enum cntr_manio what);
82 
83 extern int sbuf_pathcmp(struct sbuf *a, struct sbuf *b);
84 
85 extern int sbuf_fill_from_file(struct sbuf *sb, struct fzp *fzp,
86 	struct blk *blk);
87 extern int sbuf_fill_from_net(struct sbuf *sb, struct asfd *asfd,
88 	struct blk *blk, struct cntr *cntr);
89 
90 #endif
91