Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ses.c
Line
Count
Source
1
/* packet-ses.c
2
 *
3
 * Routine to dissect ITU-T Rec. X.225 (1995 E)/ISO 8327-1 OSI Session Protocol packets
4
 *
5
 * Yuriy Sidelnikov <YSidelnikov@hotmail.com>
6
 *
7
 * Wireshark - Network traffic analyzer
8
 * By Gerald Combs <gerald@wireshark.org>
9
 * Copyright 1998 Gerald Combs
10
 *
11
 * SPDX-License-Identifier: GPL-2.0-or-later
12
 */
13
14
#include "config.h"
15
16
#include <epan/packet.h>
17
#include <epan/expert.h>
18
#include <epan/prefs.h>
19
#include <epan/conversation.h>
20
#include <epan/reassemble.h>
21
#include <epan/proto_data.h>
22
#include <epan/tfs.h>
23
#include <wsutil/array.h>
24
#include <wsutil/str_util.h>
25
26
#include "packet-ber.h"
27
#include "packet-ses.h"
28
29
void proto_register_ses(void);
30
void proto_reg_handoff_ses(void);
31
32
void proto_register_clses(void);
33
void proto_reg_handoff_clses(void);
34
35
/* ses header fields             */
36
static int proto_ses;
37
static int hf_ses_type;
38
static int hf_ses_type_0;
39
static int hf_ses_length;
40
/* static int hf_ses_version; */
41
/* static int hf_ses_reserved; */
42
43
static int hf_ses_segment_data;
44
static int hf_ses_segments;
45
static int hf_ses_segment;
46
static int hf_ses_segment_overlap;
47
static int hf_ses_segment_overlap_conflicts;
48
static int hf_ses_segment_multiple_tails;
49
static int hf_ses_segment_too_long_segment;
50
static int hf_ses_segment_error;
51
static int hf_ses_segment_count;
52
static int hf_ses_reassembled_in;
53
static int hf_ses_reassembled_length;
54
55
/* ses fields defining a sub tree */
56
static int ett_ses;
57
static int ett_ses_param;
58
59
static int ett_ses_segment;
60
static int ett_ses_segments;
61
62
63
/* flags */
64
static int hf_connect_protocol_options_flags;
65
static int hf_version_number_options_flags;
66
static int hf_enclosure_item_options_flags;
67
static int hf_token_item_options_flags;
68
69
static int ett_connect_protocol_options_flags;
70
static int ett_transport_options_flags;
71
static int ett_protocol_version_flags;
72
static int ett_enclosure_item_flags;
73
static int ett_token_item_flags;
74
static int ett_ses_req_options_flags;
75
76
/* called SS user reference */
77
static int hf_called_ss_user_reference;
78
79
/* calling SS user reference */
80
static int hf_calling_ss_user_reference;
81
82
/* common reference */
83
static int hf_common_reference;
84
85
/* additional reference information */
86
static int hf_additional_reference_information;
87
88
/* token item */
89
static int hf_release_token;
90
static int hf_major_activity_token;
91
static int hf_synchronize_minor_token;
92
static int hf_data_token;
93
94
/* protocol options */
95
static int hf_able_to_receive_extended_concatenated_SPDU;
96
97
/* session requirement */
98
static int hf_session_user_req_flags;
99
static int hf_session_exception_report;
100
static int hf_data_separation_function_unit;
101
static int hf_symmetric_synchronize_function_unit;
102
static int hf_typed_data_function_unit;
103
static int hf_exception_function_unit;
104
static int hf_capability_function_unit;
105
static int hf_negotiated_release_function_unit;
106
static int hf_activity_management_function_unit;
107
static int hf_resynchronize_function_unit;
108
static int hf_major_resynchronize_function_unit;
109
static int hf_minor_resynchronize_function_unit;
110
static int hf_expedited_data_resynchronize_function_unit;
111
static int hf_duplex_function_unit;
112
static int hf_half_duplex_function_unit;
113
114
/* TSDU maximum size */
115
static int hf_proposed_tsdu_maximum_size_i2r;
116
static int hf_proposed_tsdu_maximum_size_r2i;
117
118
/* protocol version */
119
static int hf_protocol_version_1;
120
static int hf_protocol_version_2;
121
122
/* initial serial number */
123
static int hf_initial_serial_number;
124
125
/* enclosure item */
126
static int hf_beginning_of_SSDU;
127
static int hf_end_of_SSDU;
128
129
/* token setting item */
130
131
static const value_string token_setting_vals[] = {
132
  { 0x00, "initiator's side" },
133
  { 0x01, "responder's side" },
134
  { 0x02, "called SS user's choice" },
135
  { 0x03, "reserved" },
136
  { 0, NULL }
137
};
138
139
static const true_false_string tfs_released_kept = { "Released", "Kept" };
140
141
static int hf_release_token_setting;
142
static int hf_major_activity_token_setting;
143
static int hf_synchronize_minor_token_setting;
144
static int hf_data_token_setting;
145
146
/* calling session selector */
147
static int hf_calling_session_selector;
148
149
/* called session selector */
150
static int hf_called_session_selector;
151
152
/* activity id */
153
static int hf_activity_identifier;
154
155
/* serial number */
156
static int hf_serial_number;
157
158
/* second serial number */
159
static int hf_second_serial_number;
160
161
/* second initial serial number */
162
static int hf_second_initial_serial_number;
163
164
/* large initial serial number */
165
static int hf_large_initial_serial_number;
166
167
/* large second initial serial number */
168
static int hf_large_second_initial_serial_number;
169
170
/* Generated from convert_proto_tree_add_text.pl */
171
static int hf_ses_reason_code;
172
static int hf_ses_transport_implementation_restriction;
173
static int hf_ses_transport_no_reason;
174
static int hf_ses_parameter_group_inside_parameter_group;
175
static int hf_ses_user_data;
176
static int hf_ses_parameter_type;
177
static int hf_ses_transport_protocol_error;
178
static int hf_ses_transport_user_abort;
179
static int hf_ses_parameter_length;
180
static int hf_ses_transport_connection;
181
static int hf_ses_transport_option_flags;
182
183
/* clses header fields             */
184
static int proto_clses;
185
186
static expert_field ei_ses_bad_length;
187
static expert_field ei_ses_bad_parameter_length;
188
189
16
#define PROTO_STRING_CLSES "ISO 9548-1 OSI Connectionless Session Protocol"
190
191
static dissector_handle_t pres_handle;
192
193
static reassembly_table ses_reassembly_table;
194
195
static const fragment_items ses_frag_items = {
196
  /* Segment subtrees */
197
  &ett_ses_segment,
198
  &ett_ses_segments,
199
  /* Segment fields */
200
  &hf_ses_segments,
201
  &hf_ses_segment,
202
  &hf_ses_segment_overlap,
203
  &hf_ses_segment_overlap_conflicts,
204
  &hf_ses_segment_multiple_tails,
205
  &hf_ses_segment_too_long_segment,
206
  &hf_ses_segment_error,
207
  &hf_ses_segment_count,
208
  /* Reassembled in field */
209
  &hf_ses_reassembled_in,
210
  /* Reassembled length field */
211
  &hf_ses_reassembled_length,
212
  /* Reassembled data field */
213
  NULL,
214
  /* Tag */
215
  "SES segments"
216
};
217
218
219
static const value_string ses_vals[] =
220
{
221
  {SES_DATA_TRANSFER,                  "DATA TRANSFER (DT) SPDU" },            /*  1 */
222
  {SES_PLEASE_TOKENS,                  "PLEASE TOKENS (PT) SPDU"   },          /*  2 */
223
  {SES_EXPEDITED,                      "EXPEDITED (EX) SPDU"   },              /*  5 */
224
  {SES_PREPARE,                        "PREPARE (PR) SPDU"   },                /*  7 */
225
  {SES_NOT_FINISHED,                   "NOT FINISHED (NF) SPDU"   },           /*  8 */
226
  {SES_FINISH,                         "FINISH (FN) SPDU"   },                 /*  9 */
227
  {SES_DISCONNECT,                     "DISCONNECT (DN) SPDU"   },             /* 10 */
228
  {SES_REFUSE,                         "REFUSE (RF) SPDU"   },                 /* 12 */
229
  {SES_CONNECTION_REQUEST,             "CONNECT (CN) SPDU" },                  /* 13 */
230
  {SES_CONNECTION_ACCEPT,              "ACCEPT (AC) SPDU" },                   /* 14 */
231
  {SES_CONNECTION_DATA_OVERFLOW,       "CONNECT DATA OVERFLOW (CDO) SPDU"},    /* 15 */
232
  {SES_OVERFLOW_ACCEPT,                "OVERFLOW ACCEPT (OA) SPDU"   },        /* 16 */
233
  {SES_GIVE_TOKENS_CONFIRM,            "GIVE TOKENS CONFIRM (GTC) SPDU"},      /* 21 */
234
  {SES_GIVE_TOKENS_ACK,                "GIVE TOKENS ACK (GTA) SPDU"   },       /* 22 */
235
  {SES_ABORT,                          "ABORT (AB) SPDU"   },                  /* 25 */
236
  {SES_ABORT_ACCEPT,                   "ABORT ACCEPT (AA) SPDU"   },           /* 26 */
237
  {SES_ACTIVITY_RESUME,                "ACTIVITY RESUME (AR) SPDU"   },        /* 29 */
238
  {SES_TYPED_DATA,                     "TYPED DATA (TD) SPDU"   },             /* 33 */
239
  {SES_RESYNCHRONIZE_ACK,              "RESYNCHRONIZE ACK (RA) SPDU"   },      /* 34 */
240
  {SES_MAJOR_SYNC_POINT,               "MAJOR SYNC POINT (MAP) SPDU"   },      /* 41 */
241
  {SES_MAJOR_SYNC_ACK,                 "MAJOR SYNC ACK (MAA) SPDU"   },        /* 42 */
242
  {SES_ACTIVITY_START,                 "ACTIVITY START (AS) SPDU"   },         /* 45 */
243
  {SES_EXCEPTION_DATA,                 "EXCEPTION DATA (ED) SPDU"   },         /* 48 */
244
  {SES_MINOR_SYNC_POINT,               "MINOR SYNC POINT (MIP) SPDU"   },      /* 49 */
245
  {SES_MINOR_SYNC_ACK,                 "MINOR SYNC ACK (MIA) SPDU"   },        /* 50 */
246
  {SES_RESYNCHRONIZE,                  "RESYNCHRONIZE (RS) SPDU"   },          /* 53 */
247
  {SES_ACTIVITY_DISCARD,               "ACTIVITY DISCARD (AD) SPDU"   },       /* 57 */
248
  {SES_ACTIVITY_DISCARD_ACK,           "ACTIVITY DISCARD ACK (ADA) SPDU" },    /* 58 */
249
  {SES_CAPABILITY,                     "CAPABILITY DATA (CD) SPDU"   },        /* 61 */
250
  {SES_CAPABILITY_DATA_ACK,            "CAPABILITY DATA ACK (CDA) SPDU" },     /* 62 */
251
  {CLSES_UNIT_DATA,                    "UNIT DATA (UD) SPDU" },                /* 64 */
252
  {SES_EXCEPTION_REPORT,               "EXCEPTION REPORT (ER) SPDU"   },       /* 0x2000 */
253
  {0, NULL }
254
};
255
value_string_ext ses_vals_ext = VALUE_STRING_EXT_INIT(ses_vals);
256
257
static const value_string ses_category0_vals[] =
258
{
259
  {SES_PLEASE_TOKENS,                  "Please tokens PDU" },
260
  {SES_GIVE_TOKENS,                    "Give tokens PDU" },
261
  {0, NULL }
262
};
263
264
265
static const value_string param_vals[] =
266
{
267
  {Connection_Identifier,              "Connection Identifier"},              /*   1 */
268
  {Connect_Accept_Item,                "Connect Accept Item"},                /*   5 */
269
  {Called_SS_user_Reference,           "Called SS user Reference"},           /*   9 */
270
  {Calling_SS_user_Reference,          "Calling SS user Reference"},          /*  10 */
271
  {Common_Reference,                   "Common Reference"},                   /*  11 */
272
  {Additional_Reference_Information,   "Additional Reference Information"},   /*  12 */
273
  {Sync_Type_Item,                     "Sync Type Item"},                     /*  15 */
274
  {Token_Item,                         "Token Item"},                         /*  16 */
275
  {Transport_Disconnect,               "Transport_Disconnect"},               /*  17 */
276
  {Protocol_Options,                   "Protocol Options"},                   /*  19 */
277
  {Session_Requirement,                "Session Requirement"},                /*  20 */
278
  {TSDU_Maximum_Size,                  "TSDU Maximum Size"},                  /*  21 */
279
  {Version_Number,                     "Version Number"},                     /*  22 */
280
  {Initial_Serial_Number,              "Initial Serial Number"},              /*  23 */
281
  {Prepare_Type,                       "Prepare Type"},                       /*  24 */
282
  {EnclosureItem,                      "Enclosure Item"},                     /*  25 */
283
  {Token_Setting_Item,                 "Token Setting Item"},                 /*  26 */
284
  {Resync_Type,                        "Resync Type"},                        /*  27 */
285
  {Linking_Information,                "Linking Information"},                /*  33 */
286
  {Activity_Identifier,                "Activity Identifier"},                /*  41 */
287
  {Serial_Number,                      "Serial Number"},                      /*  42 */
288
  {Reflect_Parameter,                  "Reflect Parameter"},                  /*  49 */
289
  {Reason_Code,                        "Reason Code"},                        /*  50 */
290
  {Calling_Session_Selector,           "Calling Session Selector"},           /*  51 */
291
  {Called_Session_Selector,            "Called Session Selector"},            /*  52 */
292
  {Second_Resync_Type,                 "Second Resync Type"},                 /*  53 */
293
  {Second_Serial_Number,               "Second Serial Number"},               /*  54 */
294
  {Second_Initial_Serial_Number,       "Second Initial Serial Number"},       /*  55 */
295
  {Upper_Limit_Serial_Number,          "Upper Limit Serial Number"},          /*  56 */
296
  {Large_Initial_Serial_Number,        "Large Initial Serial Number"},        /*  57 */
297
  {Large_Second_Initial_Serial_Number, "Large Second Initial Serial Number"}, /*  58 */
298
  {Data_Overflow,                      "Data Overflow"},                      /*  60 */
299
  {User_Data,                          "Session user data"},                  /* 193 */
300
  {Extended_User_Data,                 "Session extended user data"},         /* 194 */
301
  {0, NULL}
302
};
303
static value_string_ext param_vals_ext = VALUE_STRING_EXT_INIT(param_vals);
304
305
static const value_string reason_vals[] =
306
{
307
  {reason_not_specified,               "Rejection by called SS-user; reason not specified" },
308
  {temporary_congestion,               "Rejection by called SS-user due to temporary congestion"   },
309
  {Subsequent,                         "Rejection by called SS-user."   },
310
  {SES_DISCONNECT,                     "Rejection by the SPM; implementation restriction stated in the PICS"   },
311
  {Session_Selector_unknown,           "Session Selector unknown" },
312
  {SS_user_not_attached_to_SSAP,       "SS-user not attached to SSAP"   },
313
  {SPM_congestion_at_connect_time,     "SPM congestion at connect time"   },
314
  {versions_not_supported,             "Proposed protocol versions not supported"   },
315
  {SPM_reason_not_specified,           "Rejection by the SPM; reason not specified"   },
316
  {SPM_implementation_restriction,     "Finish PDU"   },
317
  {0, NULL }
318
};
319
static value_string_ext reason_vals_ext = VALUE_STRING_EXT_INIT(reason_vals);
320
321
/* desegmentation of OSI over ses  */
322
static bool ses_desegment = true;
323
324
/* RTSE reassembly data */
325
static unsigned ses_pres_ctx_id;
326
static bool ses_rtse_reassemble;
327
328
static void
329
call_pres_dissector(tvbuff_t *tvb, int offset, uint16_t param_len,
330
        packet_info *pinfo, proto_tree *tree,
331
        proto_tree *param_tree,
332
        struct SESSION_DATA_STRUCTURE *session)
333
127
{
334
  /* do we have OSI presentation packet dissector ? */
335
127
  if(!pres_handle)
336
0
  {
337
    /* No - display as data */
338
0
    if (tree)
339
0
    {
340
0
      proto_tree_add_item(param_tree, hf_ses_user_data, tvb, offset, param_len, ENC_NA);
341
0
    }
342
0
  }
343
127
  else
344
127
  {
345
    /* Yes - call presentation dissector */
346
127
    tvbuff_t *next_tvb;
347
348
127
    next_tvb = tvb_new_subset_length(tvb, offset, param_len);
349
    /* Pass the session pdu to the presentation dissector  */
350
127
    call_dissector_with_data(pres_handle, next_tvb, pinfo, tree, session);
351
127
  }
352
127
}
353
354
/* this routine returns length of parameter field, parameter group,
355
   or parameter */
356
static int
357
get_item_len(tvbuff_t *tvb, int offset, int *len_len)
358
9.84k
{
359
9.84k
  uint16_t len;
360
361
9.84k
  len = tvb_get_uint8(tvb, offset);
362
9.84k
  if(len == TWO_BYTE_LEN)
363
338
  {
364
338
    len = tvb_get_ntohs(tvb, offset+1);
365
338
    *len_len = 3;
366
338
  }
367
9.50k
  else
368
9.50k
    *len_len = 1;
369
9.84k
  return len;
370
9.84k
}
371
372
static bool
373
dissect_parameter(tvbuff_t *tvb, int offset, proto_tree *tree,
374
            proto_tree *param_tree, packet_info *pinfo, uint8_t param_type,
375
            uint16_t param_len, proto_item *param_len_item, uint8_t *enclosure_item_flags,
376
      struct SESSION_DATA_STRUCTURE *session)
377
3.86k
{
378
3.86k
  bool has_user_information = true;
379
3.86k
  uint16_t      flags;
380
3.86k
  asn1_ctx_t asn1_ctx;
381
3.86k
  static int * const item_option_flags[] = {
382
3.86k
    &hf_release_token,
383
3.86k
    &hf_major_activity_token,
384
3.86k
    &hf_synchronize_minor_token,
385
3.86k
    &hf_data_token,
386
3.86k
    NULL
387
3.86k
  };
388
3.86k
  static int * const transport_option_flags[] = {
389
3.86k
    &hf_ses_transport_connection,
390
3.86k
    &hf_ses_transport_user_abort,
391
3.86k
    &hf_ses_transport_protocol_error,
392
3.86k
    &hf_ses_transport_no_reason,
393
3.86k
    &hf_ses_transport_implementation_restriction,
394
3.86k
    NULL
395
3.86k
  };
396
3.86k
  static int * const protocol_options_flags[] = {
397
3.86k
    &hf_able_to_receive_extended_concatenated_SPDU,
398
3.86k
    NULL
399
3.86k
  };
400
3.86k
  static int * const req_options_flags[] = {
401
3.86k
    &hf_session_exception_report,
402
3.86k
    &hf_data_separation_function_unit,
403
3.86k
    &hf_symmetric_synchronize_function_unit,
404
3.86k
    &hf_typed_data_function_unit,
405
3.86k
    &hf_exception_function_unit,
406
3.86k
    &hf_capability_function_unit,
407
3.86k
    &hf_negotiated_release_function_unit,
408
3.86k
    &hf_activity_management_function_unit,
409
3.86k
    &hf_resynchronize_function_unit,
410
3.86k
    &hf_major_resynchronize_function_unit,
411
3.86k
    &hf_minor_resynchronize_function_unit,
412
3.86k
    &hf_expedited_data_resynchronize_function_unit,
413
3.86k
    &hf_duplex_function_unit,
414
3.86k
    &hf_half_duplex_function_unit,
415
3.86k
    NULL
416
3.86k
  };
417
3.86k
  static int * const version_flags[] = {
418
3.86k
    &hf_protocol_version_2,
419
3.86k
    &hf_protocol_version_1,
420
3.86k
    NULL
421
3.86k
  };
422
3.86k
  static int * const enclosure_flags[] = {
423
3.86k
    &hf_end_of_SSDU,
424
3.86k
    &hf_beginning_of_SSDU,
425
3.86k
    NULL
426
3.86k
  };
427
428
3.86k
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
429
430
3.86k
  switch (param_type)
431
3.86k
  {
432
28
  case Called_SS_user_Reference:
433
28
    if (param_len == 0)
434
16
      break;
435
436
12
    proto_tree_add_item(param_tree,
437
12
          hf_called_ss_user_reference,
438
12
          tvb, offset, param_len, ENC_NA);
439
12
    break;
440
441
30
  case Calling_SS_user_Reference:
442
30
    if (param_len == 0)
443
18
      break;
444
445
12
    proto_tree_add_item(param_tree,
446
12
          hf_calling_ss_user_reference,
447
12
          tvb, offset, param_len, ENC_NA);
448
12
    break;
449
450
28
  case Common_Reference:
451
28
    if (param_len == 0)
452
5
      break;
453
454
23
    proto_tree_add_item(param_tree,
455
23
          hf_common_reference,
456
23
          tvb, offset, param_len, ENC_NA);
457
23
    break;
458
459
27
  case Additional_Reference_Information:
460
27
    if (param_len == 0)
461
4
      break;
462
463
23
    proto_tree_add_item(param_tree,
464
23
          hf_additional_reference_information,
465
23
          tvb, offset, param_len, ENC_NA);
466
23
    break;
467
468
53
  case Token_Item:
469
53
    if (param_len != 1)
470
46
    {
471
46
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
472
46
          "Length is %u, should be 1", param_len);
473
46
      break;
474
46
    }
475
476
7
    proto_tree_add_bitmask(param_tree, tvb, offset, hf_token_item_options_flags, ett_token_item_flags, item_option_flags, ENC_NA);
477
7
    break;
478
479
21
  case Transport_Disconnect:
480
21
    if (param_len != 1)
481
13
    {
482
13
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
483
13
          "Length is %u, should be 1", param_len);
484
13
      break;
485
13
    }
486
8
    proto_tree_add_bitmask(param_tree, tvb, offset, hf_ses_transport_option_flags, ett_transport_options_flags, transport_option_flags, ENC_NA);
487
488
8
    if(tvb_get_uint8(tvb, offset) & user_abort )
489
3
    {
490
3
      session->abort_type = SESSION_USER_ABORT;
491
3
    }
492
5
    else
493
5
    {
494
5
      session->abort_type = SESSION_PROVIDER_ABORT;
495
5
    }
496
8
    break;
497
498
15
  case Protocol_Options:
499
15
    if (param_len != 1)
500
15
    {
501
15
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
502
15
          "Length is %u, should be 1", param_len);
503
15
      break;
504
15
    }
505
506
0
    proto_tree_add_bitmask(param_tree, tvb, offset, hf_connect_protocol_options_flags, ett_connect_protocol_options_flags, protocol_options_flags, ENC_NA);
507
0
    break;
508
509
8
  case Session_Requirement:
510
8
    if (param_len != 2)
511
6
    {
512
6
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
513
6
          "Length is %u, should be 2", param_len);
514
6
      break;
515
6
    }
516
2
    proto_tree_add_bitmask(param_tree, tvb, offset, hf_session_user_req_flags, ett_ses_req_options_flags, req_options_flags, ENC_BIG_ENDIAN);
517
2
    break;
518
519
14
  case TSDU_Maximum_Size:
520
14
    if (param_len != 4)
521
14
    {
522
14
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
523
14
          "Length is %u, should be 4", param_len);
524
14
      break;
525
14
    }
526
0
    if (tree)
527
0
    {
528
0
      proto_tree_add_item(param_tree,
529
0
          hf_proposed_tsdu_maximum_size_i2r,
530
0
          tvb, offset, 2, ENC_BIG_ENDIAN);
531
0
      proto_tree_add_item(param_tree,
532
0
          hf_proposed_tsdu_maximum_size_r2i,
533
0
          tvb, offset+2, 2, ENC_BIG_ENDIAN);
534
0
    }
535
0
    break;
536
537
24
  case Version_Number:
538
24
    if (param_len != 1)
539
22
    {
540
22
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
541
22
          "Length is %u, should be 1", param_len);
542
22
      break;
543
22
    }
544
2
    proto_tree_add_bitmask(param_tree, tvb, offset, hf_version_number_options_flags, ett_protocol_version_flags, version_flags, ENC_BIG_ENDIAN);
545
2
    break;
546
547
26
  case Initial_Serial_Number:
548
26
    if (param_len == 0)
549
13
      break;
550
551
13
    proto_tree_add_item(param_tree,
552
13
          hf_initial_serial_number,
553
13
          tvb, offset, param_len, ENC_ASCII);
554
13
    break;
555
556
26
  case EnclosureItem:
557
26
    if (param_len != 1)
558
15
    {
559
15
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
560
15
          "Length is %u, should be 1", param_len);
561
15
      break;
562
15
    }
563
11
    flags = tvb_get_uint8(tvb, offset);
564
11
    *enclosure_item_flags = (uint8_t) flags;
565
11
    proto_tree_add_bitmask(param_tree, tvb, offset, hf_enclosure_item_options_flags, ett_enclosure_item_flags, enclosure_flags, ENC_BIG_ENDIAN);
566
567
11
    if (flags & END_SPDU) {
568
      /*
569
       * In Data Transfer and Typed Data SPDUs, (X.225: 8.3.{11,13}.4)
570
       * "The User Information Field shall be present
571
       * if the Enclosure Item is not present, or has
572
       * bit 2 = 0", which presumably means it shall
573
       * *not* be present if the Enclosure item *is*
574
       * present and has bit 2 = 1.
575
       */
576
577
10
      if(!(flags & BEGINNING_SPDU)) {
578
        /* X.225 7.11.2 also states:
579
         * "All DATA TRANSFER SPDUs, except the last DATA TRANSFER SPDU in a sequence greater than one, must have user information"
580
         * So if BEGINNING_SPDU and END_SPDU are set in the enclosure item, then this is presumably a sequence of one and
581
         * consequently there must be user information.
582
         *
583
         * So, there is only no user information if *only* END_SPDU is set.
584
         */
585
586
4
         has_user_information = false;
587
4
      }
588
10
    }
589
11
    break;
590
591
25
  case Token_Setting_Item:
592
25
    if (param_len != 1)
593
24
    {
594
24
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
595
24
          "Length is %u, should be 1", param_len);
596
24
      break;
597
24
    }
598
1
    if (tree)
599
1
    {
600
1
      proto_tree_add_item(param_tree,
601
1
          hf_release_token_setting,
602
1
          tvb, offset, 1, ENC_BIG_ENDIAN);
603
1
      proto_tree_add_item(param_tree,
604
1
          hf_major_activity_token_setting,
605
1
          tvb, offset, 1, ENC_BIG_ENDIAN);
606
1
      proto_tree_add_item(param_tree,
607
1
          hf_synchronize_minor_token_setting,
608
1
          tvb, offset, 1, ENC_BIG_ENDIAN);
609
1
      proto_tree_add_item(param_tree,
610
1
          hf_data_token_setting,
611
1
          tvb, offset, 1, ENC_BIG_ENDIAN);
612
1
    }
613
1
    break;
614
615
27
  case Activity_Identifier:
616
27
    if (param_len == 0)
617
6
      break;
618
619
    /* 8.3.29.2 The parameter fields shall be as specified in Table 37.
620
      * Activity Identifier m 41 6 octets maximum
621
      */
622
21
    proto_tree_add_item(param_tree,
623
21
      hf_activity_identifier,
624
21
      tvb, offset, param_len, ENC_NA);
625
21
    break;
626
627
21
  case Serial_Number:
628
21
    if (param_len == 0)
629
11
      break;
630
631
10
    proto_tree_add_item(param_tree,
632
10
          hf_serial_number,
633
10
          tvb, offset, param_len, ENC_ASCII);
634
10
    break;
635
636
108
  case Reason_Code:
637
/*
638
  0:  Rejection by called SS-user; reason not specified.
639
  1:  Rejection by called SS-user due to temporary congestion.
640
  2:  Rejection by called SS-user. Subsequent octets may be used for user data
641
up to a length of 512 octets if Protocol Version 1 has been selected, and up
642
to a length such that the total length (including SI and LI)  of the SPDU
643
does not exceed 65 539 octets if Protocol Version 2 has been selected.
644
  128 + 1:  Session Selector unknown.
645
  128 + 2:  SS-user not attached to SSAP.
646
  128 + 3:  SPM congestion at connect time.
647
  128 + 4:  Proposed protocol versions not supported.
648
  128 + 5:  Rejection by the SPM; reason not specified.
649
  128 + 6:  Rejection by the SPM; implementation restriction stated in the
650
PICS.    */
651
108
    if (param_len < 1)
652
8
    {
653
8
      expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
654
8
          "Length is %u, should be >= 1", param_len);
655
8
      break;
656
8
    }
657
658
100
    proto_tree_add_item(param_tree, hf_ses_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
659
100
    offset++;
660
100
    param_len--;
661
100
    if (param_len != 0)
662
97
    {
663
97
      call_pres_dissector(tvb, offset, param_len,
664
97
          pinfo, tree, param_tree, session);
665
97
    }
666
100
    break;
667
668
23
  case Calling_Session_Selector:
669
23
    if (param_len == 0)
670
6
      break;
671
672
17
    proto_tree_add_item(param_tree,
673
17
          hf_calling_session_selector,
674
17
          tvb, offset, param_len, ENC_NA);
675
17
    break;
676
677
15
  case Called_Session_Selector:
678
15
    if (param_len == 0)
679
1
      break;
680
681
14
    proto_tree_add_item(param_tree,
682
14
          hf_called_session_selector,
683
14
          tvb, offset, param_len, ENC_NA);
684
14
    break;
685
686
24
  case Second_Serial_Number:
687
24
    if (param_len == 0)
688
3
      break;
689
690
21
    proto_tree_add_item(param_tree,
691
21
          hf_second_serial_number,
692
21
          tvb, offset, param_len, ENC_ASCII);
693
21
    break;
694
695
11
  case Second_Initial_Serial_Number:
696
11
    if (param_len == 0)
697
3
      break;
698
699
8
    proto_tree_add_item(param_tree,
700
8
          hf_second_initial_serial_number,
701
8
          tvb, offset, param_len, ENC_ASCII);
702
8
    break;
703
704
6
  case Large_Initial_Serial_Number:
705
6
    if (param_len == 0)
706
2
      break;
707
708
4
    proto_tree_add_item(param_tree,
709
4
          hf_large_initial_serial_number,
710
4
          tvb, offset, param_len, ENC_ASCII);
711
4
    break;
712
713
16
  case Large_Second_Initial_Serial_Number:
714
16
    if (param_len == 0)
715
6
      break;
716
717
10
    proto_tree_add_item(param_tree,
718
10
          hf_large_second_initial_serial_number,
719
10
          tvb, offset, param_len, ENC_ASCII);
720
10
    break;
721
722
3.29k
  default:
723
3.29k
    break;
724
3.86k
  }
725
3.85k
  return has_user_information;
726
3.86k
}
727
728
static bool
729
dissect_parameter_group(tvbuff_t *tvb, int offset, proto_tree *tree,
730
            proto_tree *pg_tree, packet_info *pinfo, uint16_t pg_len,
731
            uint8_t *enclosure_item_flags, struct SESSION_DATA_STRUCTURE *session)
732
329
{
733
329
  bool has_user_information = true;
734
329
  proto_item *ti, *param_len_item;
735
329
  proto_tree *param_tree;
736
329
  uint8_t param_type;
737
329
  const char *param_str;
738
329
  int len_len;
739
329
  uint16_t param_len;
740
741
656
  while(pg_len != 0)
742
576
  {
743
576
    param_type = tvb_get_uint8(tvb, offset);
744
576
    param_tree = proto_tree_add_subtree(pg_tree, tvb, offset, -1,
745
576
      ett_ses_param, &ti,
746
576
      val_to_str_ext(pinfo->pool, param_type, &param_vals_ext, "Unknown parameter type (0x%02x)"));
747
576
    param_str = val_to_str_ext_const(param_type, &param_vals_ext, "Unknown");
748
576
    proto_tree_add_item(param_tree, hf_ses_parameter_type, tvb, offset, 1, ENC_BIG_ENDIAN);
749
576
    offset++;
750
576
    pg_len--;
751
576
    param_len = get_item_len(tvb, offset, &len_len);
752
576
    if (len_len > pg_len) {
753
87
      proto_item_set_len(ti, pg_len + 1);
754
87
      proto_tree_add_expert_format(param_tree, pinfo, &ei_ses_bad_parameter_length, tvb, offset, pg_len, "Parameter length doesn't fit in parameter");
755
87
      return has_user_information;
756
87
    }
757
489
    pg_len -= len_len;
758
489
    if (param_len > pg_len) {
759
159
      proto_item_set_len(ti, pg_len + 1 + len_len);
760
159
      proto_tree_add_expert_format(param_tree, pinfo, &ei_ses_bad_parameter_length, tvb, offset, pg_len, "Parameter length: %u, should be <= %u", param_len, pg_len);
761
159
      return has_user_information;
762
159
    }
763
330
    proto_item_set_len(ti, 1 + len_len + param_len);
764
330
    param_len_item = proto_tree_add_uint(param_tree, hf_ses_parameter_length, tvb, offset, len_len, param_len);
765
330
    offset += len_len;
766
767
330
    if (param_str != NULL)
768
322
    {
769
322
      switch(param_type)
770
322
      {
771
      /* PG's in PG's are invalid, presumably */
772
0
      case Extended_User_Data:
773
0
      case User_Data:
774
24
      case Connect_Accept_Item:
775
44
      case Connection_Identifier:
776
45
      case Linking_Information:
777
45
        proto_tree_add_item(param_tree, hf_ses_parameter_group_inside_parameter_group, tvb, offset, param_len, ENC_NA);
778
45
        break;
779
780
277
      default:
781
277
        if (!dissect_parameter(tvb, offset, tree,
782
277
            param_tree, pinfo, param_type, param_len, param_len_item,
783
277
            enclosure_item_flags, session))
784
0
          has_user_information = false;
785
277
        break;
786
322
      }
787
322
    }
788
327
    offset += param_len;
789
327
    pg_len -= param_len;
790
327
  }
791
80
  return has_user_information;
792
329
}
793
794
/*
795
 * Returns true if there's a User Information field in this SPDU, false
796
 * otherwise.
797
 */
798
static bool
799
dissect_parameters(tvbuff_t *tvb, int offset, uint16_t len, proto_tree *tree,
800
             proto_tree *ses_tree, packet_info *pinfo,
801
             uint8_t *enclosure_item_flags, struct SESSION_DATA_STRUCTURE *session)
802
3.13k
{
803
3.13k
  bool has_user_information = true;
804
3.13k
  proto_item *ti, *param_len_item;
805
3.13k
  proto_tree *param_tree;
806
3.13k
  uint8_t param_type;
807
3.13k
  const char *param_str;
808
3.13k
  int len_len;
809
3.13k
  uint16_t param_len;
810
811
7.25k
  while (len != 0)
812
5.35k
  {
813
5.35k
    param_type = tvb_get_uint8(tvb, offset);
814
5.35k
    param_tree = proto_tree_add_subtree(ses_tree, tvb, offset, -1, ett_ses_param, &ti,
815
5.35k
        val_to_str_ext(pinfo->pool, param_type, &param_vals_ext,
816
5.35k
          "Unknown parameter type (0x%02x)"));
817
5.35k
    param_str = val_to_str_ext_const(param_type, &param_vals_ext, "Unknown");
818
5.35k
    proto_tree_add_item(param_tree, hf_ses_parameter_type, tvb, offset, 1, ENC_BIG_ENDIAN);
819
5.35k
    offset++;
820
5.35k
    len--;
821
5.35k
    param_len = get_item_len(tvb, offset, &len_len);
822
5.35k
    if (len_len > len) {
823
140
      proto_item_set_len(ti, len + 1 );
824
140
      proto_tree_add_expert_format(param_tree, pinfo, &ei_ses_bad_parameter_length, tvb, offset, len, "Parameter length doesn't fit in parameter");
825
140
      return has_user_information;
826
140
    }
827
5.21k
    len -= len_len;
828
5.21k
    if (param_len > len) {
829
1.05k
      proto_item_set_len(ti, len + 1 + len_len);
830
1.05k
      proto_tree_add_expert_format(param_tree, pinfo, &ei_ses_bad_parameter_length, tvb, offset, len, "Parameter length: %u, should be <= %u", param_len, len);
831
1.05k
      return has_user_information;
832
1.05k
    }
833
4.15k
    proto_item_set_len(ti, 1 + len_len + param_len);
834
4.15k
    param_len_item = proto_tree_add_uint(param_tree, hf_ses_parameter_length, tvb, offset, len_len, param_len);
835
4.15k
    offset += len_len;
836
837
4.15k
    if (param_str != NULL)
838
3.94k
    {
839
3.94k
      switch(param_type)
840
3.94k
      {
841
16
      case Extended_User_Data:
842
16
        call_pres_dissector(tvb, offset, param_len,
843
16
            pinfo, tree, param_tree, session);
844
16
        break;
845
846
14
      case User_Data:
847
14
        call_pres_dissector(tvb, offset, param_len,
848
14
            pinfo, tree, param_tree, session);
849
14
        break;
850
851
      /* handle PGI's  */
852
121
      case Connect_Accept_Item:
853
307
      case Connection_Identifier:
854
329
      case Linking_Information:
855
        /* Yes. */
856
329
        if (!dissect_parameter_group(tvb, offset, tree,
857
329
            param_tree, pinfo, param_len, enclosure_item_flags, session))
858
0
          has_user_information = false;
859
329
        break;
860
861
      /* everything else is a PI */
862
3.59k
      default:
863
3.59k
        if (!dissect_parameter(tvb, offset, tree,
864
3.59k
            param_tree, pinfo, param_type, param_len, param_len_item,
865
3.59k
            enclosure_item_flags, session))
866
4
          has_user_information = false;
867
3.59k
        break;
868
3.94k
      }
869
3.94k
    }
870
4.12k
    offset += param_len;
871
4.12k
    len -= param_len;
872
4.12k
  }
873
1.90k
  return has_user_information;
874
3.13k
}
875
876
/*
877
 * Dissect an SPDU.
878
 */
879
static int
880
dissect_spdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
881
       bool tokens, bool connectionless)
882
3.14k
{
883
3.14k
  bool has_user_information = false;
884
3.14k
  uint8_t type;
885
3.14k
  proto_item *ti = NULL;
886
3.14k
  proto_tree *ses_tree = NULL;
887
3.14k
  int len_len;
888
3.14k
  uint16_t parameters_len;
889
3.14k
  tvbuff_t *next_tvb = NULL;
890
3.14k
  uint32_t *pres_ctx_id = NULL;
891
3.14k
  uint8_t enclosure_item_flags = BEGINNING_SPDU|END_SPDU;
892
3.14k
  struct SESSION_DATA_STRUCTURE session;
893
894
  /*
895
   * Get SPDU type.
896
   */
897
3.14k
  type = tvb_get_uint8(tvb, offset);
898
3.14k
  session.spdu_type = type;
899
3.14k
  session.abort_type = SESSION_NO_ABORT;
900
3.14k
  session.pres_ctx_id = 0;
901
3.14k
  session.ros_op = 0;
902
3.14k
  session.rtse_reassemble = false;
903
904
3.14k
  if(connectionless) {
905
20
    col_add_str(pinfo->cinfo, COL_INFO,
906
20
          val_to_str_ext(pinfo->pool, type, &ses_vals_ext, "Unknown SPDU type (0x%02x)"));
907
20
    if (tree) {
908
20
      ti = proto_tree_add_item(tree, proto_clses, tvb, offset,
909
20
        -1, ENC_NA);
910
20
      ses_tree = proto_item_add_subtree(ti, ett_ses);
911
20
      proto_tree_add_uint(ses_tree, hf_ses_type, tvb,
912
20
        offset, 1, type);
913
20
    }
914
20
    has_user_information = true;
915
20
  }
916
3.12k
  else if (tokens) {
917
101
    col_add_str(pinfo->cinfo, COL_INFO,
918
101
          val_to_str(pinfo->pool, type, ses_category0_vals, "Unknown SPDU type (0x%02x)"));
919
101
    if (tree) {
920
101
      ti = proto_tree_add_item(tree, proto_ses, tvb, offset,
921
101
          -1, ENC_NA);
922
101
      ses_tree = proto_item_add_subtree(ti, ett_ses);
923
101
      proto_tree_add_uint(ses_tree, hf_ses_type_0, tvb,
924
101
          offset, 1, type);
925
101
    }
926
3.01k
  } else {
927
3.01k
    col_add_str(pinfo->cinfo, COL_INFO,
928
3.01k
          val_to_str_ext(pinfo->pool, type, &ses_vals_ext, "Unknown SPDU type (0x%02x)"));
929
3.01k
    if (tree) {
930
3.01k
      ti = proto_tree_add_item(tree, proto_ses, tvb, offset,
931
3.01k
        -1, ENC_NA);
932
3.01k
      ses_tree = proto_item_add_subtree(ti, ett_ses);
933
3.01k
      proto_tree_add_uint(ses_tree, hf_ses_type, tvb,
934
3.01k
        offset, 1, type);
935
3.01k
    }
936
937
    /*
938
     * Might this SPDU have a User Information field?
939
     */
940
3.01k
    switch (type) {
941
115
    case SES_DATA_TRANSFER:
942
131
    case SES_EXPEDITED:
943
150
    case SES_TYPED_DATA:
944
150
      has_user_information = true;
945
150
      break;
946
37
    case SES_MAJOR_SYNC_POINT:
947
37
      pres_ctx_id = (uint32_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ses, 0);
948
37
      if (ses_rtse_reassemble != 0 && !pres_ctx_id) {
949
        /* First time visited - save pres_ctx_id */
950
0
        pres_ctx_id = wmem_new(wmem_file_scope(), uint32_t);
951
0
        *pres_ctx_id = ses_pres_ctx_id;
952
0
        p_add_proto_data(wmem_file_scope(), pinfo, proto_ses, 0, pres_ctx_id);
953
0
      }
954
37
      if (pres_ctx_id) {
955
0
        session.pres_ctx_id = *pres_ctx_id;
956
0
        session.rtse_reassemble = true;
957
0
        has_user_information = true;
958
0
      }
959
37
      ses_rtse_reassemble = false;
960
37
      break;
961
3.01k
    }
962
3.01k
  }
963
3.13k
  offset++;
964
965
  /* get length of SPDU parameter field */
966
3.13k
  parameters_len = get_item_len(tvb, offset, &len_len);
967
3.13k
  if (tree)
968
3.13k
    proto_tree_add_uint(ses_tree, hf_ses_length, tvb, offset,
969
3.13k
        len_len, parameters_len);
970
3.13k
  offset += len_len;
971
972
  /* Dissect parameters. */
973
3.13k
  if (!dissect_parameters(tvb, offset, parameters_len, tree, ses_tree,
974
3.13k
        pinfo, &enclosure_item_flags, &session))
975
2
    has_user_information = false;
976
3.13k
  offset += parameters_len;
977
978
3.13k
  proto_item_set_end(ti, tvb, offset);
979
980
  /* Dissect user information, if present */
981
3.13k
  if (!ses_desegment || enclosure_item_flags == (BEGINNING_SPDU|END_SPDU)) {
982
2.74k
    if (has_user_information) {
983
      /* Not desegment or only one segment */
984
113
      if (tvb_reported_length_remaining(tvb, offset) > 0 || type == SES_MAJOR_SYNC_POINT) {
985
106
        next_tvb = tvb_new_subset_remaining(tvb, offset);
986
106
      }
987
113
    }
988
2.74k
  } else {
989
393
    conversation_t *conversation = NULL;
990
393
    fragment_head *frag_msg = NULL;
991
393
    int fragment_len;
992
393
    uint32_t ses_id = 0;
993
994
    /* Use conversation index as segment id */
995
393
    conversation  = find_conversation_pinfo(pinfo, 0);
996
393
    if (conversation != NULL) {
997
7
      ses_id = conversation->conv_index;
998
7
    }
999
393
    fragment_len = tvb_reported_length_remaining (tvb, offset);
1000
393
    ti = proto_tree_add_item (ses_tree, hf_ses_segment_data, tvb, offset,
1001
393
            fragment_len, ENC_NA);
1002
393
    proto_item_append_text (ti, " (%d byte%s)", fragment_len, plurality (fragment_len, "", "s"));
1003
393
    frag_msg = fragment_add_seq_next (&ses_reassembly_table,
1004
393
              tvb, offset,
1005
393
              pinfo, ses_id, NULL,
1006
393
              fragment_len,
1007
393
              (enclosure_item_flags & END_SPDU) ? false : true);
1008
393
    next_tvb = process_reassembled_data (tvb, offset, pinfo, "Reassembled SES",
1009
393
                 frag_msg, &ses_frag_items, NULL,
1010
393
                 (enclosure_item_flags & END_SPDU) ? tree : ses_tree);
1011
1012
393
    has_user_information = true;
1013
393
    offset += fragment_len;
1014
393
  }
1015
1016
3.13k
  if (has_user_information && next_tvb) {
1017
113
    if (!pres_handle) {
1018
0
      call_data_dissector(next_tvb, pinfo, tree);
1019
113
    } else {
1020
      /* Pass the session pdu to the presentation dissector */
1021
113
      call_dissector_with_data(pres_handle, next_tvb, pinfo, tree, &session);
1022
113
    }
1023
1024
    /*
1025
     * No more SPDUs to dissect.  Set the offset to the
1026
     * end of the tvbuff.
1027
     */
1028
113
    offset = tvb_captured_length(tvb);
1029
113
    if (session.rtse_reassemble && type == SES_DATA_TRANSFER) {
1030
0
      ses_pres_ctx_id = session.pres_ctx_id;
1031
0
      ses_rtse_reassemble = true;
1032
0
    }
1033
113
  }
1034
3.13k
  return offset;
1035
3.14k
}
1036
1037
/*
1038
 * Dissect SPDUs inside a TSDU.
1039
 */
1040
static int
1041
dissect_ses(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1042
540
{
1043
540
  unsigned offset = 0;
1044
540
  uint8_t type;
1045
540
  bool is_clsp = false;
1046
1047
540
  type = tvb_get_uint8(tvb, offset);
1048
540
  if(type == CLSES_UNIT_DATA)
1049
20
    is_clsp = true;
1050
1051
1052
540
  col_set_str(pinfo->cinfo, COL_PROTOCOL, is_clsp ? "CLSES" : "SES");
1053
540
  col_clear(pinfo->cinfo, COL_INFO);
1054
1055
1056
  /*
1057
   * Do we have a category 0 SPDU (GIVE_TOKENS/PLEASE_TOKENS) as
1058
   * the first SPDU?
1059
   *
1060
   * If so, dissect it as such (GIVE_TOKENS and DATA_TRANSFER have
1061
   * the same SPDU type value).
1062
   */
1063
540
  if ((type == SES_PLEASE_TOKENS) || (type == SES_GIVE_TOKENS))
1064
101
    offset = dissect_spdu(tvb, offset, pinfo, tree, TOKENS_SPDU, false);
1065
1066
1067
  /* Dissect the remaining SPDUs. */
1068
3.57k
  while (tvb_reported_length_remaining(tvb, offset) > 0)
1069
3.03k
    offset = dissect_spdu(tvb, offset, pinfo, tree, NON_TOKENS_SPDU, is_clsp);
1070
540
  return tvb_captured_length(tvb);
1071
540
}
1072
1073
static bool
1074
dissect_ses_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
1075
3.39k
{
1076
  /* must check that this really is a ses packet */
1077
3.39k
  unsigned offset = 0;
1078
3.39k
  uint8_t type;
1079
3.39k
  int len_len;
1080
3.39k
  uint16_t len;
1081
1082
  /* first, check do we have at least 4 bytes (type+length) */
1083
3.39k
  if (tvb_captured_length(tvb) < 2)
1084
122
    return false;  /* no */
1085
1086
  /* can we recognize session PDU ? Return false if  not */
1087
  /*   get SPDU type */
1088
3.27k
  type = tvb_get_uint8(tvb, offset);
1089
  /* check SPDU type */
1090
3.27k
  if (try_val_to_str_ext(type, &ses_vals_ext) == NULL)
1091
1.99k
  {
1092
1.99k
    return false;  /* no, it isn't a session PDU */
1093
1.99k
  }
1094
1095
  /* can we recognize the second session PDU if the first one was
1096
   * a Give Tokens PDU? Return false if not */
1097
1.28k
  if(tvb_bytes_exist(tvb, 2, 2) && type == SES_GIVE_TOKENS) {
1098
    /*   get SPDU type */
1099
71
    type = tvb_get_uint8(tvb, offset+2);
1100
    /* check SPDU type */
1101
71
    if (try_val_to_str_ext(type, &ses_vals_ext) == NULL)
1102
21
    {
1103
21
      return false;  /* no, it isn't a session PDU */
1104
21
    }
1105
71
  }
1106
1107
  /* some Siemens SIMATIC protocols also use COTP, and shouldn't be
1108
   * misinterpreted as SES.
1109
   * the starter in this case is fixed to 0x32 (SES_MINOR_SYNC_ACK for SES),
1110
   * so if the parameter type is unknown, it's probably SIMATIC */
1111
1.26k
  if(type == 0x32 && tvb_captured_length(tvb) >= 3) {
1112
376
    type = tvb_get_uint8(tvb, offset+2);
1113
376
    if (try_val_to_str_ext(type, &param_vals_ext) == NULL) {
1114
293
      return false; /* it's probably a SIMATIC protocol */
1115
293
    }
1116
376
  }
1117
1118
  /*  OK,let's check SPDU length  */
1119
  /*  get length of SPDU */
1120
971
  len = get_item_len(tvb, offset+1, &len_len);
1121
1122
  /*  add header length     */
1123
971
  len+=len_len;
1124
  /* do we have enough bytes ? */
1125
971
  if (tvb_reported_length(tvb) < len)
1126
177
    return false;  /* no */
1127
1128
  /* final check to see if the next SPDU, if present, is also valid */
1129
794
  if (tvb_captured_length(tvb) > 1+(unsigned) len) {
1130
762
    type = tvb_get_uint8(tvb, offset + len + 1);
1131
    /* check SPDU type */
1132
762
    if (try_val_to_str_ext(type, &ses_vals_ext) == NULL) {
1133
254
      return false;  /* no, it isn't a session PDU */
1134
254
    }
1135
762
  }
1136
1137
540
  dissect_ses(tvb, pinfo, parent_tree, data);
1138
540
  return true;
1139
794
}
1140
1141
void
1142
proto_register_ses(void)
1143
16
{
1144
16
  static hf_register_info hf[] =
1145
16
  {
1146
16
    {
1147
16
      &hf_ses_type,
1148
16
      {
1149
16
        "SPDU Type",
1150
16
        "ses.type",
1151
16
        FT_UINT8,
1152
16
        BASE_DEC | BASE_EXT_STRING,
1153
16
        &ses_vals_ext,
1154
16
        0x0,
1155
16
        NULL, HFILL
1156
16
      }
1157
16
    },
1158
16
    {
1159
16
      &hf_ses_type_0,
1160
16
      {
1161
16
        "SPDU Type",
1162
16
        "ses.type",
1163
16
        FT_UINT8,
1164
16
        BASE_DEC,
1165
16
        VALS(ses_category0_vals),
1166
16
        0x0,
1167
16
        NULL, HFILL
1168
16
      }
1169
16
    },
1170
16
    {
1171
16
      &hf_ses_length,
1172
16
      {
1173
16
        "Length",
1174
16
        "ses.length",
1175
16
        FT_UINT16,
1176
16
        BASE_DEC,
1177
16
        NULL,
1178
16
        0x0,
1179
16
        NULL, HFILL
1180
16
      }
1181
16
    },
1182
1183
#if 0
1184
    {
1185
      &hf_ses_version,
1186
      {
1187
        "Version",
1188
        "ses.version",
1189
        FT_UINT8,
1190
        BASE_DEC,
1191
        NULL,
1192
        0x0,
1193
        NULL, HFILL
1194
      }
1195
    },
1196
#endif
1197
#if 0
1198
    {
1199
      &hf_ses_reserved,
1200
      {
1201
        "Reserved",
1202
        "ses.reserved",
1203
        FT_UINT8,
1204
        BASE_DEC,
1205
        NULL,
1206
        0x0,
1207
        NULL, HFILL
1208
      }
1209
    },
1210
#endif
1211
16
    {
1212
16
      &hf_called_ss_user_reference,
1213
16
      {
1214
16
        "Called SS User Reference",
1215
16
        "ses.called_ss_user_reference",
1216
16
        FT_BYTES, BASE_NONE,
1217
16
        NULL,
1218
16
        0x0,
1219
16
        NULL,
1220
16
        HFILL
1221
16
      }
1222
16
    },
1223
16
    {
1224
16
      &hf_calling_ss_user_reference,
1225
16
      {
1226
16
        "Calling SS User Reference",
1227
16
        "ses.calling_ss_user_reference",
1228
16
        FT_BYTES, BASE_NONE,
1229
16
        NULL,
1230
16
        0x0,
1231
16
        NULL,
1232
16
        HFILL
1233
16
      }
1234
16
    },
1235
16
    {
1236
16
      &hf_common_reference,
1237
16
      {
1238
16
        "Common Reference",
1239
16
        "ses.common_reference",
1240
16
        FT_BYTES, BASE_NONE,
1241
16
        NULL,
1242
16
        0x0,
1243
16
        NULL,
1244
16
        HFILL
1245
16
      }
1246
16
    },
1247
16
    {
1248
16
      &hf_additional_reference_information,
1249
16
      {
1250
16
        "Additional Reference Information",
1251
16
        "ses.additional_reference_information",
1252
16
        FT_BYTES, BASE_NONE,
1253
16
        NULL,
1254
16
        0x0,
1255
16
        NULL,
1256
16
        HFILL
1257
16
      }
1258
16
    },
1259
16
    {
1260
16
      &hf_release_token,
1261
16
      {
1262
16
        "release token",
1263
16
        "ses.release_token",
1264
16
        FT_BOOLEAN, 8,
1265
16
        NULL,
1266
16
        RELEASE_TOKEN,
1267
16
        NULL,
1268
16
        HFILL
1269
16
      }
1270
16
    },
1271
16
    {
1272
16
      &hf_major_activity_token,
1273
16
      {
1274
16
        "major/activity token",
1275
16
        "ses.major.token",
1276
16
        FT_BOOLEAN, 8,
1277
16
        NULL,
1278
16
        MAJOR_ACTIVITY_TOKEN,
1279
16
        NULL,
1280
16
        HFILL
1281
16
      }
1282
16
    },
1283
16
    {
1284
16
      &hf_synchronize_minor_token,
1285
16
      {
1286
16
        "synchronize minor token",
1287
16
        "ses.synchronize_token",
1288
16
        FT_BOOLEAN, 8,
1289
16
        NULL,
1290
16
        SYNCHRONIZE_MINOR_TOKEN,
1291
16
        NULL,
1292
16
        HFILL
1293
16
      }
1294
16
    },
1295
16
    {
1296
16
      &hf_data_token,
1297
16
      {
1298
16
        "data token",
1299
16
        "ses.data_token",
1300
16
        FT_BOOLEAN, 8,
1301
16
        NULL,
1302
16
        DATA_TOKEN,
1303
16
        "data  token",
1304
16
        HFILL
1305
16
      }
1306
16
    },
1307
16
    {
1308
16
      &hf_able_to_receive_extended_concatenated_SPDU,
1309
16
      {
1310
16
        "Able to receive extended concatenated SPDU",
1311
16
        "ses.connect.f1",
1312
16
        FT_BOOLEAN, 8,
1313
16
        NULL,
1314
16
        SES_EXT_CONT,
1315
16
        NULL,
1316
16
        HFILL
1317
16
      }
1318
16
    },
1319
16
    {
1320
16
      &hf_session_user_req_flags,
1321
16
      {
1322
16
        "Flags",
1323
16
        "ses.req.flags",
1324
16
        FT_UINT16,
1325
16
        BASE_HEX,
1326
16
        NULL,
1327
16
        0x0,
1328
16
        NULL,
1329
16
        HFILL
1330
16
      }
1331
16
    },
1332
16
    {
1333
16
      &hf_session_exception_report,
1334
16
      {
1335
16
        "Session exception report",
1336
16
        "ses.exception_report",
1337
16
        FT_BOOLEAN, 16,
1338
16
        NULL,
1339
16
        SES_EXCEPTION_REPORT,
1340
16
        NULL,
1341
16
        HFILL
1342
16
      }
1343
16
    },
1344
16
    {
1345
16
      &hf_data_separation_function_unit,
1346
16
      {
1347
16
        "Data separation function unit",
1348
16
        "ses.data_sep",
1349
16
        FT_BOOLEAN, 16,
1350
16
        NULL,
1351
16
        DATA_SEPARATION_FUNCTION_UNIT,
1352
16
        NULL,
1353
16
        HFILL
1354
16
      }
1355
16
    },
1356
16
    {
1357
16
      &hf_symmetric_synchronize_function_unit,
1358
16
      {
1359
16
        "Symmetric synchronize function unit",
1360
16
        "ses.symm_sync",
1361
16
        FT_BOOLEAN, 16,
1362
16
        NULL,
1363
16
        SYMMETRIC_SYNCHRONIZE_FUNCTION_UNIT,
1364
16
        NULL,
1365
16
        HFILL
1366
16
      }
1367
16
    },
1368
16
    {
1369
16
      &hf_typed_data_function_unit,
1370
16
      {
1371
16
        "Typed data function unit",
1372
16
        "ses.typed_data",
1373
16
        FT_BOOLEAN, 16,
1374
16
        NULL,
1375
16
        TYPED_DATA_FUNCTION_UNIT,
1376
16
        NULL,
1377
16
        HFILL
1378
16
      }
1379
16
    },
1380
16
    {
1381
16
      &hf_exception_function_unit,
1382
16
      {
1383
16
        "Exception function unit",
1384
16
        "ses.exception_data",
1385
16
        FT_BOOLEAN, 16,
1386
16
        NULL,
1387
16
        EXCEPTION_FUNCTION_UNIT,
1388
16
        NULL,
1389
16
        HFILL
1390
16
      }
1391
16
    },
1392
16
    {
1393
16
      &hf_capability_function_unit,
1394
16
      {
1395
16
        "Capability function unit",
1396
16
        "ses.capability_data",
1397
16
        FT_BOOLEAN, 16,
1398
16
        NULL,
1399
16
        CAPABILITY_DATA_FUNCTION_UNIT,
1400
16
        NULL,
1401
16
        HFILL
1402
16
      }
1403
16
    },
1404
16
    {
1405
16
      &hf_negotiated_release_function_unit,
1406
16
      {
1407
16
        "Negotiated release function unit",
1408
16
        "ses.negotiated_release",
1409
16
        FT_BOOLEAN, 16,
1410
16
        NULL,
1411
16
        NEGOTIATED_RELEASE_FUNCTION_UNIT,
1412
16
        NULL,
1413
16
        HFILL
1414
16
      }
1415
16
    },
1416
16
    {
1417
16
      &hf_activity_management_function_unit,
1418
16
      {
1419
16
        "Activity management function unit",
1420
16
        "ses.activity_management",
1421
16
        FT_BOOLEAN, 16,
1422
16
        NULL,
1423
16
        ACTIVITY_MANAGEMENT_FUNCTION_UNIT,
1424
16
        NULL,
1425
16
        HFILL
1426
16
      }
1427
16
    },
1428
16
    {
1429
16
      &hf_resynchronize_function_unit,
1430
16
      {
1431
16
        "Resynchronize function unit",
1432
16
        "ses.resynchronize",
1433
16
        FT_BOOLEAN, 16,
1434
16
        NULL,
1435
16
        RESYNCHRONIZE_FUNCTION_UNIT,
1436
16
        NULL,
1437
16
        HFILL
1438
16
      }
1439
16
    },
1440
16
    {
1441
16
      &hf_major_resynchronize_function_unit,
1442
16
      {
1443
16
        "Major resynchronize function unit",
1444
16
        "ses.major_resynchronize",
1445
16
        FT_BOOLEAN, 16,
1446
16
        NULL,
1447
16
        MAJOR_SYNCHRONIZE_FUNCTION_UNIT,
1448
16
        NULL,
1449
16
        HFILL
1450
16
      }
1451
16
    },
1452
16
    {
1453
16
      &hf_minor_resynchronize_function_unit,
1454
16
      {
1455
16
        "Minor resynchronize function unit",
1456
16
        "ses.minor_resynchronize",
1457
16
        FT_BOOLEAN, 16,
1458
16
        NULL,
1459
16
        MINOR_SYNCHRONIZE_FUNCTION_UNIT,
1460
16
        NULL,
1461
16
        HFILL
1462
16
      }
1463
16
    },
1464
16
    {
1465
16
      &hf_expedited_data_resynchronize_function_unit,
1466
16
      {
1467
16
        "Expedited data function unit",
1468
16
        "ses.expedited_data",
1469
16
        FT_BOOLEAN, 16,
1470
16
        NULL,
1471
16
        EXPEDITED_DATA_FUNCTION_UNIT,
1472
16
        NULL,
1473
16
        HFILL
1474
16
      }
1475
16
    },
1476
16
    {
1477
16
      &hf_duplex_function_unit,
1478
16
      {
1479
16
        "Duplex functional unit",
1480
16
        "ses.duplex",
1481
16
        FT_BOOLEAN, 16,
1482
16
        NULL,
1483
16
        DUPLEX_FUNCTION_UNIT,
1484
16
        NULL,
1485
16
        HFILL
1486
16
      }
1487
16
    },
1488
16
    {
1489
16
      &hf_half_duplex_function_unit,
1490
16
      {
1491
16
        "Half-duplex functional unit",
1492
16
        "ses.half_duplex",
1493
16
        FT_BOOLEAN, 16,
1494
16
        NULL,
1495
16
        HALF_DUPLEX_FUNCTION_UNIT,
1496
16
        NULL,
1497
16
        HFILL
1498
16
      }
1499
16
    },
1500
16
    {
1501
16
      &hf_proposed_tsdu_maximum_size_i2r,
1502
16
      {
1503
16
        "Proposed TSDU Maximum Size, Initiator to Responder",
1504
16
        "ses.proposed_tsdu_maximum_size_i2r",
1505
16
        FT_UINT16,
1506
16
        BASE_DEC,
1507
16
        NULL,
1508
16
        0x0,
1509
16
        NULL,
1510
16
        HFILL
1511
16
      }
1512
16
    },
1513
16
    {
1514
16
      &hf_proposed_tsdu_maximum_size_r2i,
1515
16
      {
1516
16
        "Proposed TSDU Maximum Size, Responder to Initiator",
1517
16
        "ses.proposed_tsdu_maximum_size_r2i",
1518
16
        FT_UINT16,
1519
16
        BASE_DEC,
1520
16
        NULL,
1521
16
        0x0,
1522
16
        NULL,
1523
16
        HFILL
1524
16
      }
1525
16
    },
1526
16
    {
1527
16
      &hf_protocol_version_1,
1528
16
      {
1529
16
        "Protocol Version 1",
1530
16
        "ses.protocol_version1",
1531
16
        FT_BOOLEAN, 8,
1532
16
        NULL,
1533
16
        PROTOCOL_VERSION_1,
1534
16
        NULL,
1535
16
        HFILL
1536
16
      }
1537
16
    },
1538
16
    {
1539
16
      &hf_protocol_version_2,
1540
16
      {
1541
16
        "Protocol Version 2",
1542
16
        "ses.protocol_version2",
1543
16
        FT_BOOLEAN, 8,
1544
16
        NULL,
1545
16
        PROTOCOL_VERSION_2,
1546
16
        NULL,
1547
16
        HFILL
1548
16
      }
1549
16
    },
1550
16
    {
1551
16
      &hf_initial_serial_number,
1552
16
      {
1553
16
        "Initial Serial Number",
1554
16
        "ses.initial_serial_number",
1555
16
        FT_STRING, BASE_NONE,
1556
16
        NULL,
1557
16
        0x0,
1558
16
        NULL,
1559
16
        HFILL
1560
16
      }
1561
16
    },
1562
16
    {
1563
16
      &hf_beginning_of_SSDU,
1564
16
      {
1565
16
        "beginning of SSDU",
1566
16
        "ses.beginning_of_SSDU",
1567
16
        FT_BOOLEAN, 8,
1568
16
        NULL,
1569
16
        BEGINNING_SPDU,
1570
16
        NULL,
1571
16
        HFILL
1572
16
      }
1573
16
    },
1574
16
    {
1575
16
      &hf_end_of_SSDU,
1576
16
      {
1577
16
        "end of SSDU",
1578
16
        "ses.end_of_SSDU",
1579
16
        FT_BOOLEAN, 8,
1580
16
        NULL,
1581
16
        END_SPDU,
1582
16
        NULL,
1583
16
        HFILL
1584
16
      }
1585
16
    },
1586
16
    {
1587
16
      &hf_release_token_setting,
1588
16
      {
1589
16
        "release token setting",
1590
16
        "ses.release_token_setting",
1591
16
        FT_UINT8, BASE_HEX,
1592
16
        VALS(token_setting_vals),
1593
16
        0xC0,
1594
16
        NULL,
1595
16
        HFILL
1596
16
      }
1597
16
    },
1598
16
    {
1599
16
      &hf_major_activity_token_setting,
1600
16
      {
1601
16
        "major/activity setting",
1602
16
        "ses.major_activity_token_setting",
1603
16
        FT_UINT8, BASE_HEX,
1604
16
        VALS(token_setting_vals),
1605
16
        0x30,
1606
16
        "major/activity token setting",
1607
16
        HFILL
1608
16
      }
1609
16
    },
1610
16
    {
1611
16
      &hf_synchronize_minor_token_setting,
1612
16
      {
1613
16
        "synchronize-minor token setting",
1614
16
        "ses.synchronize_minor_token_setting",
1615
16
        FT_UINT8, BASE_HEX,
1616
16
        VALS(token_setting_vals),
1617
16
        0x0C,
1618
16
        NULL,
1619
16
        HFILL
1620
16
      }
1621
16
    },
1622
16
    {
1623
16
      &hf_data_token_setting,
1624
16
      {
1625
16
        "data token setting",
1626
16
        "ses.data_token_setting",
1627
16
        FT_UINT8, BASE_HEX,
1628
16
        VALS(token_setting_vals),
1629
16
        0x03,
1630
16
        NULL,
1631
16
        HFILL
1632
16
      }
1633
16
    },
1634
16
    {
1635
16
      &hf_activity_identifier,
1636
16
      {
1637
16
        "Activity Identifier",
1638
16
        "ses.activity_identifier",
1639
16
        FT_BYTES, BASE_NONE,
1640
16
        NULL,
1641
16
        0x0,
1642
16
        NULL,
1643
16
        HFILL
1644
16
      }
1645
16
    },
1646
16
    {
1647
16
      &hf_serial_number,
1648
16
      {
1649
16
        "Serial Number",
1650
16
        "ses.serial_number",
1651
16
        FT_STRING, BASE_NONE,
1652
16
        NULL,
1653
16
        0x0,
1654
16
        NULL,
1655
16
        HFILL
1656
16
      }
1657
16
    },
1658
16
    {
1659
16
      &hf_calling_session_selector,
1660
16
      {
1661
16
        "Calling Session Selector",
1662
16
        "ses.calling_session_selector",
1663
16
        FT_BYTES, BASE_NONE,
1664
16
        NULL,
1665
16
        0x0,
1666
16
        NULL,
1667
16
        HFILL
1668
16
      }
1669
16
    },
1670
16
    {
1671
16
      &hf_called_session_selector,
1672
16
      {
1673
16
        "Called Session Selector",
1674
16
        "ses.called_session_selector",
1675
16
        FT_BYTES, BASE_NONE,
1676
16
        NULL,
1677
16
        0x0,
1678
16
        NULL,
1679
16
        HFILL
1680
16
      }
1681
16
    },
1682
16
    {
1683
16
      &hf_second_serial_number,
1684
16
      {
1685
16
        "Second Serial Number",
1686
16
        "ses.second_serial_number",
1687
16
        FT_STRING, BASE_NONE,
1688
16
        NULL,
1689
16
        0x0,
1690
16
        NULL,
1691
16
        HFILL
1692
16
      }
1693
16
    },
1694
16
    {
1695
16
      &hf_second_initial_serial_number,
1696
16
      {
1697
16
        "Second Initial Serial Number",
1698
16
        "ses.second_initial_serial_number",
1699
16
        FT_STRING, BASE_NONE,
1700
16
        NULL,
1701
16
        0x0,
1702
16
        NULL,
1703
16
        HFILL
1704
16
      }
1705
16
    },
1706
16
    {
1707
16
      &hf_large_initial_serial_number,
1708
16
      {
1709
16
        "Large Initial Serial Number",
1710
16
        "ses.large_initial_serial_number",
1711
16
        FT_STRING, BASE_NONE,
1712
16
        NULL,
1713
16
        0x0,
1714
16
        NULL,
1715
16
        HFILL
1716
16
      }
1717
16
    },
1718
16
    {
1719
16
      &hf_large_second_initial_serial_number,
1720
16
      {
1721
16
        "Large Second Initial Serial Number",
1722
16
        "ses.large_second_initial_serial_number",
1723
16
        FT_STRING, BASE_NONE,
1724
16
        NULL,
1725
16
        0x0,
1726
16
        NULL,
1727
16
        HFILL
1728
16
      }
1729
16
    },
1730
16
    {
1731
16
      &hf_connect_protocol_options_flags,
1732
16
      {
1733
16
        "Flags",
1734
16
        "ses.connect.flags",
1735
16
        FT_UINT8,
1736
16
        BASE_HEX,
1737
16
        NULL,
1738
16
        0x0,
1739
16
        NULL,
1740
16
        HFILL
1741
16
      }
1742
16
    },
1743
16
    {
1744
16
      &hf_version_number_options_flags,
1745
1746
16
      {
1747
16
        "Flags",
1748
16
        "ses.version.flags",
1749
16
        FT_UINT8,
1750
16
        BASE_HEX,
1751
16
        NULL,
1752
16
        0x0,
1753
16
        NULL,
1754
16
        HFILL
1755
16
      }
1756
16
    },
1757
1758
16
    {
1759
16
      &hf_token_item_options_flags,
1760
1761
16
      {
1762
16
        "Flags",
1763
16
        "ses.tken_item.flags",
1764
16
        FT_UINT8,
1765
16
        BASE_HEX,
1766
16
        NULL,
1767
16
        0x0,
1768
16
        NULL,
1769
16
        HFILL
1770
16
      }
1771
16
    },
1772
1773
16
    {
1774
16
      &hf_enclosure_item_options_flags,
1775
1776
16
      {
1777
16
        "Flags",
1778
16
        "ses.enclosure.flags",
1779
16
        FT_UINT8,
1780
16
        BASE_HEX,
1781
16
        NULL,
1782
16
        0x0,
1783
16
        NULL,
1784
16
        HFILL
1785
16
      }
1786
16
    },
1787
1788
16
    { &hf_ses_segment_data,
1789
16
      { "SES segment data", "ses.segment.data", FT_NONE, BASE_NONE,
1790
16
        NULL, 0x00, NULL, HFILL } },
1791
16
    { &hf_ses_segments,
1792
16
      { "SES segments", "ses.segments", FT_NONE, BASE_NONE,
1793
16
        NULL, 0x00, NULL, HFILL } },
1794
16
    { &hf_ses_segment,
1795
16
      { "SES segment", "ses.segment", FT_FRAMENUM, BASE_NONE,
1796
16
        NULL, 0x00, NULL, HFILL } },
1797
16
    { &hf_ses_segment_overlap,
1798
16
      { "SES segment overlap", "ses.segment.overlap", FT_BOOLEAN,
1799
16
        BASE_NONE, NULL, 0x0, NULL, HFILL } },
1800
16
    { &hf_ses_segment_overlap_conflicts,
1801
16
      { "SES segment overlapping with conflicting data",
1802
16
        "ses.segment.overlap.conflicts", FT_BOOLEAN, BASE_NONE,
1803
16
        NULL, 0x0, NULL, HFILL } },
1804
16
    { &hf_ses_segment_multiple_tails,
1805
16
      { "SES has multiple tail segments",
1806
16
        "ses.segment.multiple_tails", FT_BOOLEAN, BASE_NONE,
1807
16
        NULL, 0x0, NULL, HFILL } },
1808
16
    { &hf_ses_segment_too_long_segment,
1809
16
      { "SES segment too long", "ses.segment.too_long_segment",
1810
16
        FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
1811
16
    { &hf_ses_segment_error,
1812
16
      { "SES desegmentation error", "ses.segment.error", FT_FRAMENUM,
1813
16
        BASE_NONE, NULL, 0x00, NULL, HFILL } },
1814
16
    { &hf_ses_segment_count,
1815
16
      { "SES segment count", "ses.segment.count", FT_UINT32, BASE_DEC,
1816
16
        NULL, 0x00, NULL, HFILL } },
1817
16
    { &hf_ses_reassembled_in,
1818
16
      { "Reassembled SES in frame", "ses.reassembled.in", FT_FRAMENUM, BASE_NONE,
1819
16
        NULL, 0x00, "This SES packet is reassembled in this frame", HFILL } },
1820
16
    { &hf_ses_reassembled_length,
1821
16
      { "Reassembled SES length", "ses.reassembled.length", FT_UINT32, BASE_DEC,
1822
16
        NULL, 0x00, "The total length of the reassembled payload", HFILL } },
1823
1824
          /* Generated from convert_proto_tree_add_text.pl */
1825
16
          { &hf_ses_user_data, { "User data", "ses.user_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1826
16
          { &hf_ses_transport_option_flags, { "Flags", "ses.transport_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1827
16
          { &hf_ses_transport_connection, { "Transport connection", "ses.transport_flags.connection", FT_BOOLEAN, 8, TFS(&tfs_released_kept), transport_connection_is_released, NULL, HFILL }},
1828
16
          { &hf_ses_transport_user_abort, { "User abort", "ses.transport_flags.user_abort", FT_BOOLEAN, 8, TFS(&tfs_yes_no), user_abort, NULL, HFILL }},
1829
16
          { &hf_ses_transport_protocol_error, { "Protocol error", "ses.transport_flags.protocol_error", FT_BOOLEAN, 8, TFS(&tfs_yes_no), protocol_error, NULL, HFILL }},
1830
16
          { &hf_ses_transport_no_reason, { "No reason", "ses.transport_flags.no_reason", FT_BOOLEAN, 8, TFS(&tfs_yes_no), no_reason, NULL, HFILL }},
1831
16
          { &hf_ses_transport_implementation_restriction, { "Implementation restriction", "ses.transport_flags.implementation_restriction", FT_BOOLEAN, 8, TFS(&tfs_yes_no), implementation_restriction, NULL, HFILL }},
1832
16
          { &hf_ses_reason_code, { "Reason Code", "ses.reason_code", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &reason_vals_ext, 0x0, NULL, HFILL }},
1833
16
          { &hf_ses_parameter_type, { "Parameter type", "ses.parameter_type", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &param_vals_ext, 0x0, NULL, HFILL }},
1834
16
          { &hf_ses_parameter_length, { "Parameter length", "ses.parameter_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1835
16
          { &hf_ses_parameter_group_inside_parameter_group, { "Parameter group inside parameter group", "ses.parameter_group_inside_parameter_group", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1836
16
  };
1837
1838
16
  static int *ett[] =
1839
16
  {
1840
16
    &ett_ses,
1841
16
    &ett_ses_param,
1842
16
    &ett_connect_protocol_options_flags,
1843
16
    &ett_transport_options_flags,
1844
16
    &ett_protocol_version_flags,
1845
16
    &ett_enclosure_item_flags,
1846
16
    &ett_token_item_flags,
1847
16
    &ett_ses_req_options_flags,
1848
16
    &ett_ses_segment,
1849
16
    &ett_ses_segments
1850
16
  };
1851
1852
16
  static ei_register_info ei[] = {
1853
16
    { &ei_ses_bad_length, { "ses.bad_length", PI_MALFORMED, PI_ERROR, "Bad length", EXPFILL }},
1854
16
    { &ei_ses_bad_parameter_length, { "ses.bad_parameter_length", PI_MALFORMED, PI_ERROR, "Bad parameter length", EXPFILL }},
1855
16
  };
1856
1857
16
  module_t *ses_module;
1858
16
  expert_module_t* expert_ses;
1859
1860
16
  proto_ses = proto_register_protocol(PROTO_STRING_SES, "SES", "ses");
1861
16
  proto_register_field_array(proto_ses, hf, array_length(hf));
1862
16
  proto_register_subtree_array(ett, array_length(ett));
1863
16
  expert_ses = expert_register_protocol(proto_ses);
1864
16
  expert_register_field_array(expert_ses, ei, array_length(ei));
1865
1866
16
  reassembly_table_register (&ses_reassembly_table,
1867
16
    &addresses_reassembly_table_functions);
1868
1869
16
  ses_module = prefs_register_protocol(proto_ses, NULL);
1870
1871
16
  prefs_register_bool_preference(ses_module, "desegment",
1872
16
      "Reassemble session packets ",
1873
16
      "Whether the session dissector should reassemble messages spanning multiple SES segments",
1874
16
      &ses_desegment);
1875
1876
  /*
1877
   * Register the dissector by name, so other dissectors can
1878
   * grab it by name rather than just referring to it directly
1879
   * (you can't refer to it directly from a plugin dissector
1880
   * on Windows without stuffing it into the Big Transfer Vector).
1881
   */
1882
16
  register_dissector("ses", dissect_ses, proto_ses);
1883
16
}
1884
1885
void
1886
proto_reg_handoff_ses(void)
1887
16
{
1888
  /* define sub dissector */
1889
16
  pres_handle = find_dissector_add_dependency("pres", proto_ses);
1890
1891
  /* add our session dissector to cotp dissector list
1892
   * and cotp_is dissector list*/
1893
16
  heur_dissector_add("cotp", dissect_ses_heur, "SES over COTP", "ses_cotp", proto_ses, HEURISTIC_ENABLE);
1894
16
  heur_dissector_add("cotp_is", dissect_ses_heur, "SES over COTP (inactive subset)", "ses_cotp_is", proto_ses, HEURISTIC_ENABLE);
1895
16
}
1896
1897
1898
1899
void proto_register_clses(void)
1900
16
{
1901
16
  proto_clses = proto_register_protocol(PROTO_STRING_CLSES, "CLSP", "clsp");
1902
16
}
1903
1904
void
1905
proto_reg_handoff_clses(void)
1906
16
{
1907
  /* add our session dissector to cltp dissector list */
1908
16
  heur_dissector_add("cltp", dissect_ses_heur, "CLSP over COTP", "clses_cotp", proto_clses, HEURISTIC_ENABLE);
1909
16
}
1910
1911
/*
1912
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1913
 *
1914
 * Local variables:
1915
 * c-basic-offset: 8
1916
 * tab-width: 8
1917
 * indent-tabs-mode: t
1918
 * End:
1919
 *
1920
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1921
 * :indentSize=8:tabSize=8:noTabs=false:
1922
 */