-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.cpp
More file actions
66 lines (59 loc) · 1.56 KB
/
Copy pathmessage.cpp
File metadata and controls
66 lines (59 loc) · 1.56 KB
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
//
// Created by Linghan Xing on 10/27/18.
//
#include "message.h"
//typedef struct {
// uint32_t type;
// uint32_t proc_id;
//} heartbeat_msg;
heartbeat_msg* hton(heartbeat_msg* msg) {
msg -> type = htonl(msg -> type);
msg -> proc_id = htonl(msg -> proc_id);
return msg;
}
heartbeat_msg* ntoh(heartbeat_msg* msg) {
msg -> proc_id = ntohl(msg -> proc_id);
return msg;
}
new_view_msg* hton(new_view_msg* msg){
msg -> type = htonl(msg -> type);
msg -> view_id = htonl(msg -> view_id);
msg -> new_proc_id = htonl(msg -> new_proc_id);
return msg;
}
new_view_msg* ntoh(new_view_msg* msg){
msg -> view_id = ntohl(msg -> view_id);
msg -> new_proc_id = ntohl(msg -> new_proc_id);
return msg;
};
Req_Msg* hton(Req_Msg* msg) {
msg -> type = htonl(msg -> type);
msg -> view_id = htonl(msg -> view_id);
msg -> operation = htonl(msg -> operation);
msg -> peer_id = htonl(msg -> peer_id);
return msg;
};
Req_Msg* ntoh(Req_Msg* msg) {
msg -> view_id = ntohl(msg -> view_id);
msg -> operation = ntohl(msg -> operation);
msg -> peer_id = ntohl(msg -> peer_id);
return msg;
};
OK_Msg* hton(OK_Msg* msg) {
msg -> type = htonl(msg -> type);
msg -> peer_id = htonl(msg -> peer_id);
return msg;
}
OK_Msg* ntoh(OK_Msg* msg) {
msg -> peer_id = ntohl(msg -> peer_id);
return msg;
}
join_msg* hton(join_msg* msg) {
msg -> type = htonl(msg -> type);
msg -> proc_id = htonl(msg -> proc_id);
return msg;
};
join_msg* ntoh(join_msg* msg) {
msg -> proc_id = ntohl(msg -> proc_id);
return msg;
};