forked from cisagov/icsnpp-opcua-binary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opcua_binary-browse_debug.pac
134 lines (110 loc) · 7.16 KB
/
opcua_binary-browse_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
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
## opcua_binary-browse_debug.pac
##
## OPCUA Binary Protocol Analyzer
##
## Debug code for processing the browse service.
##
## Author: Melanie Pierce
## Contact: [email protected]
##
## Copyright (c) 2022 Battelle Energy Alliance, LLC. All rights reserved.
%header{
void printBrowseReq(Browse_Req *msg);
void printBrowseRes(Browse_Res *msg);
void printBrowseNextReq (Browse_Next_Req *msg);
%}
%code{
void printBrowseReq(Browse_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());
printOpcUA_ViewDescription(3, msg->view_description());
printf("%s RequestedMaxReferencesPerNode: %d\n", indent(3).c_str(), msg->req_max_refs_per_node());
printf("%s NodesToBrowse: Array of BrowseDescription\n", indent(3).c_str());
printf("%s ArraySize: %d\n", indent(4).c_str(), msg->num_nodes_to_browse());
for (int32_t i = 0; i < msg->num_nodes_to_browse(); i++) {
printf("%s [%d]: BrowseDescription\n", indent(4).c_str(), i);
printf("%s NodeId: NodeId\n", indent(5).c_str());
printOpcUA_NodeId(6, msg->nodes_to_browse()->at(i)->node_id());
printf("%s BrowseDirection: 0x%08x\n", indent(5).c_str(), msg->nodes_to_browse()->at(i)->browse_direction_id());
printf("%s ReferenceTypeId: NodeId\n", indent(5).c_str());
printOpcUA_NodeId(6, msg->nodes_to_browse()->at(i)->ref_type_id());
if (msg->nodes_to_browse()->at(i)->include_subtypes() == 1){
printf("%s IncludeSubtypes: True\n",indent(5).c_str());
} else {
printf("%s IncludeSubtypes: False\n", indent(5).c_str());
}
printf("%s Node Class Mask: %s\n", indent(5).c_str(), NODE_CLASSES_MAP.find(msg->nodes_to_browse()->at(i)->node_class_mask())->second.c_str());
printf("%s Result Mask: 0x%08x\n", indent(5).c_str(), msg->nodes_to_browse()->at(i)->result_mask());
}
return;
}
void printBrowseRes(Browse_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 BrowseResult\n", indent(3).c_str());
printf("%s ArraySize: %d\n", indent(4).c_str(), msg->results_table_size());
for (int32_t i = 0; i < msg->results_table_size(); i++) {
printf("%s [%d]: BrowseResult\n", indent(4).c_str(), i);
printf("%s StatusCode: 0x%08x [%s]\n", indent(5).c_str(), msg->results()->at(i)->status_code(), STATUS_CODE_MAP.find(msg->results()->at(i)->status_code())->second.c_str());
printf("%s ContinuationPoint: %s\n", indent(5).c_str(), bytestringToHexstring(msg->results()->at(i)->continuation_point()->byteString()).c_str());
printf("%s References: Array of ReferenceDescription\n", indent(5).c_str());
printf("%s ArraySize: %d\n", indent(6).c_str(), msg->results()->at(i)->num_references());
for (int32_t j = 0; j < msg->results()->at(i)->num_references(); j++) {
printf("%s [%d]: ReferenceDescription\n", indent(6).c_str(), j);
printf("%s ReferenceTypeId: NodeId\n", indent(7).c_str());
printOpcUA_NodeId(8, msg->results()->at(i)->references()->at(j)->ref_type_id());
if (msg->results()->at(i)->references()->at(j)->is_forward() == 1){
printf("%s IsForward: True\n",indent(7).c_str());
} else {
printf("%s IsForward: False\n", indent(7).c_str());
}
printf("%s NodeId: ExpandedNodeId\n", indent(7).c_str());
printOpcUA_ExpandedNodeId(8, msg->results()->at(i)->references()->at(j)->target_node_id());
printf("%s BrowseName: QualifiedName\n", indent(7).c_str());
printf("%s Id: %d\n", indent(8).c_str(), msg->results()->at(i)->references()->at(j)->browse_name()->namespace_index());
printf("%s Name: %s\n", indent(8).c_str(), std_str(msg->results()->at(i)->references()->at(j)->browse_name()->name()->string()).c_str());
printf("%s DisplayName: LocalizedText\n", indent(7).c_str());
printf("%s EncodingMask: 0x%02x\n", indent(8).c_str(), msg->results()->at(i)->references()->at(j)->display_name()->encoding_mask());
if (isBitSet(msg->results()->at(i)->references()->at(j)->display_name()->encoding_mask(), localizedTextHasLocale)) {
printf("%s Locale: %s\n", indent(8).c_str(), std_str(msg->results()->at(i)->references()->at(j)->display_name()->locale()->string()).c_str());
}
if (isBitSet(msg->results()->at(i)->references()->at(j)->display_name()->encoding_mask(), localizedTextHasText)) {
printf("%s Text: %s\n", indent(8).c_str(), std_str(msg->results()->at(i)->references()->at(j)->display_name()->text()->string()).c_str());
}
printf("%s NodeClass: %s (0x%08x)\n", indent(7).c_str(), NODE_CLASSES_MAP.find(msg->results()->at(i)->references()->at(j)->node_class())->second.c_str(), msg->results()->at(i)->references()->at(j)->node_class());
printf("%s TypeDefinition: ExpandedNodeId\n", indent(7).c_str());
printOpcUA_ExpandedNodeId(8, msg->results()->at(i)->references()->at(j)->type_definition());
}
}
// Array of DiagnosticInfo(s)
printf("%s Results: Array of DiagnosticInfo\n", indent(3).c_str());
printf("%s ArraySize: %d\n", indent(4).c_str(), msg->diag_info_size());
for (int i = 0; i < msg->diag_info_size(); i++) {
printf("%s [%d]: DiagnosticInfo\n", indent(4).c_str(), i);
printOpcUA_DiagInfo(5, msg->diag_info()->at(i));
}
}
void printBrowseNextReq (Browse_Next_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());
if (msg->release_continuation_points() == 1){
printf("%s ReleaseContinuationPoints: True\n",indent(3).c_str());
} else {
printf("%s ReleaseContinuationPoints: False\n", indent(3).c_str());
}
printf("%s ContinuationPoints: Array of ByteString\n", indent(3).c_str());
printf("%s ArraySize: %d\n", indent(4).c_str(), msg->num_continuation_points());
for (int32_t i = 0; i < msg->num_continuation_points(); i++) {
printf("%s [%d]: ContinuationPoints: %s\n", indent(4).c_str(), i, bytestringToHexstring(msg->continuation_points()->at(i)->byteString()).c_str());
}
}
%}