-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrpc.h
142 lines (120 loc) · 3.32 KB
/
rpc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* %ISC_START_LICENSE%
* ---------------------------------------------------------------------
* Copyright 2014-2016, Google, LLC
* Copyright 2014-2015, Pittsburgh Supercomputing Center
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* --------------------------------------------------------------------
* %END_LICENSE%
*/
#ifndef _RPC_H_
#define _RPC_H_
struct hdr {
uint64_t magic;
uint32_t opc; /* operation code */
uint32_t msglen; /* length of payload */
uint64_t xid; /* message ID */
};
#define OPC_GETFILE_REQ 0
#define OPC_GETFILE_REP 1
#define OPC_PUTDATA 2
#define OPC_CHECKZERO_REQ 3
#define OPC_CHECKZERO_REP 4
#define OPC_GETCKSUM_REQ 5
#define OPC_GETCKSUM_REP 6
#define OPC_PUTNAME_REQ 7
#define OPC_PUTNAME_REP 8
#define OPC_DONE 9
#define OPC_READY 10
struct rpc_sub_stat {
uint64_t dev;
uint64_t rdev;
uint32_t mode;
uint32_t uid;
uint32_t gid;
uint32_t _pad;
uint64_t size;
struct pfl_timespec tim[2];
#define atim tim[0] /* access time */
#define mtim tim[1] /* modify (data) time */
};
struct rpc_generic_rep {
uint64_t xid;
int32_t rc;
int32_t _pad;
};
struct rpc_getfile_req {
int32_t len;
int32_t _pad;
char fn[0]; /* relative path */
// char base[0];/* destination basename (optional) */
};
#define rpc_getfile_rep rpc_generic_rep
struct rpc_putdata {
uint64_t fid;
uint64_t off;
uint32_t flags;
int32_t _pad;
unsigned char data[0];
};
#define RPC_PUTDATA_F_LAST (1 << 0) /* this chunk is last one */
struct rpc_checkzero_req {
uint64_t fid;
uint64_t off;
uint64_t len;
};
#define rpc_checkzero_rep rpc_generic_rep
struct rpc_getcksum_req {
uint64_t fid;
uint64_t off;
uint64_t len;
};
#define ALGLEN 32
struct rpc_getcksum_rep {
char digest[ALGLEN];
};
struct rpc_putname_req {
struct rpc_sub_stat pstb;
uint64_t fid;
int32_t flags;
int32_t _pad;
uint64_t nchunks;
char fn[0];
};
struct rpc_putname_rep {
uint64_t fid;
int32_t rc;
int32_t _pad;
};
#define RPC_PUTNAME_F_TRYDIR (1 << 0) /* try directory as base */
struct rpc_ready {
int32_t nstreams;
int32_t _pad;
};
#define AUTH_LEN 1024
#define PSYNC_MAGIC UINT64_C(0xf1f2f3f4f5f6f7f8)
void rpc_send_done(struct stream *);
void rpc_send_ready(struct stream *);
void rpc_send_getfile(struct stream *, uint64_t, const char *,
const char *);
void rpc_send_putdata(struct stream *, uint64_t, off_t, const void *,
size_t, uint32_t);
void rpc_send_putname_req(struct stream *, uint64_t, const char *,
const struct stat *, const char *, uint64_t, int);
void rpc_send_putname_rep(struct stream *, uint64_t, int);
void handle_signal(int);
#endif /* _RPC_H_ */