aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/q932/q932-ros.cnf
blob: bdf39ab6167b455b59011b832d59f4b300749cbc (plain)
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#.PDU_NEW

ROS

#.OMIT_ASSIGNMENT

Priority
RejectProblem
Components
GFPInvokeIDSet
 
#.TYPE_RENAME

Invoke/argument             InvokeArgument
ReturnResult/result/result  ResultArgument

#.FIELD_RENAME

Invoke/linkedId/present     linkedIdPresent

Reject/problem/invoke       invokeProblem
Reject/problem/returnError  returnErrorProblem
Reject/problem/returnResult returnResultProblem

ReturnResult/result/result  resultArgument

#--- ROS ---

#.FN_HDR ROS
  /* will be moved to ROS_PDU when PDU function can be alternated from conformance file */
  actx->rose_ctx = rose_ctx_tmp;
  rose_ctx_clean_data(actx->rose_ctx);
#.END

#--- Code ---

#.FN_PARS
Code         VAL_PTR = &%(ACTX)s->rose_ctx->d.code
Code/local   VAL_PTR = &%(ACTX)s->rose_ctx->d.code_local
Code/global  FN_VARIANT = _str  VAL_PTR = &%(ACTX)s->rose_ctx->d.code_global
#.FN_FTR Code
  actx->rose_ctx->d.code_item = actx->created_item;
#.END

#--- Problem ---

#.FN_PARS
GeneralProblem       VAL_PTR = &problem_val
InvokeProblem        VAL_PTR = &problem_val
ReturnResultProblem  VAL_PTR = &problem_val
ReturnErrorProblem   VAL_PTR = &problem_val
#.FN_FTR GeneralProblem
  strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_GeneralProblem_vals), ""));
#.FN_FTR InvokeProblem
  strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_InvokeProblem_vals), ""));
#.FN_FTR ReturnResultProblem
  strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnResultProblem_vals), ""));
#.FN_FTR ReturnErrorProblem
  strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnErrorProblem_vals), ""));
#.END

#--- INVOKE ---

#.FIELD_ATTR
Invoke/argument  TYPE = FT_BYTES  DISPLAY = BASE_HEX

#.FN_BODY Invoke/argument
  gint len;

  len = tvb_length_remaining(tvb, offset);
  if (len)
    proto_tree_add_item(tree, hf_index, tvb, offset, len, FALSE);
  arg_next_tvb = tvb_new_subset(tvb, offset, len, len);

  offset += tvb_length_remaining(tvb, offset);

#.FN_HDR Invoke
  dissector_handle_t arg_handle = NULL;

  arg_next_tvb = NULL;
#.FN_FTR Invoke
  actx->rose_ctx->d.pdu = 1;

  if (actx->rose_ctx->d.code == 0) {
    arg_handle = dissector_get_port_handle(actx->rose_ctx->arg_local_dissector_table, actx->rose_ctx->d.code_local);
  } else if (actx->rose_ctx->d.code == 1) {
    arg_handle = dissector_get_string_handle(actx->rose_ctx->arg_global_dissector_table, actx->rose_ctx->d.code_global);
  } else {
    arg_handle = NULL;
  }

  proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  INV:");
  if (!arg_handle || 
      !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(arg_handle)))) {
    if (actx->rose_ctx->d.code == 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %d", actx->rose_ctx->d.code_local);
    else if (actx->rose_ctx->d.code == 1)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %s", actx->rose_ctx->d.code_global);
  }
  if (!arg_next_tvb) {  /* empty argument */
    arg_next_tvb = tvb_new_subset(tvb, offset, 0, 0);
  }
  actx->pinfo->private_data = actx->rose_ctx;
  call_dissector((arg_handle)?arg_handle:data_handle, arg_next_tvb, actx->pinfo, tree);
#.END


#--- RETURN RESULT ---

#.FIELD_ATTR
ReturnResult/result/result  TYPE = FT_BYTES  DISPLAY = BASE_HEX

#.FN_BODY ReturnResult/result/result
  gint len;

  len = tvb_length_remaining(tvb, offset);
  if (len)
    proto_tree_add_item(tree, hf_index, tvb, offset, len, FALSE);
  res_next_tvb = tvb_new_subset(tvb, offset, len, len);

  offset += tvb_length_remaining(tvb, offset);

#.FN_HDR ReturnResult
  dissector_handle_t res_handle = NULL;

  res_next_tvb = NULL;
#.FN_FTR ReturnResult
  actx->rose_ctx->d.pdu = 2;

  if (actx->rose_ctx->d.code == 0) {
    res_handle = dissector_get_port_handle(actx->rose_ctx->res_local_dissector_table, actx->rose_ctx->d.code_local);
  } else if (actx->rose_ctx->d.code == 1) {
    res_handle = dissector_get_string_handle(actx->rose_ctx->res_global_dissector_table, actx->rose_ctx->d.code_global);
  } else {
    res_handle = NULL;
  }

  proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  RES:");
  if (!res_handle || 
      !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(res_handle)))) {
    if (actx->rose_ctx->d.code == 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %d", actx->rose_ctx->d.code_local);
    else if (actx->rose_ctx->d.code == 1)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %s", actx->rose_ctx->d.code_global);
  }
  if (!res_next_tvb) {  /* empty result */
    res_next_tvb = tvb_new_subset(tvb, offset, 0, 0);
  }
  actx->pinfo->private_data = actx->rose_ctx;
  call_dissector((res_handle)?res_handle:data_handle, res_next_tvb, actx->pinfo, tree); 
#.END

#--- RETURN ERROR ---

#.FIELD_ATTR
ReturnError/parameter  TYPE = FT_BYTES  DISPLAY = BASE_HEX

#.FN_BODY ReturnError/parameter

  gint len;

  len = tvb_length_remaining(tvb, offset);
  if (len)
    proto_tree_add_item(tree, hf_index, tvb, offset, len, FALSE);
  err_next_tvb = tvb_new_subset(tvb, offset, len, len);

  offset += tvb_length_remaining(tvb, offset);

#.FN_HDR ReturnError
  dissector_handle_t err_handle = NULL;

  err_next_tvb = NULL;
#.FN_FTR ReturnError
  actx->rose_ctx->d.pdu = 3;

  if (actx->rose_ctx->d.code == 0) {
    err_handle = dissector_get_port_handle(actx->rose_ctx->err_local_dissector_table, actx->rose_ctx->d.code_local);
  } else if (actx->rose_ctx->d.code == 1) {
    err_handle = dissector_get_string_handle(actx->rose_ctx->err_global_dissector_table, actx->rose_ctx->d.code_global);
  } else {
    err_handle = NULL;
  }

  proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  ERR:");
  if (!err_handle || 
      !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(err_handle)))) {
    if (actx->rose_ctx->d.code == 0)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %d", actx->rose_ctx->d.code_local);
    else if (actx->rose_ctx->d.code == 1)
      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %s", actx->rose_ctx->d.code_global);
  }
  if (!err_next_tvb) {  /* empty error */
    err_next_tvb = tvb_new_subset(tvb, offset, 0, 0);
  }
  actx->pinfo->private_data = actx->rose_ctx;
  call_dissector((err_handle)?err_handle:data_handle, err_next_tvb, actx->pinfo, tree); 
#.END

#--- REJECT ---

#.FN_HDR Reject
  problem_str[0] = '\0';
#.FN_FTR Reject
  proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), "  REJ: %s", problem_str);
#.END