3 * BLIP protocol for Couchbase Lite <-> Sync Gateway 2.0+ Replication
5 * Spec: https://github.com/couchbaselabs/BLIP-Cpp/blob/master/docs/BLIP%20Protocol.md
7 * Copyright 2018, Traun Leyden <traun@couchbase.com>
8 * Copyright 2018, Jim Borden <jim.borden@couchbase.com>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include <epan/conversation.h>
21 #include <epan/prefs.h>
22 #include <epan/expert.h>
23 #include <epan/strutil.h>
24 #include "proto_data.h"
26 #if defined(HAVE_ZLIB) && !defined(HAVE_ZLIBNG)
27 #define ZLIB_PREFIX(x) x
29 typedef z_stream zlib_stream
;
30 #endif /* HAVE_ZLIB */
33 #define ZLIB_PREFIX(x) zng_ ## x
35 typedef zng_stream zlib_stream
;
36 #endif /* HAVE_ZLIBNG */
37 void proto_reg_handoff_blip(void);
38 void proto_register_blip(void);
40 #define BLIP_BODY_CHECKSUM_SIZE 4
42 // blip_conversation_entry_t is metadata that the blip dissector associates w/ each wireshark conversation
45 // Keep track of the largest frame number seen. This is useful for determining whether
46 // this is the first frame in a request message or not.
48 // key: msgtype:srcport:destport:messagenumber -> value: frame number for the _first_ frame in this request message
49 // Example: "MSG:23243:4984:56" -> 12
50 // which means: "the first frame for blip message number 56, originating from source port 23243,
51 // ... and going to port 4984 for message type = MSG occurred in wireshark packet #12"
52 wmem_map_t
*blip_requests
;
54 #if defined(HAVE_ZLIB) || defined(HAVE_ZLIBNG)
55 // The streams used to decode a particular connection. These are per direction and per connection.
56 wmem_map_t
*decompress_streams
;
58 } blip_conversation_entry_t
;
60 #if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
70 decompress_error_t domain
;
74 } decompress_result_t
;
77 // File level variables
78 static dissector_handle_t blip_handle
;
79 static int proto_blip
;
80 static int hf_blip_message_number
;
81 static int hf_blip_frame_flags
;
82 static int hf_blip_properties_length
;
83 static int hf_blip_properties
;
84 static int hf_blip_message_body
;
85 static int hf_blip_ack_size
;
86 static int hf_blip_checksum
;
90 static expert_field ei_blip_decompress_buffer_error
;
96 // In ascending order so that a binary search will be used as per the
98 static const value_string flag_combos
[] = {
100 { 0x08, "Compressed" },
102 { 0x10|0x08, "Compressed|Urgent" },
104 { 0x20|0x08, "Compressed|NoReply" },
105 { 0x20|0x10, "Urgent|NoReply" },
106 { 0x20|0x10|0x08, "Compressed|Urgent|NoReply" },
107 { 0x40, "MoreComing" },
108 { 0x40|0x08, "Compressed|MoreComing" },
109 { 0x40|0x10, "Urgent|MoreComing" },
110 { 0x40|0x10|0x08, "Compressed|Urgent|MoreComing" },
111 { 0x40|0x20, "NoReply|MoreComing" },
112 { 0x40|0x20|0x08, "Compressed|NoReply|MoreComing" },
113 { 0x40|0x20|0x10, "Urgent|NoReply|MoreComing" },
114 { 0x40|0x20|0x10|0x08, "Compressed|Urgent|NoReply|MoreComing" },
118 static value_string_ext flag_combos_ext
= VALUE_STRING_EXT_INIT(flag_combos
);
120 static const val64_string msg_types
[] = {
124 { 0x04ll
, "ACKMSG" },
125 { 0x05ll
, "ACKRPY" },
130 #if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
131 static unsigned max_uncompressed_size
= 64; // Max uncompressed body size in Kb
140 get_message_type(uint64_t value_frame_flags
)
142 // Mask out the least significant bits: 0000 0111
143 uint64_t type_mask_val
= (0x07ll
& value_frame_flags
);
144 return val64_to_str_const(type_mask_val
, msg_types
, "???");
148 is_ack_message(uint64_t value_frame_flags
) {
149 // Note, even though this is a 64-bit int, only the least significant byte has meaningful information,
150 // since frame flags all fit into one byte at the time this code was written.
152 // Mask out the least significant bits: 0000 0111
153 uint64_t type_mask_val
= (0x07ll
& value_frame_flags
);
156 if (type_mask_val
== 0x04ll
) {
161 if (type_mask_val
== 0x05ll
) {
169 is_compressed(uint64_t value_frame_flags
)
171 // Note, even though this is a 64-bit int, only the least significant byte has meaningful information,
172 // since frame flags all fit into one byte at the time this code was written.
174 if ((0x08ll
& value_frame_flags
) == 0x08ll
) {
183 message_hash_key_convo(packet_info
*pinfo
,
184 uint64_t value_frame_flags
,
185 uint64_t value_message_num
)
187 // Derive the hash key to use
188 // msgtype:srcport:destport:messagenum
190 const char *msg_type
= get_message_type(value_frame_flags
);
191 char *hash_key
= wmem_strdup_printf(pinfo
->pool
, "%s:%u:%u:%" PRIu64
,
192 msg_type
, pinfo
->srcport
, pinfo
->destport
, value_message_num
);
197 // Finds out whether this is the first blip frame in the blip message (which can consist of a series of frames).
198 // If it is, updates the conversation_entry_ptr->blip_requests hash to record the pinfo->num (wireshark packet number)
200 is_first_frame_in_msg(blip_conversation_entry_t
*conversation_entry_ptr
, packet_info
*pinfo
,
201 uint64_t value_frame_flags
, uint64_t value_message_num
) {
203 bool first_frame_in_msg
= true;
205 // Temporary pool for the lookup hash_key. Will get duplicated on the file_scope() pool if needed to be
206 // stored in the hashtable.
207 char *hash_key
= message_hash_key_convo(pinfo
, value_frame_flags
, value_message_num
);
208 unsigned* first_frame_number_for_msg
= (unsigned*)wmem_map_lookup(conversation_entry_ptr
->blip_requests
, (void *) hash_key
);
210 if (first_frame_number_for_msg
!= NULL
) {
211 if (GPOINTER_TO_UINT(first_frame_number_for_msg
) != pinfo
->num
) {
212 first_frame_in_msg
= false;
215 // If storing the key in the hashmap, re-allocate it with the file_scope() allocator
216 char *hash_key_copy
= wmem_strdup(wmem_file_scope(), hash_key
);
218 wmem_map_insert(conversation_entry_ptr
->blip_requests
, (void *) hash_key_copy
, GUINT_TO_POINTER(pinfo
->num
));
221 return first_frame_in_msg
;
225 handle_ack_message(tvbuff_t
*tvb
, _U_ packet_info
*pinfo
, proto_tree
*blip_tree
, int offset
, _U_
uint64_t value_frame_flags
)
227 // This gets the number of ack bytes received as a var int in order to find out how much to bump
228 // the offset for the next proto_tree item
229 uint64_t value_ack_size
;
230 unsigned varint_ack_size_length
= tvb_get_varint(
235 ENC_VARINT_PROTOBUF
);
237 proto_tree_add_item(blip_tree
, hf_blip_ack_size
, tvb
, offset
, varint_ack_size_length
, ENC_VARINT_PROTOBUF
);
239 return tvb_captured_length(tvb
);
242 static blip_conversation_entry_t
*
243 get_blip_conversation(packet_info
* pinfo
)
245 // Create a new conversation if needed and associate the blip_conversation_entry_t with it
246 // Adapted from sample code in doc/README.dissector
247 conversation_t
*conversation
;
248 conversation
= find_or_create_conversation(pinfo
);
249 blip_conversation_entry_t
*conversation_entry_ptr
= (blip_conversation_entry_t
*)conversation_get_proto_data(conversation
, proto_blip
);
250 if (conversation_entry_ptr
== NULL
) {
252 // create a new blip_conversation_entry_t
253 conversation_entry_ptr
= wmem_new(wmem_file_scope(), blip_conversation_entry_t
);
255 // create a new hash map and save a reference in blip_conversation_entry_t
256 conversation_entry_ptr
->blip_requests
= wmem_map_new(wmem_file_scope(), g_str_hash
, g_str_equal
);
257 #if defined(HAVE_ZLIB) || defined(HAVE_ZLIBNG)
258 conversation_entry_ptr
->decompress_streams
= wmem_map_new(wmem_file_scope(), g_direct_hash
, g_direct_equal
);
260 conversation_add_proto_data(conversation
, proto_blip
, conversation_entry_ptr
);
263 return conversation_entry_ptr
;
266 #if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
268 z_stream_destroy_cb(wmem_allocator_t
*allocator _U_
, wmem_cb_event_t event _U_
, void *user_data
)
270 zlib_stream
*decompress_stream
= (zlib_stream
*)user_data
;
271 ZLIB_PREFIX(inflateEnd
)(decompress_stream
);
276 get_decompress_stream(packet_info
* pinfo
)
278 const blip_conversation_entry_t
* blip_convo
= get_blip_conversation(pinfo
);
280 // Store compression state per srcport/destport.
281 uint32_t hash_key
= (pinfo
->srcport
<< 16) | pinfo
->destport
;
282 zlib_stream
* decompress_stream
= (zlib_stream
*)wmem_map_lookup(blip_convo
->decompress_streams
, GUINT_TO_POINTER(hash_key
));
283 if(decompress_stream
) {
284 return decompress_stream
;
287 decompress_stream
= wmem_new0(wmem_file_scope(), zlib_stream
);
288 wmem_map_insert(blip_convo
->decompress_streams
, GUINT_TO_POINTER(hash_key
), decompress_stream
);
289 wmem_register_callback(wmem_file_scope(), z_stream_destroy_cb
, decompress_stream
);
291 return decompress_stream
;
295 decompress(packet_info
* pinfo
, proto_tree
* tree
, tvbuff_t
* tvb
, int offset
, int length
)
297 if(PINFO_FD_VISITED(pinfo
)) {
298 const decompress_result_t
* saved_data
= (decompress_result_t
*)p_get_proto_data(wmem_file_scope(), pinfo
, proto_blip
, 0);
300 proto_tree_add_string(tree
, hf_blip_message_body
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), "<Error decompressing data>");
304 if(saved_data
->domain
) {
305 proto_item
* field
= proto_tree_add_string(tree
, hf_blip_message_body
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), "<Error decompressing data>");
306 if(saved_data
->domain
== zlib_error
) {
307 expert_add_info_format(pinfo
, field
, &ei_blip_decompress_buffer_error
, "Unable to decompress message, got zlib error %d", saved_data
->code
);
309 expert_add_info_format(pinfo
, field
, &ei_blip_decompress_buffer_error
, "Unable to decompress message, buffer too small (%u Kb). Please adjust in settings.", max_uncompressed_size
);
314 tvbuff_t
* decompressedChild
= tvb_new_child_real_data(tvb
, (uint8_t *)saved_data
->buf
,
315 (int)saved_data
->size
, (int)saved_data
->size
);
316 add_new_data_source(pinfo
, decompressedChild
, "Decompressed Payload");
317 return decompressedChild
;
321 static bool size_overflow
= false;
322 const uint8_t* buf
= tvb_get_ptr(tvb
, offset
, length
);
323 zlib_stream
* decompress_stream
= get_decompress_stream(pinfo
);
324 static Byte trailer
[4] = { 0x00, 0x00, 0xff, 0xff };
325 if(!decompress_stream
->next_out
) {
326 decompress_stream
->zalloc
= 0;
327 decompress_stream
->zfree
= 0;
328 decompress_stream
->opaque
= 0;
329 int err
= ZLIB_PREFIX(inflateInit2
)(decompress_stream
, -MAX_WBITS
);
331 decompress_stream
->next_out
= 0;
332 REPORT_DISSECTOR_BUG("Unable to create INFLATE context to decompress messages");
337 // Create a temporary buffer of the maximum size, which will get cleaned up later
338 // when the packet scope is freed
339 uInt buffer_size
= max_uncompressed_size
* 1024;
340 Bytef
* decompress_buffer
= (Bytef
*)wmem_alloc(pinfo
->pool
, buffer_size
);
341 decompress_stream
->next_in
= (Bytef
*)buf
;
342 decompress_stream
->avail_in
= length
;
343 decompress_stream
->next_out
= decompress_buffer
;
344 decompress_stream
->avail_out
= buffer_size
;
345 size_t start
= decompress_stream
->total_out
;
346 int err
= ZLIB_PREFIX(inflate
)(decompress_stream
, Z_NO_FLUSH
);
348 proto_item
* field
= proto_tree_add_string(tree
, hf_blip_message_body
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), "<Error decompressing data>");
349 decompress_result_t
* data_to_save
= wmem_new0(wmem_file_scope(), decompress_result_t
);
350 if(size_overflow
&& err
== Z_DATA_ERROR
) {
351 data_to_save
->domain
= overflow_error
;
352 expert_add_info_format(pinfo
, field
, &ei_blip_decompress_buffer_error
, "Unable to decompress message, buffer too small (%u Kb). Please adjust in settings.", max_uncompressed_size
);
354 data_to_save
->domain
= zlib_error
;
355 data_to_save
->code
= err
;
356 expert_add_info_format(pinfo
, field
, &ei_blip_decompress_buffer_error
, "Unable to decompress message, got zlib error %d", err
);
359 p_add_proto_data(wmem_file_scope(), pinfo
, proto_blip
, 0, data_to_save
);
363 decompress_stream
->next_in
= trailer
;
364 decompress_stream
->avail_in
= 4;
365 err
= ZLIB_PREFIX(inflate
)(decompress_stream
, Z_SYNC_FLUSH
);
367 proto_item
* field
= proto_tree_add_string(tree
, hf_blip_message_body
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), "<Error decompressing data>");
368 decompress_result_t
* data_to_save
= wmem_new0(wmem_file_scope(), decompress_result_t
);
369 if(err
== Z_BUF_ERROR
) {
370 data_to_save
->domain
= overflow_error
;
371 size_overflow
= true;
372 expert_add_info_format(pinfo
, field
, &ei_blip_decompress_buffer_error
, "Unable to decompress message, buffer too small (%u Kb). Please adjust in settings.", max_uncompressed_size
);
374 data_to_save
->domain
= zlib_error
;
375 data_to_save
->code
= err
;
376 expert_add_info_format(pinfo
, field
, &ei_blip_decompress_buffer_error
, "Unable to decompress message, got zlib error %d", err
);
379 p_add_proto_data(wmem_file_scope(), pinfo
, proto_blip
, 0, data_to_save
);
383 // Shrink the buffer so that there is not wasted space on the end of it since
384 // it will be long lived in the file scope
385 size_t bodyLength
= decompress_stream
->total_out
- start
;
386 Bytef
* shortened_buffer
= (Bytef
*)wmem_memdup(wmem_file_scope(), decompress_buffer
, bodyLength
);
388 tvbuff_t
* decompressedChild
= tvb_new_child_real_data(tvb
, shortened_buffer
, (unsigned)bodyLength
, (int)bodyLength
);
389 add_new_data_source(pinfo
, decompressedChild
, "Decompressed Payload");
390 decompress_result_t
* data_to_save
= wmem_new0(wmem_file_scope(), decompress_result_t
);
391 data_to_save
->size
= (size_t)bodyLength
;
392 data_to_save
->buf
= shortened_buffer
;
393 p_add_proto_data(wmem_file_scope(), pinfo
, proto_blip
, 0, data_to_save
);
395 return decompressedChild
;
397 #endif /* HAVE_ZLIB */
400 dissect_blip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, _U_
void *data
)
403 proto_tree
*blip_tree
;
406 /* Set the protocol column to say BLIP */
407 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "BLIP");
408 /* Clear out stuff in the info column */
409 col_clear(pinfo
->cinfo
,COL_INFO
);
411 // ------------------------------------- Setup BLIP tree -----------------------------------------------------------
414 /* Add a subtree to dissection. See WSDG 9.2.2. Dissecting the details of the protocol */
415 proto_item
*blip_item
= proto_tree_add_item(tree
, proto_blip
, tvb
, offset
, -1, ENC_NA
);
417 blip_tree
= proto_item_add_subtree(blip_item
, ett_blip
);
420 // ------------------------ BLIP Frame Header: Message Number VarInt -----------------------------------------------
422 // This gets the message number as a var int in order to find out how much to bump
423 // the offset for the next proto_tree item
424 uint64_t value_message_num
;
425 unsigned varint_message_num_length
= tvb_get_varint(
430 ENC_VARINT_PROTOBUF
);
432 proto_tree_add_item(blip_tree
, hf_blip_message_number
, tvb
, offset
, varint_message_num_length
, ENC_VARINT_PROTOBUF
);
434 offset
+= varint_message_num_length
;
436 // ------------------------ BLIP Frame Header: Frame Flags VarInt --------------------------------------------------
438 // This gets the message number as a var int in order to find out how much to bump
439 // the offset for the next proto_tree item
440 uint64_t value_frame_flags
;
441 unsigned varint_frame_flags_length
= tvb_get_varint(
446 ENC_VARINT_PROTOBUF
);
448 uint64_t masked
= value_frame_flags
& ~0x07;
449 proto_tree_add_uint(blip_tree
, hf_blip_frame_flags
, tvb
, offset
, varint_frame_flags_length
, (uint8_t)masked
);
451 offset
+= varint_frame_flags_length
;
453 const char* msg_type
= get_message_type(value_frame_flags
);
454 char* msg_num
= wmem_strdup_printf(pinfo
->pool
, "#%" PRIu64
, value_message_num
);
455 char* col_info
= wmem_strconcat(pinfo
->pool
, msg_type
, msg_num
, NULL
);
456 col_add_str(pinfo
->cinfo
, COL_INFO
, col_info
);
458 // If it's an ACK message, handle that separately, since there are no properties etc.
459 if (is_ack_message(value_frame_flags
) == true) {
460 return handle_ack_message(tvb
, pinfo
, blip_tree
, offset
, value_frame_flags
);
464 // ------------------------------------- Conversation Tracking -----------------------------------------------------
466 blip_conversation_entry_t
*conversation_entry_ptr
= get_blip_conversation(pinfo
);
468 // Is this the first frame in a blip message with multiple frames?
469 bool first_frame_in_msg
= is_first_frame_in_msg(
470 conversation_entry_ptr
,
476 tvbuff_t
* tvb_to_use
= tvb
;
477 bool compressed
= is_compressed(value_frame_flags
);
480 #if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
481 tvb_to_use
= decompress(pinfo
, blip_tree
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
) - BLIP_BODY_CHECKSUM_SIZE
);
483 return tvb_reported_length(tvb
);
486 #else /* ! HAVE_ZLIB */
487 proto_tree_add_string(tree
, hf_blip_message_body
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), "<decompression support is not available>");
488 return tvb_reported_length(tvb
);
489 #endif /* ! HAVE_ZLIB */
492 // Is this the first frame in a message?
493 if (first_frame_in_msg
== true) {
495 // ------------------------ BLIP Frame Header: Properties Length VarInt --------------------------------------------------
497 // WARNING: this only works because this code assumes that ALL MESSAGES FIT INTO ONE FRAME, which is absolutely not true.
498 // In other words, as soon as there is a message that spans two frames, this code will break.
500 uint64_t value_properties_length
;
501 unsigned value_properties_length_varint_length
= tvb_get_varint(
505 &value_properties_length
,
506 ENC_VARINT_PROTOBUF
);
508 proto_tree_add_item(blip_tree
, hf_blip_properties_length
, tvb_to_use
, offset
, value_properties_length_varint_length
, ENC_VARINT_PROTOBUF
);
510 offset
+= value_properties_length_varint_length
;
512 // ------------------------ BLIP Frame: Properties --------------------------------------------------
514 // WARNING: this only works because this code assumes that ALL MESSAGES FIT INTO ONE FRAME, which is absolutely not true.
515 // In other words, as soon as there is a message that spans two frames, this code will break.
517 // At this point, the length of the properties is known and is stored in value_properties_length.
518 // This reads the entire properties out of the tvb and into a buffer (buf).
519 uint8_t* buf
= tvb_get_string_enc(pinfo
->pool
, tvb_to_use
, offset
, (int) value_properties_length
, ENC_UTF_8
);
521 // "Profile\0subChanges\0continuous\0true\0foo\0bar" -> "Profile:subChanges:continuous:true:foo:bar"
522 // Iterate over buf and change all the \0 null characters to ':', since otherwise trying to set a header
523 // field to this buffer via proto_tree_add_item() will end up only printing it up to the first null character,
524 // for example "Profile", even though there are many more properties that follow.
525 for (int i
= 0; i
< (int) value_properties_length
; i
++) {
526 if (i
< (int) (value_properties_length
- 1)) {
527 if (buf
[i
] == '\0') { // TODO: I don't even know if this is actually a safe assumption in a UTF-8 encoded string
533 if(value_properties_length
> 0) {
534 proto_tree_add_string(blip_tree
, hf_blip_properties
, tvb_to_use
, offset
, (int)value_properties_length
, (const char *)buf
);
537 // Bump the offset by the length of the properties
538 offset
+= (int)value_properties_length
;
541 // ------------------------ BLIP Frame: Message Body --------------------------------------------------
543 // WS_DLL_PUBLIC int tvb_reported_length_remaining(const tvbuff_t *tvb, const int offset);
544 int reported_length_remaining
= tvb_reported_length_remaining(tvb_to_use
, offset
);
546 // Don't read in the trailing checksum at the end
547 if (!compressed
&& reported_length_remaining
>= BLIP_BODY_CHECKSUM_SIZE
) {
548 reported_length_remaining
-= BLIP_BODY_CHECKSUM_SIZE
;
551 if(reported_length_remaining
> 0) {
552 proto_tree_add_item(blip_tree
, hf_blip_message_body
, tvb_to_use
, offset
, reported_length_remaining
, ENC_UTF_8
);
555 proto_tree_add_item(blip_tree
, hf_blip_checksum
, tvb
, tvb_reported_length(tvb
) - BLIP_BODY_CHECKSUM_SIZE
, BLIP_BODY_CHECKSUM_SIZE
, ENC_BIG_ENDIAN
);
557 // -------------------------------------------- Etc ----------------------------------------------------------------
559 return tvb_captured_length(tvb
);
563 proto_register_blip(void)
565 static hf_register_info hf
[] = {
566 { &hf_blip_message_number
,
567 { "Message Number", "blip.messagenum", FT_UINT64
, BASE_DEC
,
568 NULL
, 0x0, NULL
, HFILL
}
570 { &hf_blip_frame_flags
,
571 { "Frame Flags", "blip.frameflags", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
,
572 &flag_combos_ext
, 0x0, NULL
, HFILL
}
574 { &hf_blip_properties_length
,
575 { "Properties Length", "blip.propslength", FT_UINT64
, BASE_DEC
,
576 NULL
, 0x0, NULL
, HFILL
}
578 { &hf_blip_properties
,
579 { "Properties", "blip.props", FT_STRING
, BASE_NONE
,
580 NULL
, 0x0, NULL
, HFILL
}
582 { &hf_blip_message_body
,
583 { "Message Body", "blip.messagebody", FT_STRING
, BASE_NONE
,
584 NULL
, 0x0, NULL
, HFILL
}
587 { "ACK num bytes", "blip.numackbytes", FT_UINT64
, BASE_DEC
,
588 NULL
, 0x0, NULL
, HFILL
}
591 { "Checksum", "blip.checksum", FT_UINT32
, BASE_DEC
,
592 NULL
, 0x0, NULL
, HFILL
}
596 /* Setup protocol subtree array */
597 static int *ett
[] = {
602 static ei_register_info ei
[] = {
603 { &ei_blip_decompress_buffer_error
, { "blip.decompress_buffer_error", PI_UNDECODED
, PI_WARN
, "Decompression error", EXPFILL
}}
606 proto_blip
= proto_register_protocol("BLIP Couchbase Mobile", "BLIP", "blip");
607 expert_module_t
* expert_blip
= expert_register_protocol(proto_blip
);
609 proto_register_field_array(proto_blip
, hf
, array_length(hf
));
610 proto_register_subtree_array(ett
, array_length(ett
));
611 expert_register_field_array(expert_blip
, ei
, array_length(ei
));
613 blip_handle
= register_dissector("blip", dissect_blip
, proto_blip
);
616 module_t
*blip_module
= prefs_register_protocol(proto_blip
, NULL
);
617 prefs_register_uint_preference(blip_module
, "max_uncompressed_size",
618 "Maximum uncompressed message size (Kb)",
619 "The maximum size of the buffer for uncompressed messages. "
620 "If a message is larger than this, then the packet containing "
621 "the message, as well as subsequent packets, will fail to "
622 "decompress", 10, &max_uncompressed_size
);
627 proto_reg_handoff_blip(void)
630 // Register the blip dissector as a subprotocol dissector of "ws.protocol",
631 // matching any packets with a Web-Sec-Protocol header of "BLIP_3+CBMobile_2"
632 // "BLIP_3+CBMobile_3", or "BLIP_3+CBMobile_4"
634 // See https://github.com/couchbase/sync_gateway/issues/3356#issuecomment-370958321 for
635 // more notes on how the websocket dissector routes packets down to subprotocol handlers.
637 dissector_add_string("ws.protocol", "BLIP_3+CBMobile_4", blip_handle
);
638 dissector_add_string("ws.protocol", "BLIP_3+CBMobile_3", blip_handle
);
639 dissector_add_string("ws.protocol", "BLIP_3+CBMobile_2", blip_handle
);
643 * Editor modelines - https://www.wireshark.org/tools/modelines.html
648 * indent-tabs-mode: t
651 * ex: set shiftwidth=8 tabstop=8 noexpandtab:
652 * :indentSize=8:tabSize=8:noTabs=false: