forked from cisagov/icsnpp-opcua-binary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopcua_binary-write_debug.pac
59 lines (49 loc) · 2.23 KB
/
opcua_binary-write_debug.pac
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
## opcua_binary-write_debug.pac
##
## OPCUA Binary Protocol Analyzer
##
## Debug code for processing the write service.
##
## Author: Jason Rush
## Contact: [email protected]
##
## Copyright (c) 2024 Battelle Energy Alliance, LLC. All rights reserved.
%header{
void printWriteReq(Write_Req *msg);
void printWriteRes(Write_Res *msg);
%}
%code{
void printWriteReq(Write_Req *msg) {
printMsgHeader(msg->service()->msg_body()->header());
printMsgType(msg->service()->msg_body()->header());
printService(msg->service());
printf("%s %s\n", indent(2).c_str(), NODE_IDENTIFIER_MAP.find(msg->service()->identifier())->second.c_str());
printReqHdr(msg->req_hdr());
// Nodes to write
printf("%s NodesToWrite: Array of WriteValue\n", indent(3).c_str());
printf("%s ArraySize: %d\n", indent(4).c_str(), msg->nodes_to_write_size());
for (int i = 0; i < msg->nodes_to_write_size(); i++) {
printf("%s [%d]: WriteValue\n", indent(4).c_str(), i);
printOpcUA_WriteValue(5, msg->nodes_to_write()->at(i));
}
}
void printWriteRes(Write_Res *msg) {
printMsgHeader(msg->service()->msg_body()->header());
printMsgType(msg->service()->msg_body()->header());
printService(msg->service());
printf("%s %s\n", indent(2).c_str(), NODE_IDENTIFIER_MAP.find(msg->service()->identifier())->second.c_str());
printResHdr(msg->res_hdr());
printf("%s Results: Array of StatusCode\n", indent(3).c_str());
printf("%s ArraySize: %d\n", indent(4).c_str(), msg->results_size());
for (int i = 0; i < msg->results_size(); i++) {
printf("%s [%d]: Results: 0x%08x [%s]\n", indent(4).c_str(), i, msg->results()->at(i), STATUS_CODE_MAP.find(msg->results()->at(i))->second.c_str());
}
// Array of DiagnosticInfo(s)
printf("%s DiagnosticInfos: Array of DiagnosticInfo\n", indent(3).c_str());
printf("%s ArraySize: %d\n", indent(4).c_str(), msg->diagnostic_info_size());
for (int i = 0; i < msg->diagnostic_info_size(); i++) {
printf("%s [%d]: DiagnosticInfo\n", indent(4).c_str(), i);
printOpcUA_DiagInfo(5, msg->diagnostic_info()->at(i));
}
}
%}