2 * Routines for SAMETIME dissection
3 * Copyright 2010, Toralf Foerster <toralf.foerster [AT] gmx.de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
15 #include <epan/prefs.h>
16 #include <epan/stats_tree.h>
17 #include "packet-tcp.h"
19 #define DEFAULT_SAMETIME_PORT 1533 /* Not IANA registered */
21 void proto_register_sametime(void);
22 void proto_reg_handoff_sametime(void);
24 static int proto_sametime = -1;
25 static dissector_handle_t sametime_handle;
28 static gboolean global_sametime_show_length = FALSE;
29 static gboolean global_sametime_reassemble_packets = TRUE;
32 static int hf_sametime_heartbeat = -1;
34 /*sametime message header*/
35 static int hf_sametime_message_length = -1;
36 static int hf_sametime_message_type = -1;
37 static int hf_sametime_message_options = -1;
38 static int hf_sametime_message_options_attribute = -1;
39 static int hf_sametime_message_options_encrypted = -1;
40 static int hf_sametime_message_channel = -1;
43 static int hf_sametime_field_length = -1;
44 static int hf_sametime_field_text = -1;
45 static int hf_sametime_code = -1;
46 static int hf_sametime_login_type = -1;
47 static int hf_sametime_time = -1;
50 static int hf_sametime_handshake_major = -1;
51 static int hf_sametime_handshake_minor = -1;
52 static int hf_sametime_handshake_srvrcalc_addr = -1;
53 static int hf_sametime_handshake_loclcalc_addr = -1;
56 static int hf_sametime_channel_service = -1;
57 static int hf_sametime_channel_id = -1;
58 static int hf_sametime_channel_send_type = -1;
59 static int hf_sametime_channel_awareness = -1;
62 static int hf_sametime_user_status = -1;
65 static int hf_sametime_location_country = -1;
66 static int hf_sametime_location_postalcode = -1;
67 static int hf_sametime_location_province = -1;
68 static int hf_sametime_location_city = -1;
69 static int hf_sametime_location_phone = -1;
70 static int hf_sametime_location_name = -1;
71 static int hf_sametime_location_timezone = -1;
73 /*packet detail tree*/
74 static gint ett_sametime = -1;
75 static gint ett_sametime_options = -1;
78 static int sametime_tap = -1;
79 static const guint8* st_str_packet = "Sametime Message Count";
80 static const guint8* st_str_message_type = "Message Type";
81 static const guint8* st_str_send_type = "Send Type";
82 static const guint8* st_str_user_status = "User Status";
83 static int st_node_packet = -1;
84 static int st_node_message_type = -1;
85 static int st_node_send_type = -1;
86 static int st_node_user_status = -1;
88 typedef struct SametimeTap {
94 #define SAMETIME_MESSAGETYPE_HEARTBEAT 0x80
95 #define SAMETIME_MESSAGETYPE_HANDSHAKE 0x0000
97 #define SAMETIME_MESSAGETYPE_HANDSHAKE_ACK 0x8000
98 #define SAMETIME_MESSAGETYPE_HANDSHAKE_SYN 0x0025
99 #define SAMETIME_MESSAGETYPE_LOGIN 0x0001
100 #define SAMETIME_MESSAGETYPE_LOGIN_ACK 0x8001
101 #define SAMETIME_MESSAGETYPE_LOGIN_REDIRECT 0x0018
102 #define SAMETIME_MESSAGETYPE_LOGIN_CONTINUE 0x0016
104 #define SAMETIME_MESSAGETYPE_CHANNEL_CREATE 0x0002
105 #define SAMETIME_MESSAGETYPE_CHANNEL_DESTROY 0x0003
106 #define SAMETIME_MESSAGETYPE_CHANNEL_SEND 0x0004
107 #define SAMETIME_MESSAGETYPE_CHANNEL_ACCEPT 0x0006
109 #define SAMETIME_MESSAGETYPE_SET_USER_STATUS 0x0009
110 #define SAMETIME_MESSAGETYPE_SET_PRIVACY_LIST 0x000b
111 #define SAMETIME_MESSAGETYPE_SENSE_SERVICE 0x0011
112 #define SAMETIME_MESSAGETYPE_ADMIN 0x0019
113 #define SAMETIME_MESSAGETYPE_ANNOUNCE 0x0022
116 static const value_string messagetypenames[] = {
117 { SAMETIME_MESSAGETYPE_HEARTBEAT, "HEARTBEAT" },
119 { SAMETIME_MESSAGETYPE_HANDSHAKE, "HANDSHAKE" },
120 { SAMETIME_MESSAGETYPE_HANDSHAKE_SYN, "HANDSHAKE_SYN" },
121 { SAMETIME_MESSAGETYPE_HANDSHAKE_ACK, "HANDSHAKE_ACK" },
122 { SAMETIME_MESSAGETYPE_LOGIN, "LOGIN" },
123 { SAMETIME_MESSAGETYPE_LOGIN_ACK, "LOGIN_ACK" },
124 { SAMETIME_MESSAGETYPE_LOGIN_REDIRECT, "LOGIN_REDIRECT" },
125 { SAMETIME_MESSAGETYPE_LOGIN_CONTINUE, "LOGIN_CONTINUE" },
127 { SAMETIME_MESSAGETYPE_CHANNEL_CREATE, "CHANNEL_CREATE" },
128 { SAMETIME_MESSAGETYPE_CHANNEL_DESTROY, "CHANNEL_DESTROY" },
129 { SAMETIME_MESSAGETYPE_CHANNEL_SEND, "CHANNEL_SEND" },
130 { SAMETIME_MESSAGETYPE_CHANNEL_ACCEPT, "CHANNEL_ACCEPT" },
132 { SAMETIME_MESSAGETYPE_SET_USER_STATUS, "SET_USER_STATUS" },
133 { SAMETIME_MESSAGETYPE_SET_PRIVACY_LIST, "SET_PRIVACY_LIST" },
134 { SAMETIME_MESSAGETYPE_SENSE_SERVICE, "SENSE_SERVICE" },
135 { SAMETIME_MESSAGETYPE_ADMIN, "ADMIN" },
136 { SAMETIME_MESSAGETYPE_ANNOUNCE, "ANNOUNCE" },
141 #define SAMETIME_MESSAGEOPTION_ENCRYPT 0x4000
142 #define SAMETIME_MESSAGEOPTION_HAS_ATTRIBS 0x8000
144 static const value_string optionnames[] = {
146 { SAMETIME_MESSAGEOPTION_ENCRYPT, "ENCRYPT" },
147 { SAMETIME_MESSAGEOPTION_HAS_ATTRIBS, "HAS_ATTRIBS" },
152 static const value_string userstatusnames[] = {
153 { 0x0020, "ACTIVE" }, /* "I am available" */
154 { 0x0040, "IDLE" }, /* never seen in the wild, maybe non-pc :-) ? */
155 { 0x0060, "AWAY" }, /* "I am away from my computer now" */
156 { 0x0080, "BUSY" }, /* "Please do not disturb me" */
157 { 0x0008, "MEETING" }, /* "I am in a meeting" */
162 #define SAMETIME_SENDTYPE_AWARE_ADD 0x0068
163 #define SAMETIME_SENDTYPE_OPT_DO_SET 0x00c9
164 #define SAMETIME_SENDTYPE_AWARE_SNAPSHOT 0x01f4
165 #define SAMETIME_SENDTYPE_AWARE_UPDATE 0x01f5
166 #define SAMETIME_SENDTYPE_OPT_GOT_SET 0x0259
168 static const value_string sendtypenames[] = {
169 { SAMETIME_SENDTYPE_AWARE_ADD, "AWARE_ADD" },
170 { 0x0069, "AWARE_REMOVE" },
171 { SAMETIME_SENDTYPE_OPT_DO_SET, "OPT_DO_SET" },
172 { 0x00cb, "OPT_WATCH" },
173 { SAMETIME_SENDTYPE_AWARE_SNAPSHOT, "AWARE_SNAPSHOT" },
174 { SAMETIME_SENDTYPE_AWARE_UPDATE, "AWARE_UPDATE" },
175 { SAMETIME_SENDTYPE_OPT_GOT_SET, "OPT_GOT_SET" },
177 { 0x025d, "OPT_DID_SET" },
182 static const value_string awarenessnames[] = {
185 { 0x0008, "SERVER" },
189 static const value_string codenames[] = {
190 { 0x00000011, "SERVICE_AWARE" },
191 { 0x00000015, "SERVICE_RESOLVE" },
192 { 0x00000018, "SERVICE_STORAGE" },
193 { 0x0000001a, "SERVICE_DIRECTORY" },
195 { 0x80000011, "ERR_USER_SKETCHY" },
196 { 0x80000015, "ERR_TOKEN_INVALID" },
197 { 0x80000018, "ERR_PORT_IN_USE" },
198 { 0x80000022, "ERR_CHANNEL_DESTROYED" },
205 add_text_item(tvbuff_t *tvb, proto_tree *tree, int offset, int hf)
209 /* heuristic rule, string should start w/ valid character(s) */
210 if (! tvb_get_guint8(tvb, offset + 2))
213 length = tvb_get_ntohs(tvb, offset);
215 /* the string length must not exceed the packet length */
216 if (length > tvb_reported_length_remaining(tvb, offset + 2))
219 /* add string length only if preferences is set */
220 if (global_sametime_show_length)
221 proto_tree_add_item(tree, hf_sametime_field_length, tvb, offset, 2, ENC_BIG_ENDIAN);
224 proto_tree_add_item(tree, hf, tvb, offset + 2, length, ENC_ASCII|ENC_NA);
232 dissect_set_user_status(tvbuff_t *tvb, proto_tree *tree, int offset)
236 user_status = tvb_get_ntohs(tvb, offset);
237 proto_item_append_text(tree, ", %s", val_to_str(user_status, userstatusnames, "0x%04x"));
238 proto_tree_add_item(tree, hf_sametime_user_status, tvb, offset, 2, ENC_BIG_ENDIAN);
240 proto_tree_add_item(tree, hf_sametime_time, tvb, offset, 4, ENC_BIG_ENDIAN);
242 add_text_item(tvb, tree, offset, hf_sametime_field_text);
249 dissect_handshake(tvbuff_t *tvb, proto_tree *tree, int offset)
251 proto_tree_add_item(tree, hf_sametime_handshake_major, tvb, offset, 2, ENC_BIG_ENDIAN);
253 proto_tree_add_item(tree, hf_sametime_handshake_minor, tvb, offset, 2, ENC_BIG_ENDIAN);
256 proto_tree_add_item(tree, hf_sametime_handshake_srvrcalc_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
258 proto_tree_add_item(tree, hf_sametime_login_type, tvb, offset, 2, ENC_BIG_ENDIAN);
260 proto_tree_add_item(tree, hf_sametime_handshake_loclcalc_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
263 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
265 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
272 dissect_handshake_ack(tvbuff_t *tvb, proto_tree *tree, int offset)
274 proto_tree_add_item(tree, hf_sametime_handshake_major, tvb, offset, 2, ENC_BIG_ENDIAN);
276 proto_tree_add_item(tree, hf_sametime_handshake_minor, tvb, offset, 2, ENC_BIG_ENDIAN);
278 proto_tree_add_item(tree, hf_sametime_handshake_loclcalc_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
282 add_text_item(tvb, tree, offset, hf_sametime_field_text);
287 dissect_login(tvbuff_t *tvb, proto_tree *tree, int offset)
290 add_text_item(tvb, tree, offset, hf_sametime_field_text);
295 dissect_login_redirect(tvbuff_t *tvb, proto_tree *tree, int offset)
298 add_text_item(tvb, tree, offset, hf_sametime_field_text);
303 dissect_login_ack(tvbuff_t *tvb, proto_tree *tree, int offset)
305 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
306 proto_tree_add_item(tree, hf_sametime_login_type, tvb, offset, 2, ENC_BIG_ENDIAN);
308 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
309 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
311 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
312 proto_tree_add_item(tree, hf_sametime_handshake_loclcalc_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
314 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
316 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
317 add_text_item(tvb, tree, offset, hf_sametime_field_text);
322 dissect_channel_create(tvbuff_t *tvb, proto_tree *tree, int offset)
325 proto_tree_add_item(tree, hf_sametime_channel_id, tvb, offset, 4, ENC_BIG_ENDIAN);
327 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
328 proto_tree_add_item(tree, hf_sametime_channel_service, tvb, offset, 4, ENC_BIG_ENDIAN);
331 add_text_item(tvb, tree, offset, hf_sametime_field_text);
336 dissect_channel_send(tvbuff_t *tvb, proto_tree *tree, int offset)
338 guint16 send_type, awareness;
341 send_type = tvb_get_ntohs(tvb, offset);
342 proto_item_append_text(tree, ", %s", val_to_str(send_type, sendtypenames, "0x%04x"));
343 proto_tree_add_item(tree, hf_sametime_channel_send_type, tvb, offset, 2, ENC_BIG_ENDIAN);
347 case SAMETIME_SENDTYPE_AWARE_ADD:
349 awareness = tvb_get_ntohs(tvb, offset);
350 proto_item_append_text(tree, ", %s", val_to_str(awareness, awarenessnames, "0x%04x"));
351 proto_tree_add_item(tree, hf_sametime_channel_awareness, tvb, offset, 2, ENC_BIG_ENDIAN);
353 add_text_item(tvb, tree, offset, hf_sametime_field_text);
357 case SAMETIME_SENDTYPE_OPT_DO_SET:
359 na = tvb_get_ntohl(tvb, offset);
362 offset += add_text_item(tvb, tree, offset, hf_sametime_location_country);
363 offset += add_text_item(tvb, tree, offset, hf_sametime_location_postalcode);
364 offset += add_text_item(tvb, tree, offset, hf_sametime_location_province);
365 offset += add_text_item(tvb, tree, offset, hf_sametime_location_city);
366 offset += add_text_item(tvb, tree, offset, hf_sametime_location_phone);
368 offset += add_text_item(tvb, tree, offset, hf_sametime_location_name);
369 add_text_item(tvb, tree, offset, hf_sametime_location_timezone);
371 add_text_item(tvb, tree, offset, hf_sametime_field_text);
376 case SAMETIME_SENDTYPE_OPT_GOT_SET:
378 awareness = tvb_get_ntohs(tvb, offset);
379 proto_item_append_text(tree, ", %s", val_to_str(awareness, awarenessnames, "0x%04x"));
380 proto_tree_add_item(tree, hf_sametime_channel_awareness, tvb, offset, 2, ENC_BIG_ENDIAN);
382 while (tvb_reported_length_remaining(tvb, offset) > 2) {
383 int n = add_text_item(tvb, tree, offset, hf_sametime_field_text);
384 offset += (n) ? n : 1;
389 case SAMETIME_SENDTYPE_AWARE_SNAPSHOT:
391 awareness = tvb_get_ntohs(tvb, offset);
392 proto_item_append_text(tree, ", %s", val_to_str(awareness, awarenessnames, "0x%04x"));
393 proto_tree_add_item(tree, hf_sametime_channel_awareness, tvb, offset, 2, ENC_BIG_ENDIAN);
395 add_text_item(tvb, tree, offset, hf_sametime_field_text);
399 case SAMETIME_SENDTYPE_AWARE_UPDATE:
402 awareness = tvb_get_ntohs(tvb, offset);
403 proto_item_append_text(tree, ", %s", val_to_str(awareness, awarenessnames, "0x%04x"));
404 proto_tree_add_item(tree, hf_sametime_channel_awareness, tvb, offset, 2, ENC_BIG_ENDIAN);
406 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
408 if (tvb_get_guint8(tvb, offset)) {
410 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
411 dissect_set_user_status(tvb, tree, offset);
418 add_text_item(tvb, tree, offset, hf_sametime_field_text);
424 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
426 add_text_item(tvb, tree, offset, hf_sametime_field_text);
430 case 0x0005: /* XML */
431 if (26 <= tvb_reported_length_remaining(tvb, offset + 2)) {
433 add_text_item(tvb, tree, offset, hf_sametime_field_text);
440 if (4 <= tvb_reported_length_remaining(tvb, offset + 2)) {
441 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
442 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
444 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
445 add_text_item(tvb, tree, offset, hf_sametime_field_text);
452 add_text_item(tvb, tree, offset, hf_sametime_field_text);
465 dissect_channel_accept(tvbuff_t *tvb, proto_tree *tree, int offset)
468 if (tvb_reported_length_remaining(tvb, offset + 2)) {
469 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
470 if (tvb_get_guint8(tvb, offset)) {
472 offset += add_text_item(tvb, tree, offset, hf_sametime_field_text);
473 dissect_set_user_status(tvb, tree, offset);
480 dissect_sense_service(tvbuff_t *tvb, proto_tree *tree, int offset)
484 code = tvb_get_ntohl(tvb, offset);
485 proto_item_append_text(tree, ", %s", val_to_str(code, codenames, "0x%04x"));
486 proto_tree_add_item(tree, hf_sametime_code, tvb, offset, 4, ENC_BIG_ENDIAN);
491 here we really dissect the message(s)
494 dissect_sametime_content(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
496 proto_tree *sametime_tree;
498 static SametimeTap *sinfo;
500 int packet_length, offset = 0;
502 /* we expect either 1 heartbeat byte (0x80) or a sametime message */
503 packet_length = tvb_reported_length_remaining(tvb, offset);
504 if (packet_length == 1) {
505 message_type = tvb_get_guint8(tvb, 0);
507 } else if (packet_length < 12) {
511 message_type = tvb_get_ntohs(tvb, 4);
514 /* add message type */
515 col_append_str(pinfo->cinfo, COL_INFO, val_to_str(message_type, messagetypenames, "0x%04x"));
516 col_append_str(pinfo->cinfo, COL_INFO, " ");
518 /* message type statistic */
519 sinfo = wmem_new(wmem_packet_scope(), struct SametimeTap);
520 sinfo->message_type = message_type;
521 sinfo->send_type = -1;
522 sinfo->user_status = -1;
524 /* packet detail tree */
525 ti = proto_tree_add_item(tree, proto_sametime, tvb, offset, -1, ENC_NA);
526 sametime_tree = proto_item_add_subtree(ti, ett_sametime);
527 proto_item_append_text(sametime_tree, ", %s", val_to_str(message_type, messagetypenames, "0x%04x"));
529 /* dissect message */
530 if (message_type == SAMETIME_MESSAGETYPE_HEARTBEAT) {
531 proto_tree_add_item(sametime_tree, hf_sametime_heartbeat, tvb, offset, 1, ENC_BIG_ENDIAN);
533 } else if (message_type != -1) {
534 proto_tree *options_tree;
537 /* first 4 bytes gives the length of the sametime message */
538 if (global_sametime_show_length) {
539 proto_tree_add_item(sametime_tree, hf_sametime_message_length, tvb, offset, 4, ENC_BIG_ENDIAN);
543 /* next 2 bytes gives the message type */
544 proto_tree_add_item(sametime_tree, hf_sametime_message_type, tvb, offset, 2, ENC_BIG_ENDIAN);
547 /* next 2 bytes are the message options */
548 op = proto_tree_add_item(sametime_tree, hf_sametime_message_options, tvb, offset, 2, ENC_BIG_ENDIAN);
549 options_tree = proto_item_add_subtree(op, ett_sametime_options);
550 proto_tree_add_item(options_tree, hf_sametime_message_options_attribute, tvb, offset, 2, ENC_BIG_ENDIAN);
551 proto_tree_add_item(options_tree, hf_sametime_message_options_encrypted, tvb, offset, 2, ENC_BIG_ENDIAN);
554 /* next 4 bytes contains the channel id */
555 proto_tree_add_item(sametime_tree, hf_sametime_message_channel, tvb, offset, 4, ENC_BIG_ENDIAN);
558 switch (message_type)
560 case SAMETIME_MESSAGETYPE_HANDSHAKE:
561 dissect_handshake(tvb, sametime_tree, offset);
564 case SAMETIME_MESSAGETYPE_HANDSHAKE_ACK:
565 dissect_handshake_ack(tvb, sametime_tree, offset);
568 case SAMETIME_MESSAGETYPE_HANDSHAKE_SYN:
571 case SAMETIME_MESSAGETYPE_LOGIN:
572 dissect_login(tvb, sametime_tree, offset);
575 case SAMETIME_MESSAGETYPE_LOGIN_REDIRECT:
576 dissect_login_redirect(tvb, sametime_tree, offset);
579 case SAMETIME_MESSAGETYPE_LOGIN_ACK:
580 dissect_login_ack(tvb, sametime_tree, offset);
583 case SAMETIME_MESSAGETYPE_CHANNEL_CREATE:
584 dissect_channel_create(tvb, sametime_tree, offset);
587 case SAMETIME_MESSAGETYPE_CHANNEL_SEND:
588 sinfo->send_type = dissect_channel_send(tvb, sametime_tree, offset);
591 case SAMETIME_MESSAGETYPE_CHANNEL_ACCEPT:
592 dissect_channel_accept(tvb, sametime_tree, offset);
595 case SAMETIME_MESSAGETYPE_SET_USER_STATUS:
596 sinfo->user_status = dissect_set_user_status(tvb, sametime_tree, offset);
599 case SAMETIME_MESSAGETYPE_SENSE_SERVICE:
600 dissect_sense_service(tvb, sametime_tree, offset);
604 /* do not fill the statistics with useless data from encrypted packages */
605 sinfo->message_type = -1;
610 tap_queue_packet(sametime_tap, pinfo, sinfo);
611 return tvb_captured_length(tvb);
618 static tap_packet_status
619 sametime_stats_tree_packet(stats_tree* st, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* p)
621 const struct SametimeTap *pi = (const struct SametimeTap *)p;
623 tick_stat_node(st, st_str_packet, 0, FALSE);
624 if (pi->message_type != -1)
625 stats_tree_tick_pivot(st, st_node_message_type, val_to_str(pi->message_type, messagetypenames, "Unknown (0x%04x)"));
627 if (pi->send_type != -1)
628 stats_tree_tick_pivot(st, st_node_send_type, val_to_str(pi->send_type, sendtypenames, "Unknown (0x%04x)"));
630 if (pi->user_status != -1)
631 stats_tree_tick_pivot(st, st_node_user_status, val_to_str(pi->user_status, userstatusnames, "Unknown (0x%04x)"));
633 return TAP_PACKET_REDRAW;
641 sametime_stats_tree_init(stats_tree* st)
643 st_node_packet = stats_tree_create_node(st, st_str_packet, 0, STAT_DT_INT, TRUE);
644 st_node_message_type = stats_tree_create_pivot(st, st_str_message_type, st_node_packet);
645 st_node_send_type = stats_tree_create_pivot(st, st_str_send_type, st_node_packet);
646 st_node_user_status = stats_tree_create_pivot(st, st_str_user_status, st_node_packet);
651 length of the sametime message
654 get_sametime_message_len(packet_info *pinfo _U_, tvbuff_t *tvb,
655 int offset, void *data _U_)
657 /* XXX: Actually: the length of the tvb will always be 4 or greater at this point */
658 /* because tcp_dissect_pdus was called with 4 as a required "fixed length". */
659 /* But newer variants of this protocol with a full encrypted network stream */
660 /* may require a more sophisticated dissection logic here */
661 guint32 N = tvb_captured_length_remaining(tvb, offset);
663 return (N < 4) ? N : tvb_get_ntohl(tvb, offset) + 4;
671 dissect_sametime(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
673 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SAMETIME");
674 col_clear(pinfo->cinfo,COL_INFO);
676 tcp_dissect_pdus(tvb, pinfo, tree, global_sametime_reassemble_packets, 4,
677 get_sametime_message_len, dissect_sametime_content, data);
678 return tvb_captured_length(tvb);
683 proto_register_sametime(void)
685 static hf_register_info hf[] = {
686 /*tcp payload is one byte : SAMETIME_MESSAGETYPE_HEARTBEAT*/
687 { &hf_sametime_heartbeat,
688 { "heartbeat", "sametime.heartbeat",
694 /*sametime message header*/
695 { &hf_sametime_message_length,
696 { "msg length", "sametime.message_length",
701 { &hf_sametime_message_type,
702 { "msg type", "sametime.message_type",
704 VALS(messagetypenames), 0x0,
707 { &hf_sametime_message_options,
708 { "msg options", "sametime.message_options",
710 VALS(optionnames), 0x0,
713 { &hf_sametime_message_options_encrypted,
714 { "ENCRYPT", "sametime.message_options.encrypted",
716 NULL, SAMETIME_MESSAGEOPTION_ENCRYPT,
719 { &hf_sametime_message_options_attribute,
720 { "HAS_ATTRIBS", "sametime.message_options.attribute",
722 NULL, SAMETIME_MESSAGEOPTION_HAS_ATTRIBS,
725 { &hf_sametime_message_channel,
726 { "msg channel", "sametime.message_channel",
732 /*common fields within various message types*/
733 { &hf_sametime_field_length,
734 { "length", "sametime.field_length",
739 { &hf_sametime_field_text,
740 { "text", "sametime.field_text",
741 FT_STRING, STR_ASCII,
746 { "code", "sametime.code",
748 VALS(codenames), 0x0,
751 { &hf_sametime_login_type,
752 { "login type", "sametime.login_type",
758 { "time", "sametime.time",
765 { &hf_sametime_handshake_major,
766 { "major", "sametime.handshake.major",
771 { &hf_sametime_handshake_minor,
772 { "minor", "sametime.handshake.minor",
777 { &hf_sametime_handshake_srvrcalc_addr,
778 { "srvr", "sametime.handshake.srvrcalc_addr",
783 { &hf_sametime_handshake_loclcalc_addr,
784 { "locl", "sametime.handshake.loclcalc_addr",
791 { &hf_sametime_channel_service,
792 { "service id", "sametime.channel.service",
797 { &hf_sametime_channel_id,
798 { "channel id", "sametime.channel.id",
803 { &hf_sametime_channel_send_type,
804 { "send type", "sametime.channel.send_type",
806 VALS(sendtypenames), 0,
809 { &hf_sametime_channel_awareness,
810 { "awareness", "sametime.channel.awareness",
812 VALS(awarenessnames), 0x0,
817 { &hf_sametime_user_status,
818 { "user status", "sametime.user_status_type",
820 VALS(userstatusnames), 0x0,
825 { &hf_sametime_location_name,
826 { "name", "sametime.location.name",
827 FT_STRING, STR_ASCII,
831 { &hf_sametime_location_city,
832 { "city", "sametime.location.city",
833 FT_STRING, STR_ASCII,
837 { &hf_sametime_location_province,
838 { "province", "sametime.location.province",
839 FT_STRING, STR_ASCII,
843 { &hf_sametime_location_postalcode,
844 { "postal code", "sametime.location.postalcode",
845 FT_STRING, STR_ASCII,
849 { &hf_sametime_location_country,
850 { "country", "sametime.location.country",
851 FT_STRING, STR_ASCII,
855 { &hf_sametime_location_phone,
856 { "phone", "sametime.location.phone",
857 FT_STRING, STR_ASCII,
861 { &hf_sametime_location_timezone,
862 { "time zone", "sametime.location.timezone",
863 FT_STRING, STR_ASCII,
869 static gint *ett[] = {
871 &ett_sametime_options
874 module_t *sametime_module;
876 proto_sametime = proto_register_protocol ("Sametime Protocol", "SAMETIME", "sametime");
877 proto_register_field_array(proto_sametime, hf, array_length(hf));
878 proto_register_subtree_array(ett, array_length(ett));
880 sametime_tap = register_tap("sametime");
882 /* Preference setting */
883 sametime_module = prefs_register_protocol(proto_sametime, NULL);
884 prefs_register_bool_preference(sametime_module, "show_length",
886 "Show length of text field",
887 &global_sametime_show_length);
888 prefs_register_bool_preference(sametime_module, "reassemble",
889 "Reassemble","reassemble packets",
890 &global_sametime_reassemble_packets);
898 proto_reg_handoff_sametime(void)
900 sametime_handle = create_dissector_handle(dissect_sametime, proto_sametime);
901 dissector_add_uint_with_preference("tcp.port", DEFAULT_SAMETIME_PORT, sametime_handle);
903 stats_tree_register("sametime", "sametime", "Sametime/Messages", 0,
904 sametime_stats_tree_packet,
905 sametime_stats_tree_init, NULL );
911 * Editor modelines - https://www.wireshark.org/tools/modelines.html
916 * indent-tabs-mode: nil
919 * vi: set shiftwidth=4 tabstop=8 expandtab:
920 * :indentSize=4:tabSize=8:noTabs=true: