aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/asn1/ain/ain.cnf
blob: a1f34e652c81b45d947c08a35f0fbb88f8a1582a (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# ain.cnf
# ain conformation file


#.EXPORTS

#.NO_EMIT ONLY_VALS
ROS

#.OMIT_ASSIGNMENT
# Removed as they are giving 'defined but not used' warnings currently.
Priority
RejectProblem

#.END

#.TYPE_RENAME

#.FIELD_RENAME

#.OMIT_ASSIGNMENT Remote-Operations-Information-Objects
Bind
Unbind
#.END

#.PDU
ERROR.&ParameterType
OPERATION.&ArgumentType
OPERATION.&ResultType

# This table creates the value_sting to name AIN operation codes and errors
# in file packet-ain-table.c which is included in the template file
#
#.TABLE_HDR
/* AIN OPERATIONS */
const value_string ain_opr_code_strings[] = {
#.TABLE_BODY OPERATION.&operationCode
  { %(&operationCode)-40s, "%(_ident)s" },
#.TABLE_FTR
  { 0, NULL }
};
#.END

#.TABLE_HDR
/* AIN ERRORS */
static const value_string ain_err_code_string_vals[] = {
#.TABLE_BODY ERROR.&errorCode
  { %(&errorCode)-40s, "%(_ident)s" },
#.TABLE_FTR
  { 0, NULL }
};
#.END

# This table creates the switch() to branch on AIN operation codes and errors
# in file packet-ain-table2.c which is included in the template file
#
#.TABLE2_HDR
static int dissect_invokeData(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx) {

  switch(opcode){
#.TABLE2_BODY OPERATION.&ArgumentType
    case %(&operationCode)s:  /* %(_ident)s */
      offset= %(_argument_pdu)s(tvb, actx->pinfo , tree , NULL);
      break;
#.TABLE2_FTR
    default:
      proto_tree_add_expert_format(tree, actx->pinfo, &ei_ain_unknown_invokeData,
                                   tvb, offset, -1, "Unknown invokeData %d", opcode);
      /* todo call the asn.1 dissector */
      break;
  }
  return offset;
}
#.END
#.TABLE2_HDR
static int dissect_returnResultData(proto_tree *tree, tvbuff_t *tvb, int offset,asn1_ctx_t *actx) {
  switch(opcode){
#.TABLE2_BODY OPERATION.&ResultType
    case %(&operationCode)s:  /* %(_ident)s */
      offset= %(_result_pdu)s(tvb, actx->pinfo , tree , NULL);
      break;
#.TABLE2_FTR
  default:
    proto_tree_add_expert_format(tree, actx->pinfo, &ei_ain_unknown_returnResultData,
                                 tvb, offset, -1, "Unknown returnResultData %d", opcode);
  }
  return offset;
}
#.END
#.TABLE2_HDR
static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset,asn1_ctx_t *actx) {
  switch(errorCode) {
#.TABLE2_BODY ERROR.&ParameterType
    case %(&errorCode)s:  /* %(_ident)s */
      offset= %(_parameter_pdu)s(tvb, actx->pinfo , tree , NULL);
      break;
#.TABLE2_FTR
  default:
    proto_tree_add_expert_format(tree, actx->pinfo, &ei_ain_unknown_returnErrorData,
                                 tvb, offset, -1, "Unknown returnErrorData %d", opcode);
  }
  return offset;
}
#.END

# Create a table of opcode and corresponding args and res
#.TABLE11_HDR
typedef struct _ain_op_t {
  gint32 opcode;
  dissector_t arg_pdu;
  dissector_t res_pdu;
} ain_op_t;

static const ain_op_t ain_op_tab[] = {
#.TABLE11_BODY OPERATION.&operationCode
  /* %(_name)-31s */ { %(&operationCode)-40s, %(_argument_pdu)-45s, %(_result_pdu)s },
#.TABLE11_FTR
};
#.END

#.TABLE11_HDR
typedef struct _ain_err_t {
  gint32 errcode;
  dissector_t err_pdu;
} ain_err_t;

static const ain_err_t ain_err_tab[] = {
#.TABLE11_BODY ERROR.&errorCode
  /* %(_name)-30s */ { %(&errorCode)4s, %(_parameter_pdu)s },
#.TABLE11_FTR
};
#.END

# ROS stuff here XXX change when TCAP is redone.

#.FN_BODY Code/local  VAL_PTR = &opcode
  %(DEFAULT_BODY)s
    if (ain_opcode_type == AIN_OPCODE_RETURN_ERROR){
      errorCode = opcode;
      col_append_str(actx->pinfo->cinfo, COL_INFO, val_to_str(errorCode, ain_err_code_string_vals, "Unknown AIN error (%%u)"));
      col_append_str(actx->pinfo->cinfo, COL_INFO, " ");
      col_set_fence(actx->pinfo->cinfo, COL_INFO);
    }else{
      col_append_str(actx->pinfo->cinfo, COL_INFO, val_to_str(opcode, ain_opr_code_strings, "Unknown AIN (%%u)"));
      col_append_str(actx->pinfo->cinfo, COL_INFO, " ");
      col_set_fence(actx->pinfo->cinfo, COL_INFO);
    }

#.FN_HDR Invoke

  ain_opcode_type=AIN_OPCODE_INVOKE;

#.FN_HDR ReturnResult

  ain_opcode_type=AIN_OPCODE_RETURN_RESULT;

#.FN_HDR ReturnError

  ain_opcode_type=AIN_OPCODE_RETURN_ERROR;

#.FN_HDR Reject

  ain_opcode_type=AIN_OPCODE_REJECT;

#.FN_BODY Invoke/argument

  offset = dissect_invokeData(tree, tvb, offset, actx);

#.FN_BODY ReturnResult/result/result

  offset = dissect_returnResultData(tree, tvb, offset, actx);

#.FN_BODY ReturnError/parameter

  offset = dissect_returnErrorData(tree, tvb, offset, actx);

# END ROS
#.FN_PARS ExtensionParameter/assignmentAuthority
  FN_VARIANT = _str  HF_INDEX = hf_ain_ext_type_oid  VAL_PTR = &actx->external.direct_reference

#.FN_BODY ExtensionParameter/parameters
  offset=call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL);

#.FN_BODY AINDigits VAL_PTR = &parameter_tvb
  tvbuff_t *parameter_tvb;
  proto_tree *subtree;

  %(DEFAULT_BODY)s

  if (!parameter_tvb)
    return offset;

  subtree = proto_item_add_subtree(actx->created_item, ett_ain_digits);
  proto_tree_add_item(subtree, hf_ain_odd_even_indicator, parameter_tvb, 0, 1, ENC_BIG_ENDIAN);
  proto_tree_add_item(subtree, hf_ain_nature_of_address, parameter_tvb, 0, 1, ENC_BIG_ENDIAN);

  proto_tree_add_item(subtree, hf_ain_numbering_plan, parameter_tvb, 1, 1, ENC_BIG_ENDIAN);

  proto_tree_add_item(subtree, hf_ain_bcd_digits, parameter_tvb, 2, tvb_reported_length_remaining(parameter_tvb, 2), ENC_BCD_DIGITS_0_9);

#.FN_BODY CarrierFormat VAL_PTR = &parameter_tvb
  tvbuff_t *parameter_tvb;
  proto_tree *subtree;

  %(DEFAULT_BODY)s

  if (!parameter_tvb)
    return offset;

  subtree = proto_item_add_subtree(actx->created_item, ett_ain_carrierformat);
  /* Carrier Selection */
  proto_tree_add_item(subtree, hf_ain_carrier_selection, parameter_tvb, 0, 1, ENC_BIG_ENDIAN);
  /*  Nature of Carrier Number of Digits (always 4 )*/
  proto_tree_add_item(subtree, hf_ain_nature_of_carrier, parameter_tvb, 1, 1, ENC_BIG_ENDIAN);
  proto_tree_add_item(subtree, hf_ain_nr_digits, parameter_tvb, 1, 1, ENC_BIG_ENDIAN);

  /* 2nd Digit 1st Digit .. */
  proto_tree_add_item(subtree, hf_ain_carrier_bcd_digits, parameter_tvb, 2, tvb_reported_length_remaining(parameter_tvb, 2), ENC_BCD_DIGITS_0_9);

#.FN_BODY AMAslpID VAL_PTR = &parameter_tvb
  tvbuff_t *parameter_tvb;
  proto_tree *subtree;

  %(DEFAULT_BODY)s

  if (!parameter_tvb)
    return offset;

  subtree = proto_item_add_subtree(actx->created_item, ett_ain_amaslpid);

  proto_tree_add_item(subtree, hf_ain_amaslpid, parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb, 0), ENC_BCD_DIGITS_0_9);

#.END

#
# Editor modelines  -  https://www.wireshark.org/tools/modelines.html
#
# Local variables:
# c-basic-offset: 2
# tab-width: 8
# indent-tabs-mode: nil
# End:
#
# vi: set shiftwidth=2 tabstop=8 expandtab:
# :indentSize=2:tabSize=8:noTabs=true:
#