Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ses.c
blob34df6ed3cf350a90ea0dd0b9542814569452a1fb
1 /* packet-ses.c
3 * Routine to dissect ITU-T Rec. X.225 (1995 E)/ISO 8327-1 OSI Session Protocol packets
5 * Yuriy Sidelnikov <YSidelnikov@hotmail.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "config.h"
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>
26 #include "packet-ber.h"
27 #include "packet-ses.h"
29 void proto_register_ses(void);
30 void proto_reg_handoff_ses(void);
32 void proto_register_clses(void);
33 void proto_reg_handoff_clses(void);
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; */
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;
55 /* ses fields defining a sub tree */
56 static int ett_ses;
57 static int ett_ses_param;
59 static int ett_ses_segment;
60 static int ett_ses_segments;
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;
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;
76 /* called SS user reference */
77 static int hf_called_ss_user_reference;
79 /* calling SS user reference */
80 static int hf_calling_ss_user_reference;
82 /* common reference */
83 static int hf_common_reference;
85 /* additional reference information */
86 static int hf_additional_reference_information;
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;
94 /* protocol options */
95 static int hf_able_to_receive_extended_concatenated_SPDU;
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;
114 /* TSDU maximum size */
115 static int hf_proposed_tsdu_maximum_size_i2r;
116 static int hf_proposed_tsdu_maximum_size_r2i;
118 /* protocol version */
119 static int hf_protocol_version_1;
120 static int hf_protocol_version_2;
122 /* initial serial number */
123 static int hf_initial_serial_number;
125 /* enclosure item */
126 static int hf_beginning_of_SSDU;
127 static int hf_end_of_SSDU;
129 /* token setting item */
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 }
139 static const true_false_string tfs_released_kept = { "Released", "Kept" };
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;
146 /* calling session selector */
147 static int hf_calling_session_selector;
149 /* called session selector */
150 static int hf_called_session_selector;
152 /* activity id */
153 static int hf_activity_identifier;
155 /* serial number */
156 static int hf_serial_number;
158 /* second serial number */
159 static int hf_second_serial_number;
161 /* second initial serial number */
162 static int hf_second_initial_serial_number;
164 /* large initial serial number */
165 static int hf_large_initial_serial_number;
167 /* large second initial serial number */
168 static int hf_large_second_initial_serial_number;
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;
183 /* clses header fields */
184 static int proto_clses;
186 static expert_field ei_ses_bad_length;
187 static expert_field ei_ses_bad_parameter_length;
189 #define PROTO_STRING_CLSES "ISO 9548-1 OSI Connectionless Session Protocol"
191 static dissector_handle_t pres_handle;
193 static reassembly_table ses_reassembly_table;
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"
219 static const value_string ses_vals[] =
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 }
255 value_string_ext ses_vals_ext = VALUE_STRING_EXT_INIT(ses_vals);
257 static const value_string ses_category0_vals[] =
259 {SES_PLEASE_TOKENS, "Please tokens PDU" },
260 {SES_GIVE_TOKENS, "Give tokens PDU" },
261 {0, NULL }
265 static const value_string param_vals[] =
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}
303 static value_string_ext param_vals_ext = VALUE_STRING_EXT_INIT(param_vals);
305 static const value_string reason_vals[] =
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 }
319 static value_string_ext reason_vals_ext = VALUE_STRING_EXT_INIT(reason_vals);
321 /* desegmentation of OSI over ses */
322 static bool ses_desegment = true;
324 /* RTSE reassembly data */
325 static unsigned ses_pres_ctx_id;
326 static bool ses_rtse_reassemble;
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)
334 /* do we have OSI presentation packet dissector ? */
335 if(!pres_handle)
337 /* No - display as data */
338 if (tree)
340 proto_tree_add_item(param_tree, hf_ses_user_data, tvb, offset, param_len, ENC_NA);
343 else
345 /* Yes - call presentation dissector */
346 tvbuff_t *next_tvb;
348 next_tvb = tvb_new_subset_length(tvb, offset, param_len);
349 /* Pass the session pdu to the presentation dissector */
350 call_dissector_with_data(pres_handle, next_tvb, pinfo, tree, session);
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)
359 uint16_t len;
361 len = tvb_get_uint8(tvb, offset);
362 if(len == TWO_BYTE_LEN)
364 len = tvb_get_ntohs(tvb, offset+1);
365 *len_len = 3;
367 else
368 *len_len = 1;
369 return len;
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)
378 bool has_user_information = true;
379 uint16_t flags;
380 asn1_ctx_t asn1_ctx;
381 static int * const item_option_flags[] = {
382 &hf_release_token,
383 &hf_major_activity_token,
384 &hf_synchronize_minor_token,
385 &hf_data_token,
386 NULL
388 static int * const transport_option_flags[] = {
389 &hf_ses_transport_connection,
390 &hf_ses_transport_user_abort,
391 &hf_ses_transport_protocol_error,
392 &hf_ses_transport_no_reason,
393 &hf_ses_transport_implementation_restriction,
394 NULL
396 static int * const protocol_options_flags[] = {
397 &hf_able_to_receive_extended_concatenated_SPDU,
398 NULL
400 static int * const req_options_flags[] = {
401 &hf_session_exception_report,
402 &hf_data_separation_function_unit,
403 &hf_symmetric_synchronize_function_unit,
404 &hf_typed_data_function_unit,
405 &hf_exception_function_unit,
406 &hf_capability_function_unit,
407 &hf_negotiated_release_function_unit,
408 &hf_activity_management_function_unit,
409 &hf_resynchronize_function_unit,
410 &hf_major_resynchronize_function_unit,
411 &hf_minor_resynchronize_function_unit,
412 &hf_expedited_data_resynchronize_function_unit,
413 &hf_duplex_function_unit,
414 &hf_half_duplex_function_unit,
415 NULL
417 static int * const version_flags[] = {
418 &hf_protocol_version_2,
419 &hf_protocol_version_1,
420 NULL
422 static int * const enclosure_flags[] = {
423 &hf_end_of_SSDU,
424 &hf_beginning_of_SSDU,
425 NULL
428 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
430 switch (param_type)
432 case Called_SS_user_Reference:
433 if (param_len == 0)
434 break;
436 proto_tree_add_item(param_tree,
437 hf_called_ss_user_reference,
438 tvb, offset, param_len, ENC_NA);
439 break;
441 case Calling_SS_user_Reference:
442 if (param_len == 0)
443 break;
445 proto_tree_add_item(param_tree,
446 hf_calling_ss_user_reference,
447 tvb, offset, param_len, ENC_NA);
448 break;
450 case Common_Reference:
451 if (param_len == 0)
452 break;
454 proto_tree_add_item(param_tree,
455 hf_common_reference,
456 tvb, offset, param_len, ENC_NA);
457 break;
459 case Additional_Reference_Information:
460 if (param_len == 0)
461 break;
463 proto_tree_add_item(param_tree,
464 hf_additional_reference_information,
465 tvb, offset, param_len, ENC_NA);
466 break;
468 case Token_Item:
469 if (param_len != 1)
471 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
472 "Length is %u, should be 1", param_len);
473 break;
476 proto_tree_add_bitmask(param_tree, tvb, offset, hf_token_item_options_flags, ett_token_item_flags, item_option_flags, ENC_NA);
477 break;
479 case Transport_Disconnect:
480 if (param_len != 1)
482 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
483 "Length is %u, should be 1", param_len);
484 break;
486 proto_tree_add_bitmask(param_tree, tvb, offset, hf_ses_transport_option_flags, ett_transport_options_flags, transport_option_flags, ENC_NA);
488 if(tvb_get_uint8(tvb, offset) & user_abort )
490 session->abort_type = SESSION_USER_ABORT;
492 else
494 session->abort_type = SESSION_PROVIDER_ABORT;
496 break;
498 case Protocol_Options:
499 if (param_len != 1)
501 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
502 "Length is %u, should be 1", param_len);
503 break;
506 proto_tree_add_bitmask(param_tree, tvb, offset, hf_connect_protocol_options_flags, ett_connect_protocol_options_flags, protocol_options_flags, ENC_NA);
507 break;
509 case Session_Requirement:
510 if (param_len != 2)
512 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
513 "Length is %u, should be 2", param_len);
514 break;
516 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 break;
519 case TSDU_Maximum_Size:
520 if (param_len != 4)
522 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
523 "Length is %u, should be 4", param_len);
524 break;
526 if (tree)
528 proto_tree_add_item(param_tree,
529 hf_proposed_tsdu_maximum_size_i2r,
530 tvb, offset, 2, ENC_BIG_ENDIAN);
531 proto_tree_add_item(param_tree,
532 hf_proposed_tsdu_maximum_size_r2i,
533 tvb, offset+2, 2, ENC_BIG_ENDIAN);
535 break;
537 case Version_Number:
538 if (param_len != 1)
540 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
541 "Length is %u, should be 1", param_len);
542 break;
544 proto_tree_add_bitmask(param_tree, tvb, offset, hf_version_number_options_flags, ett_protocol_version_flags, version_flags, ENC_BIG_ENDIAN);
545 break;
547 case Initial_Serial_Number:
548 if (param_len == 0)
549 break;
551 proto_tree_add_item(param_tree,
552 hf_initial_serial_number,
553 tvb, offset, param_len, ENC_ASCII);
554 break;
556 case EnclosureItem:
557 if (param_len != 1)
559 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
560 "Length is %u, should be 1", param_len);
561 break;
563 flags = tvb_get_uint8(tvb, offset);
564 *enclosure_item_flags = (uint8_t) flags;
565 proto_tree_add_bitmask(param_tree, tvb, offset, hf_enclosure_item_options_flags, ett_enclosure_item_flags, enclosure_flags, ENC_BIG_ENDIAN);
567 if (flags & END_SPDU) {
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.
577 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.
583 * So, there is only no user information if *only* END_SPDU is set.
586 has_user_information = false;
589 break;
591 case Token_Setting_Item:
592 if (param_len != 1)
594 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
595 "Length is %u, should be 1", param_len);
596 break;
598 if (tree)
600 proto_tree_add_item(param_tree,
601 hf_release_token_setting,
602 tvb, offset, 1, ENC_BIG_ENDIAN);
603 proto_tree_add_item(param_tree,
604 hf_major_activity_token_setting,
605 tvb, offset, 1, ENC_BIG_ENDIAN);
606 proto_tree_add_item(param_tree,
607 hf_synchronize_minor_token_setting,
608 tvb, offset, 1, ENC_BIG_ENDIAN);
609 proto_tree_add_item(param_tree,
610 hf_data_token_setting,
611 tvb, offset, 1, ENC_BIG_ENDIAN);
613 break;
615 case Activity_Identifier:
616 if (param_len == 0)
617 break;
619 /* 8.3.29.2 The parameter fields shall be as specified in Table 37.
620 * Activity Identifier m 41 6 octets maximum
622 proto_tree_add_item(param_tree,
623 hf_activity_identifier,
624 tvb, offset, param_len, ENC_NA);
625 break;
627 case Serial_Number:
628 if (param_len == 0)
629 break;
631 proto_tree_add_item(param_tree,
632 hf_serial_number,
633 tvb, offset, param_len, ENC_ASCII);
634 break;
636 case Reason_Code:
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 if (param_len < 1)
653 expert_add_info_format(pinfo, param_len_item, &ei_ses_bad_length,
654 "Length is %u, should be >= 1", param_len);
655 break;
658 proto_tree_add_item(param_tree, hf_ses_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
659 offset++;
660 param_len--;
661 if (param_len != 0)
663 call_pres_dissector(tvb, offset, param_len,
664 pinfo, tree, param_tree, session);
666 break;
668 case Calling_Session_Selector:
669 if (param_len == 0)
670 break;
672 proto_tree_add_item(param_tree,
673 hf_calling_session_selector,
674 tvb, offset, param_len, ENC_NA);
675 break;
677 case Called_Session_Selector:
678 if (param_len == 0)
679 break;
681 proto_tree_add_item(param_tree,
682 hf_called_session_selector,
683 tvb, offset, param_len, ENC_NA);
684 break;
686 case Second_Serial_Number:
687 if (param_len == 0)
688 break;
690 proto_tree_add_item(param_tree,
691 hf_second_serial_number,
692 tvb, offset, param_len, ENC_ASCII);
693 break;
695 case Second_Initial_Serial_Number:
696 if (param_len == 0)
697 break;
699 proto_tree_add_item(param_tree,
700 hf_second_initial_serial_number,
701 tvb, offset, param_len, ENC_ASCII);
702 break;
704 case Large_Initial_Serial_Number:
705 if (param_len == 0)
706 break;
708 proto_tree_add_item(param_tree,
709 hf_large_initial_serial_number,
710 tvb, offset, param_len, ENC_ASCII);
711 break;
713 case Large_Second_Initial_Serial_Number:
714 if (param_len == 0)
715 break;
717 proto_tree_add_item(param_tree,
718 hf_large_second_initial_serial_number,
719 tvb, offset, param_len, ENC_ASCII);
720 break;
722 default:
723 break;
725 return has_user_information;
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)
733 bool has_user_information = true;
734 proto_item *ti, *param_len_item;
735 proto_tree *param_tree;
736 uint8_t param_type;
737 const char *param_str;
738 int len_len;
739 uint16_t param_len;
741 while(pg_len != 0)
743 param_type = tvb_get_uint8(tvb, offset);
744 param_tree = proto_tree_add_subtree(pg_tree, tvb, offset, -1,
745 ett_ses_param, &ti,
746 val_to_str_ext(param_type, &param_vals_ext, "Unknown parameter type (0x%02x)"));
747 param_str = val_to_str_ext_const(param_type, &param_vals_ext, "Unknown");
748 proto_tree_add_item(param_tree, hf_ses_parameter_type, tvb, offset, 1, ENC_BIG_ENDIAN);
749 offset++;
750 pg_len--;
751 param_len = get_item_len(tvb, offset, &len_len);
752 if (len_len > pg_len) {
753 proto_item_set_len(ti, pg_len + 1);
754 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 return has_user_information;
757 pg_len -= len_len;
758 if (param_len > pg_len) {
759 proto_item_set_len(ti, pg_len + 1 + len_len);
760 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 return has_user_information;
763 proto_item_set_len(ti, 1 + len_len + param_len);
764 param_len_item = proto_tree_add_uint(param_tree, hf_ses_parameter_length, tvb, offset, len_len, param_len);
765 offset += len_len;
767 if (param_str != NULL)
769 switch(param_type)
771 /* PG's in PG's are invalid, presumably */
772 case Extended_User_Data:
773 case User_Data:
774 case Connect_Accept_Item:
775 case Connection_Identifier:
776 case Linking_Information:
777 proto_tree_add_item(param_tree, hf_ses_parameter_group_inside_parameter_group, tvb, offset, param_len, ENC_NA);
778 break;
780 default:
781 if (!dissect_parameter(tvb, offset, tree,
782 param_tree, pinfo, param_type, param_len, param_len_item,
783 enclosure_item_flags, session))
784 has_user_information = false;
785 break;
788 offset += param_len;
789 pg_len -= param_len;
791 return has_user_information;
795 * Returns true if there's a User Information field in this SPDU, false
796 * otherwise.
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)
803 bool has_user_information = true;
804 proto_item *ti, *param_len_item;
805 proto_tree *param_tree;
806 uint8_t param_type;
807 const char *param_str;
808 int len_len;
809 uint16_t param_len;
811 while (len != 0)
813 param_type = tvb_get_uint8(tvb, offset);
814 param_tree = proto_tree_add_subtree(ses_tree, tvb, offset, -1, ett_ses_param, &ti,
815 val_to_str_ext(param_type, &param_vals_ext,
816 "Unknown parameter type (0x%02x)"));
817 param_str = val_to_str_ext_const(param_type, &param_vals_ext, "Unknown");
818 proto_tree_add_item(param_tree, hf_ses_parameter_type, tvb, offset, 1, ENC_BIG_ENDIAN);
819 offset++;
820 len--;
821 param_len = get_item_len(tvb, offset, &len_len);
822 if (len_len > len) {
823 proto_item_set_len(ti, len + 1 );
824 proto_tree_add_expert_format(param_tree, pinfo, &ei_ses_bad_parameter_length, tvb, offset, len, "Parameter length doesn't fit in parameter");
825 return has_user_information;
827 len -= len_len;
828 if (param_len > len) {
829 proto_item_set_len(ti, len + 1 + len_len);
830 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 return has_user_information;
833 proto_item_set_len(ti, 1 + len_len + param_len);
834 param_len_item = proto_tree_add_uint(param_tree, hf_ses_parameter_length, tvb, offset, len_len, param_len);
835 offset += len_len;
837 if (param_str != NULL)
839 switch(param_type)
841 case Extended_User_Data:
842 call_pres_dissector(tvb, offset, param_len,
843 pinfo, tree, param_tree, session);
844 break;
846 case User_Data:
847 call_pres_dissector(tvb, offset, param_len,
848 pinfo, tree, param_tree, session);
849 break;
851 /* handle PGI's */
852 case Connect_Accept_Item:
853 case Connection_Identifier:
854 case Linking_Information:
855 /* Yes. */
856 if (!dissect_parameter_group(tvb, offset, tree,
857 param_tree, pinfo, param_len, enclosure_item_flags, session))
858 has_user_information = false;
859 break;
861 /* everything else is a PI */
862 default:
863 if (!dissect_parameter(tvb, offset, tree,
864 param_tree, pinfo, param_type, param_len, param_len_item,
865 enclosure_item_flags, session))
866 has_user_information = false;
867 break;
870 offset += param_len;
871 len -= param_len;
873 return has_user_information;
877 * Dissect an SPDU.
879 static int
880 dissect_spdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
881 bool tokens, bool connectionless)
883 bool has_user_information = false;
884 uint8_t type;
885 proto_item *ti = NULL;
886 proto_tree *ses_tree = NULL;
887 int len_len;
888 uint16_t parameters_len;
889 tvbuff_t *next_tvb = NULL;
890 uint32_t *pres_ctx_id = NULL;
891 uint8_t enclosure_item_flags = BEGINNING_SPDU|END_SPDU;
892 struct SESSION_DATA_STRUCTURE session;
895 * Get SPDU type.
897 type = tvb_get_uint8(tvb, offset);
898 session.spdu_type = type;
899 session.abort_type = SESSION_NO_ABORT;
900 session.pres_ctx_id = 0;
901 session.ros_op = 0;
902 session.rtse_reassemble = false;
904 if(connectionless) {
905 col_add_str(pinfo->cinfo, COL_INFO,
906 val_to_str_ext(type, &ses_vals_ext, "Unknown SPDU type (0x%02x)"));
907 if (tree) {
908 ti = proto_tree_add_item(tree, proto_clses, tvb, offset,
909 -1, ENC_NA);
910 ses_tree = proto_item_add_subtree(ti, ett_ses);
911 proto_tree_add_uint(ses_tree, hf_ses_type, tvb,
912 offset, 1, type);
914 has_user_information = true;
916 else if (tokens) {
917 col_add_str(pinfo->cinfo, COL_INFO,
918 val_to_str(type, ses_category0_vals, "Unknown SPDU type (0x%02x)"));
919 if (tree) {
920 ti = proto_tree_add_item(tree, proto_ses, tvb, offset,
921 -1, ENC_NA);
922 ses_tree = proto_item_add_subtree(ti, ett_ses);
923 proto_tree_add_uint(ses_tree, hf_ses_type_0, tvb,
924 offset, 1, type);
926 } else {
927 col_add_str(pinfo->cinfo, COL_INFO,
928 val_to_str_ext(type, &ses_vals_ext, "Unknown SPDU type (0x%02x)"));
929 if (tree) {
930 ti = proto_tree_add_item(tree, proto_ses, tvb, offset,
931 -1, ENC_NA);
932 ses_tree = proto_item_add_subtree(ti, ett_ses);
933 proto_tree_add_uint(ses_tree, hf_ses_type, tvb,
934 offset, 1, type);
938 * Might this SPDU have a User Information field?
940 switch (type) {
941 case SES_DATA_TRANSFER:
942 case SES_EXPEDITED:
943 case SES_TYPED_DATA:
944 has_user_information = true;
945 break;
946 case SES_MAJOR_SYNC_POINT:
947 pres_ctx_id = (uint32_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ses, 0);
948 if (ses_rtse_reassemble != 0 && !pres_ctx_id) {
949 /* First time visited - save pres_ctx_id */
950 pres_ctx_id = wmem_new(wmem_file_scope(), uint32_t);
951 *pres_ctx_id = ses_pres_ctx_id;
952 p_add_proto_data(wmem_file_scope(), pinfo, proto_ses, 0, pres_ctx_id);
954 if (pres_ctx_id) {
955 session.pres_ctx_id = *pres_ctx_id;
956 session.rtse_reassemble = true;
957 has_user_information = true;
959 ses_rtse_reassemble = false;
960 break;
963 offset++;
965 /* get length of SPDU parameter field */
966 parameters_len = get_item_len(tvb, offset, &len_len);
967 if (tree)
968 proto_tree_add_uint(ses_tree, hf_ses_length, tvb, offset,
969 len_len, parameters_len);
970 offset += len_len;
972 /* Dissect parameters. */
973 if (!dissect_parameters(tvb, offset, parameters_len, tree, ses_tree,
974 pinfo, &enclosure_item_flags, &session))
975 has_user_information = false;
976 offset += parameters_len;
978 proto_item_set_end(ti, tvb, offset);
980 /* Dissect user information, if present */
981 if (!ses_desegment || enclosure_item_flags == (BEGINNING_SPDU|END_SPDU)) {
982 if (has_user_information) {
983 /* Not desegment or only one segment */
984 if (tvb_reported_length_remaining(tvb, offset) > 0 || type == SES_MAJOR_SYNC_POINT) {
985 next_tvb = tvb_new_subset_remaining(tvb, offset);
988 } else {
989 conversation_t *conversation = NULL;
990 fragment_head *frag_msg = NULL;
991 int fragment_len;
992 uint32_t ses_id = 0;
994 /* Use conversation index as segment id */
995 conversation = find_conversation_pinfo(pinfo, 0);
996 if (conversation != NULL) {
997 ses_id = conversation->conv_index;
999 fragment_len = tvb_reported_length_remaining (tvb, offset);
1000 ti = proto_tree_add_item (ses_tree, hf_ses_segment_data, tvb, offset,
1001 fragment_len, ENC_NA);
1002 proto_item_append_text (ti, " (%d byte%s)", fragment_len, plurality (fragment_len, "", "s"));
1003 frag_msg = fragment_add_seq_next (&ses_reassembly_table,
1004 tvb, offset,
1005 pinfo, ses_id, NULL,
1006 fragment_len,
1007 (enclosure_item_flags & END_SPDU) ? false : true);
1008 next_tvb = process_reassembled_data (tvb, offset, pinfo, "Reassembled SES",
1009 frag_msg, &ses_frag_items, NULL,
1010 (enclosure_item_flags & END_SPDU) ? tree : ses_tree);
1012 has_user_information = true;
1013 offset += fragment_len;
1016 if (has_user_information && next_tvb) {
1017 if (!pres_handle) {
1018 call_data_dissector(next_tvb, pinfo, tree);
1019 } else {
1020 /* Pass the session pdu to the presentation dissector */
1021 call_dissector_with_data(pres_handle, next_tvb, pinfo, tree, &session);
1025 * No more SPDUs to dissect. Set the offset to the
1026 * end of the tvbuff.
1028 offset = tvb_captured_length(tvb);
1029 if (session.rtse_reassemble && type == SES_DATA_TRANSFER) {
1030 ses_pres_ctx_id = session.pres_ctx_id;
1031 ses_rtse_reassemble = true;
1034 return offset;
1038 * Dissect SPDUs inside a TSDU.
1040 static int
1041 dissect_ses(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1043 int offset = 0;
1044 uint8_t type;
1045 bool is_clsp = false;
1047 type = tvb_get_uint8(tvb, offset);
1048 if(type == CLSES_UNIT_DATA)
1049 is_clsp = true;
1052 col_set_str(pinfo->cinfo, COL_PROTOCOL, is_clsp ? "CLSES" : "SES");
1053 col_clear(pinfo->cinfo, COL_INFO);
1057 * Do we have a category 0 SPDU (GIVE_TOKENS/PLEASE_TOKENS) as
1058 * the first SPDU?
1060 * If so, dissect it as such (GIVE_TOKENS and DATA_TRANSFER have
1061 * the same SPDU type value).
1063 if ((type == SES_PLEASE_TOKENS) || (type == SES_GIVE_TOKENS))
1064 offset = dissect_spdu(tvb, offset, pinfo, tree, TOKENS_SPDU, false);
1067 /* Dissect the remaining SPDUs. */
1068 while (tvb_reported_length_remaining(tvb, offset) > 0)
1069 offset = dissect_spdu(tvb, offset, pinfo, tree, NON_TOKENS_SPDU, is_clsp);
1070 return tvb_captured_length(tvb);
1073 static bool
1074 dissect_ses_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data)
1076 /* must check that this really is a ses packet */
1077 int offset = 0;
1078 uint8_t type;
1079 int len_len;
1080 uint16_t len;
1082 /* first, check do we have at least 4 bytes (type+length) */
1083 if (tvb_captured_length(tvb) < 2)
1084 return false; /* no */
1086 /* can we recognize session PDU ? Return false if not */
1087 /* get SPDU type */
1088 type = tvb_get_uint8(tvb, offset);
1089 /* check SPDU type */
1090 if (try_val_to_str_ext(type, &ses_vals_ext) == NULL)
1092 return false; /* no, it isn't a session PDU */
1095 /* can we recognize the second session PDU if the first one was
1096 * a Give Tokens PDU? Return false if not */
1097 if(tvb_bytes_exist(tvb, 2, 2) && type == SES_GIVE_TOKENS) {
1098 /* get SPDU type */
1099 type = tvb_get_uint8(tvb, offset+2);
1100 /* check SPDU type */
1101 if (try_val_to_str_ext(type, &ses_vals_ext) == NULL)
1103 return false; /* no, it isn't a session PDU */
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 if(type == 0x32 && tvb_captured_length(tvb) >= 3) {
1112 type = tvb_get_uint8(tvb, offset+2);
1113 if (try_val_to_str_ext(type, &param_vals_ext) == NULL) {
1114 return false; /* it's probably a SIMATIC protocol */
1118 /* OK,let's check SPDU length */
1119 /* get length of SPDU */
1120 len = get_item_len(tvb, offset+1, &len_len);
1122 /* add header length */
1123 len+=len_len;
1124 /* do we have enough bytes ? */
1125 if (tvb_reported_length(tvb) < len)
1126 return false; /* no */
1128 /* final check to see if the next SPDU, if present, is also valid */
1129 if (tvb_captured_length(tvb) > 1+(unsigned) len) {
1130 type = tvb_get_uint8(tvb, offset + len + 1);
1131 /* check SPDU type */
1132 if (try_val_to_str_ext(type, &ses_vals_ext) == NULL) {
1133 return false; /* no, it isn't a session PDU */
1137 dissect_ses(tvb, pinfo, parent_tree, data);
1138 return true;
1141 void
1142 proto_register_ses(void)
1144 static hf_register_info hf[] =
1147 &hf_ses_type,
1149 "SPDU Type",
1150 "ses.type",
1151 FT_UINT8,
1152 BASE_DEC | BASE_EXT_STRING,
1153 &ses_vals_ext,
1154 0x0,
1155 NULL, HFILL
1159 &hf_ses_type_0,
1161 "SPDU Type",
1162 "ses.type",
1163 FT_UINT8,
1164 BASE_DEC,
1165 VALS(ses_category0_vals),
1166 0x0,
1167 NULL, HFILL
1171 &hf_ses_length,
1173 "Length",
1174 "ses.length",
1175 FT_UINT16,
1176 BASE_DEC,
1177 NULL,
1178 0x0,
1179 NULL, HFILL
1183 #if 0
1185 &hf_ses_version,
1187 "Version",
1188 "ses.version",
1189 FT_UINT8,
1190 BASE_DEC,
1191 NULL,
1192 0x0,
1193 NULL, HFILL
1196 #endif
1197 #if 0
1199 &hf_ses_reserved,
1201 "Reserved",
1202 "ses.reserved",
1203 FT_UINT8,
1204 BASE_DEC,
1205 NULL,
1206 0x0,
1207 NULL, HFILL
1210 #endif
1212 &hf_called_ss_user_reference,
1214 "Called SS User Reference",
1215 "ses.called_ss_user_reference",
1216 FT_BYTES, BASE_NONE,
1217 NULL,
1218 0x0,
1219 NULL,
1220 HFILL
1224 &hf_calling_ss_user_reference,
1226 "Calling SS User Reference",
1227 "ses.calling_ss_user_reference",
1228 FT_BYTES, BASE_NONE,
1229 NULL,
1230 0x0,
1231 NULL,
1232 HFILL
1236 &hf_common_reference,
1238 "Common Reference",
1239 "ses.common_reference",
1240 FT_BYTES, BASE_NONE,
1241 NULL,
1242 0x0,
1243 NULL,
1244 HFILL
1248 &hf_additional_reference_information,
1250 "Additional Reference Information",
1251 "ses.additional_reference_information",
1252 FT_BYTES, BASE_NONE,
1253 NULL,
1254 0x0,
1255 NULL,
1256 HFILL
1260 &hf_release_token,
1262 "release token",
1263 "ses.release_token",
1264 FT_BOOLEAN, 8,
1265 NULL,
1266 RELEASE_TOKEN,
1267 NULL,
1268 HFILL
1272 &hf_major_activity_token,
1274 "major/activity token",
1275 "ses.major.token",
1276 FT_BOOLEAN, 8,
1277 NULL,
1278 MAJOR_ACTIVITY_TOKEN,
1279 NULL,
1280 HFILL
1284 &hf_synchronize_minor_token,
1286 "synchronize minor token",
1287 "ses.synchronize_token",
1288 FT_BOOLEAN, 8,
1289 NULL,
1290 SYNCHRONIZE_MINOR_TOKEN,
1291 NULL,
1292 HFILL
1296 &hf_data_token,
1298 "data token",
1299 "ses.data_token",
1300 FT_BOOLEAN, 8,
1301 NULL,
1302 DATA_TOKEN,
1303 "data token",
1304 HFILL
1308 &hf_able_to_receive_extended_concatenated_SPDU,
1310 "Able to receive extended concatenated SPDU",
1311 "ses.connect.f1",
1312 FT_BOOLEAN, 8,
1313 NULL,
1314 SES_EXT_CONT,
1315 NULL,
1316 HFILL
1320 &hf_session_user_req_flags,
1322 "Flags",
1323 "ses.req.flags",
1324 FT_UINT16,
1325 BASE_HEX,
1326 NULL,
1327 0x0,
1328 NULL,
1329 HFILL
1333 &hf_session_exception_report,
1335 "Session exception report",
1336 "ses.exception_report",
1337 FT_BOOLEAN, 16,
1338 NULL,
1339 SES_EXCEPTION_REPORT,
1340 NULL,
1341 HFILL
1345 &hf_data_separation_function_unit,
1347 "Data separation function unit",
1348 "ses.data_sep",
1349 FT_BOOLEAN, 16,
1350 NULL,
1351 DATA_SEPARATION_FUNCTION_UNIT,
1352 NULL,
1353 HFILL
1357 &hf_symmetric_synchronize_function_unit,
1359 "Symmetric synchronize function unit",
1360 "ses.symm_sync",
1361 FT_BOOLEAN, 16,
1362 NULL,
1363 SYMMETRIC_SYNCHRONIZE_FUNCTION_UNIT,
1364 NULL,
1365 HFILL
1369 &hf_typed_data_function_unit,
1371 "Typed data function unit",
1372 "ses.typed_data",
1373 FT_BOOLEAN, 16,
1374 NULL,
1375 TYPED_DATA_FUNCTION_UNIT,
1376 NULL,
1377 HFILL
1381 &hf_exception_function_unit,
1383 "Exception function unit",
1384 "ses.exception_data",
1385 FT_BOOLEAN, 16,
1386 NULL,
1387 EXCEPTION_FUNCTION_UNIT,
1388 NULL,
1389 HFILL
1393 &hf_capability_function_unit,
1395 "Capability function unit",
1396 "ses.capability_data",
1397 FT_BOOLEAN, 16,
1398 NULL,
1399 CAPABILITY_DATA_FUNCTION_UNIT,
1400 NULL,
1401 HFILL
1405 &hf_negotiated_release_function_unit,
1407 "Negotiated release function unit",
1408 "ses.negotiated_release",
1409 FT_BOOLEAN, 16,
1410 NULL,
1411 NEGOTIATED_RELEASE_FUNCTION_UNIT,
1412 NULL,
1413 HFILL
1417 &hf_activity_management_function_unit,
1419 "Activity management function unit",
1420 "ses.activity_management",
1421 FT_BOOLEAN, 16,
1422 NULL,
1423 ACTIVITY_MANAGEMENT_FUNCTION_UNIT,
1424 NULL,
1425 HFILL
1429 &hf_resynchronize_function_unit,
1431 "Resynchronize function unit",
1432 "ses.resynchronize",
1433 FT_BOOLEAN, 16,
1434 NULL,
1435 RESYNCHRONIZE_FUNCTION_UNIT,
1436 NULL,
1437 HFILL
1441 &hf_major_resynchronize_function_unit,
1443 "Major resynchronize function unit",
1444 "ses.major_resynchronize",
1445 FT_BOOLEAN, 16,
1446 NULL,
1447 MAJOR_SYNCHRONIZE_FUNCTION_UNIT,
1448 NULL,
1449 HFILL
1453 &hf_minor_resynchronize_function_unit,
1455 "Minor resynchronize function unit",
1456 "ses.minor_resynchronize",
1457 FT_BOOLEAN, 16,
1458 NULL,
1459 MINOR_SYNCHRONIZE_FUNCTION_UNIT,
1460 NULL,
1461 HFILL
1465 &hf_expedited_data_resynchronize_function_unit,
1467 "Expedited data function unit",
1468 "ses.expedited_data",
1469 FT_BOOLEAN, 16,
1470 NULL,
1471 EXPEDITED_DATA_FUNCTION_UNIT,
1472 NULL,
1473 HFILL
1477 &hf_duplex_function_unit,
1479 "Duplex functional unit",
1480 "ses.duplex",
1481 FT_BOOLEAN, 16,
1482 NULL,
1483 DUPLEX_FUNCTION_UNIT,
1484 NULL,
1485 HFILL
1489 &hf_half_duplex_function_unit,
1491 "Half-duplex functional unit",
1492 "ses.half_duplex",
1493 FT_BOOLEAN, 16,
1494 NULL,
1495 HALF_DUPLEX_FUNCTION_UNIT,
1496 NULL,
1497 HFILL
1501 &hf_proposed_tsdu_maximum_size_i2r,
1503 "Proposed TSDU Maximum Size, Initiator to Responder",
1504 "ses.proposed_tsdu_maximum_size_i2r",
1505 FT_UINT16,
1506 BASE_DEC,
1507 NULL,
1508 0x0,
1509 NULL,
1510 HFILL
1514 &hf_proposed_tsdu_maximum_size_r2i,
1516 "Proposed TSDU Maximum Size, Responder to Initiator",
1517 "ses.proposed_tsdu_maximum_size_r2i",
1518 FT_UINT16,
1519 BASE_DEC,
1520 NULL,
1521 0x0,
1522 NULL,
1523 HFILL
1527 &hf_protocol_version_1,
1529 "Protocol Version 1",
1530 "ses.protocol_version1",
1531 FT_BOOLEAN, 8,
1532 NULL,
1533 PROTOCOL_VERSION_1,
1534 NULL,
1535 HFILL
1539 &hf_protocol_version_2,
1541 "Protocol Version 2",
1542 "ses.protocol_version2",
1543 FT_BOOLEAN, 8,
1544 NULL,
1545 PROTOCOL_VERSION_2,
1546 NULL,
1547 HFILL
1551 &hf_initial_serial_number,
1553 "Initial Serial Number",
1554 "ses.initial_serial_number",
1555 FT_STRING, BASE_NONE,
1556 NULL,
1557 0x0,
1558 NULL,
1559 HFILL
1563 &hf_beginning_of_SSDU,
1565 "beginning of SSDU",
1566 "ses.beginning_of_SSDU",
1567 FT_BOOLEAN, 8,
1568 NULL,
1569 BEGINNING_SPDU,
1570 NULL,
1571 HFILL
1575 &hf_end_of_SSDU,
1577 "end of SSDU",
1578 "ses.end_of_SSDU",
1579 FT_BOOLEAN, 8,
1580 NULL,
1581 END_SPDU,
1582 NULL,
1583 HFILL
1587 &hf_release_token_setting,
1589 "release token setting",
1590 "ses.release_token_setting",
1591 FT_UINT8, BASE_HEX,
1592 VALS(token_setting_vals),
1593 0xC0,
1594 NULL,
1595 HFILL
1599 &hf_major_activity_token_setting,
1601 "major/activity setting",
1602 "ses.major_activity_token_setting",
1603 FT_UINT8, BASE_HEX,
1604 VALS(token_setting_vals),
1605 0x30,
1606 "major/activity token setting",
1607 HFILL
1611 &hf_synchronize_minor_token_setting,
1613 "synchronize-minor token setting",
1614 "ses.synchronize_minor_token_setting",
1615 FT_UINT8, BASE_HEX,
1616 VALS(token_setting_vals),
1617 0x0C,
1618 NULL,
1619 HFILL
1623 &hf_data_token_setting,
1625 "data token setting",
1626 "ses.data_token_setting",
1627 FT_UINT8, BASE_HEX,
1628 VALS(token_setting_vals),
1629 0x03,
1630 NULL,
1631 HFILL
1635 &hf_activity_identifier,
1637 "Activity Identifier",
1638 "ses.activity_identifier",
1639 FT_BYTES, BASE_NONE,
1640 NULL,
1641 0x0,
1642 NULL,
1643 HFILL
1647 &hf_serial_number,
1649 "Serial Number",
1650 "ses.serial_number",
1651 FT_STRING, BASE_NONE,
1652 NULL,
1653 0x0,
1654 NULL,
1655 HFILL
1659 &hf_calling_session_selector,
1661 "Calling Session Selector",
1662 "ses.calling_session_selector",
1663 FT_BYTES, BASE_NONE,
1664 NULL,
1665 0x0,
1666 NULL,
1667 HFILL
1671 &hf_called_session_selector,
1673 "Called Session Selector",
1674 "ses.called_session_selector",
1675 FT_BYTES, BASE_NONE,
1676 NULL,
1677 0x0,
1678 NULL,
1679 HFILL
1683 &hf_second_serial_number,
1685 "Second Serial Number",
1686 "ses.second_serial_number",
1687 FT_STRING, BASE_NONE,
1688 NULL,
1689 0x0,
1690 NULL,
1691 HFILL
1695 &hf_second_initial_serial_number,
1697 "Second Initial Serial Number",
1698 "ses.second_initial_serial_number",
1699 FT_STRING, BASE_NONE,
1700 NULL,
1701 0x0,
1702 NULL,
1703 HFILL
1707 &hf_large_initial_serial_number,
1709 "Large Initial Serial Number",
1710 "ses.large_initial_serial_number",
1711 FT_STRING, BASE_NONE,
1712 NULL,
1713 0x0,
1714 NULL,
1715 HFILL
1719 &hf_large_second_initial_serial_number,
1721 "Large Second Initial Serial Number",
1722 "ses.large_second_initial_serial_number",
1723 FT_STRING, BASE_NONE,
1724 NULL,
1725 0x0,
1726 NULL,
1727 HFILL
1731 &hf_connect_protocol_options_flags,
1733 "Flags",
1734 "ses.connect.flags",
1735 FT_UINT8,
1736 BASE_HEX,
1737 NULL,
1738 0x0,
1739 NULL,
1740 HFILL
1744 &hf_version_number_options_flags,
1747 "Flags",
1748 "ses.version.flags",
1749 FT_UINT8,
1750 BASE_HEX,
1751 NULL,
1752 0x0,
1753 NULL,
1754 HFILL
1759 &hf_token_item_options_flags,
1762 "Flags",
1763 "ses.tken_item.flags",
1764 FT_UINT8,
1765 BASE_HEX,
1766 NULL,
1767 0x0,
1768 NULL,
1769 HFILL
1774 &hf_enclosure_item_options_flags,
1777 "Flags",
1778 "ses.enclosure.flags",
1779 FT_UINT8,
1780 BASE_HEX,
1781 NULL,
1782 0x0,
1783 NULL,
1784 HFILL
1788 { &hf_ses_segment_data,
1789 { "SES segment data", "ses.segment.data", FT_NONE, BASE_NONE,
1790 NULL, 0x00, NULL, HFILL } },
1791 { &hf_ses_segments,
1792 { "SES segments", "ses.segments", FT_NONE, BASE_NONE,
1793 NULL, 0x00, NULL, HFILL } },
1794 { &hf_ses_segment,
1795 { "SES segment", "ses.segment", FT_FRAMENUM, BASE_NONE,
1796 NULL, 0x00, NULL, HFILL } },
1797 { &hf_ses_segment_overlap,
1798 { "SES segment overlap", "ses.segment.overlap", FT_BOOLEAN,
1799 BASE_NONE, NULL, 0x0, NULL, HFILL } },
1800 { &hf_ses_segment_overlap_conflicts,
1801 { "SES segment overlapping with conflicting data",
1802 "ses.segment.overlap.conflicts", FT_BOOLEAN, BASE_NONE,
1803 NULL, 0x0, NULL, HFILL } },
1804 { &hf_ses_segment_multiple_tails,
1805 { "SES has multiple tail segments",
1806 "ses.segment.multiple_tails", FT_BOOLEAN, BASE_NONE,
1807 NULL, 0x0, NULL, HFILL } },
1808 { &hf_ses_segment_too_long_segment,
1809 { "SES segment too long", "ses.segment.too_long_segment",
1810 FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
1811 { &hf_ses_segment_error,
1812 { "SES desegmentation error", "ses.segment.error", FT_FRAMENUM,
1813 BASE_NONE, NULL, 0x00, NULL, HFILL } },
1814 { &hf_ses_segment_count,
1815 { "SES segment count", "ses.segment.count", FT_UINT32, BASE_DEC,
1816 NULL, 0x00, NULL, HFILL } },
1817 { &hf_ses_reassembled_in,
1818 { "Reassembled SES in frame", "ses.reassembled.in", FT_FRAMENUM, BASE_NONE,
1819 NULL, 0x00, "This SES packet is reassembled in this frame", HFILL } },
1820 { &hf_ses_reassembled_length,
1821 { "Reassembled SES length", "ses.reassembled.length", FT_UINT32, BASE_DEC,
1822 NULL, 0x00, "The total length of the reassembled payload", HFILL } },
1824 /* Generated from convert_proto_tree_add_text.pl */
1825 { &hf_ses_user_data, { "User data", "ses.user_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1826 { &hf_ses_transport_option_flags, { "Flags", "ses.transport_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
1827 { &hf_ses_transport_connection, { "Transport connection", "ses.transport_flags.connection", FT_BOOLEAN, 8, TFS(&tfs_released_kept), transport_connection_is_released, NULL, HFILL }},
1828 { &hf_ses_transport_user_abort, { "User abort", "ses.transport_flags.user_abort", FT_BOOLEAN, 8, TFS(&tfs_yes_no), user_abort, NULL, HFILL }},
1829 { &hf_ses_transport_protocol_error, { "Protocol error", "ses.transport_flags.protocol_error", FT_BOOLEAN, 8, TFS(&tfs_yes_no), protocol_error, NULL, HFILL }},
1830 { &hf_ses_transport_no_reason, { "No reason", "ses.transport_flags.no_reason", FT_BOOLEAN, 8, TFS(&tfs_yes_no), no_reason, NULL, HFILL }},
1831 { &hf_ses_transport_implementation_restriction, { "Implementation restriction", "ses.transport_flags.implementation_restriction", FT_BOOLEAN, 8, TFS(&tfs_yes_no), implementation_restriction, NULL, HFILL }},
1832 { &hf_ses_reason_code, { "Reason Code", "ses.reason_code", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &reason_vals_ext, 0x0, NULL, HFILL }},
1833 { &hf_ses_parameter_type, { "Parameter type", "ses.parameter_type", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &param_vals_ext, 0x0, NULL, HFILL }},
1834 { &hf_ses_parameter_length, { "Parameter length", "ses.parameter_length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1835 { &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 }},
1838 static int *ett[] =
1840 &ett_ses,
1841 &ett_ses_param,
1842 &ett_connect_protocol_options_flags,
1843 &ett_transport_options_flags,
1844 &ett_protocol_version_flags,
1845 &ett_enclosure_item_flags,
1846 &ett_token_item_flags,
1847 &ett_ses_req_options_flags,
1848 &ett_ses_segment,
1849 &ett_ses_segments
1852 static ei_register_info ei[] = {
1853 { &ei_ses_bad_length, { "ses.bad_length", PI_MALFORMED, PI_ERROR, "Bad length", EXPFILL }},
1854 { &ei_ses_bad_parameter_length, { "ses.bad_parameter_length", PI_MALFORMED, PI_ERROR, "Bad parameter length", EXPFILL }},
1857 module_t *ses_module;
1858 expert_module_t* expert_ses;
1860 proto_ses = proto_register_protocol(PROTO_STRING_SES, "SES", "ses");
1861 proto_register_field_array(proto_ses, hf, array_length(hf));
1862 proto_register_subtree_array(ett, array_length(ett));
1863 expert_ses = expert_register_protocol(proto_ses);
1864 expert_register_field_array(expert_ses, ei, array_length(ei));
1866 reassembly_table_register (&ses_reassembly_table,
1867 &addresses_reassembly_table_functions);
1869 ses_module = prefs_register_protocol(proto_ses, NULL);
1871 prefs_register_bool_preference(ses_module, "desegment",
1872 "Reassemble session packets ",
1873 "Whether the session dissector should reassemble messages spanning multiple SES segments",
1874 &ses_desegment);
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).
1882 register_dissector("ses", dissect_ses, proto_ses);
1885 void
1886 proto_reg_handoff_ses(void)
1888 /* define sub dissector */
1889 pres_handle = find_dissector_add_dependency("pres", proto_ses);
1891 /* add our session dissector to cotp dissector list
1892 * and cotp_is dissector list*/
1893 heur_dissector_add("cotp", dissect_ses_heur, "SES over COTP", "ses_cotp", proto_ses, HEURISTIC_ENABLE);
1894 heur_dissector_add("cotp_is", dissect_ses_heur, "SES over COTP (inactive subset)", "ses_cotp_is", proto_ses, HEURISTIC_ENABLE);
1899 void proto_register_clses(void)
1901 proto_clses = proto_register_protocol(PROTO_STRING_CLSES, "CLSP", "clsp");
1904 void
1905 proto_reg_handoff_clses(void)
1907 /* add our session dissector to cltp dissector list */
1908 heur_dissector_add("cltp", dissect_ses_heur, "CLSP over COTP", "clses_cotp", proto_clses, HEURISTIC_ENABLE);
1912 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1914 * Local variables:
1915 * c-basic-offset: 8
1916 * tab-width: 8
1917 * indent-tabs-mode: t
1918 * End:
1920 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1921 * :indentSize=8:tabSize=8:noTabs=false: