3 * Routines for Riemann dissection
4 * Copyright 2014, Sergey Avseyev <sergey.avseyev@gmail.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 /* Riemann (http://riemann.io) aggregates events from servers and
14 * applications with a powerful stream processing language.
16 * Protobuf structures layout:
17 * https://github.com/riemann/riemann-java-client/blob/master/riemann-java-client/src/main/proto/riemann/proto.proto
20 * optional int64 time = 1;
21 * optional string state = 2;
22 * optional string service = 3;
23 * optional string host = 4;
24 * optional string description = 5;
25 * optional bool once = 6;
26 * repeated string tags = 7;
27 * optional float ttl = 8;
31 * optional int64 time = 1;
32 * optional string state = 2;
33 * optional string service = 3;
34 * optional string host = 4;
35 * optional string description = 5;
36 * repeated string tags = 7;
37 * optional float ttl = 8;
38 * repeated Attribute attributes = 9;
40 * optional int64 time_micros = 10;
41 * optional sint64 metric_sint64 = 13;
42 * optional double metric_d = 14;
43 * optional float metric_f = 15;
47 * optional string string = 1;
51 * optional bool ok = 2;
52 * optional string error = 3;
53 * repeated State states = 4;
54 * optional Query query = 5;
55 * repeated Event events = 6;
59 * required string key = 1;
60 * optional string value = 2;
66 #include <epan/packet.h>
67 #include <epan/expert.h>
68 #include "packet-tcp.h"
70 void proto_reg_handoff_riemann(void);
71 void proto_register_riemann(void);
73 static dissector_handle_t riemann_udp_handle
, riemann_tcp_handle
;
75 static int proto_riemann
;
76 static int hf_riemann_msg_ok
;
77 static int hf_riemann_msg_error
;
78 static int hf_riemann_attribute
;
79 static int hf_riemann_attribute_key
;
80 static int hf_riemann_attribute_value
;
81 static int hf_riemann_query
;
82 static int hf_riemann_query_string
;
83 static int hf_riemann_event
;
84 static int hf_riemann_event_state
;
85 static int hf_riemann_event_service
;
86 static int hf_riemann_event_host
;
87 static int hf_riemann_event_description
;
88 static int hf_riemann_event_tag
;
89 static int hf_riemann_event_ttl
;
90 static int hf_riemann_event_time
;
91 static int hf_riemann_event_metric_d
;
92 static int hf_riemann_event_metric_f
;
93 static int hf_riemann_event_time_micros
;
94 static int hf_riemann_event_metric_sint64
;
95 static int hf_riemann_state
;
96 static int hf_riemann_state_service
;
97 static int hf_riemann_state_host
;
98 static int hf_riemann_state_description
;
99 static int hf_riemann_state_tag
;
100 static int hf_riemann_state_ttl
;
101 static int hf_riemann_state_time
;
102 static int hf_riemann_state_state
;
103 static int hf_riemann_state_once
;
105 static int ett_riemann
;
106 static int ett_query
;
107 static int ett_event
;
108 static int ett_attribute
;
109 static int ett_state
;
111 #define RIEMANN_MIN_LENGTH 16
112 #define RIEMANN_MIN_NEEDED_FOR_HEURISTICS 10
114 /* field numbers. see protocol definition above */
115 #define RIEMANN_FN_MSG_OK 2
116 #define RIEMANN_FN_MSG_ERROR 3
117 #define RIEMANN_FN_MSG_STATES 4
118 #define RIEMANN_FN_MSG_QUERY 5
119 #define RIEMANN_FN_MSG_EVENTS 6
121 #define RIEMANN_FN_EVENT_TIME 1
122 #define RIEMANN_FN_EVENT_STATE 2
123 #define RIEMANN_FN_EVENT_SERVICE 3
124 #define RIEMANN_FN_EVENT_HOST 4
125 #define RIEMANN_FN_EVENT_DESCRIPTION 5
126 #define RIEMANN_FN_EVENT_TAGS 7
127 #define RIEMANN_FN_EVENT_TTL 8
128 #define RIEMANN_FN_EVENT_ATTRIBUTES 9
129 #define RIEMANN_FN_EVENT_TIME_MICROS 10
130 #define RIEMANN_FN_EVENT_METRIC_SINT64 13
131 #define RIEMANN_FN_EVENT_METRIC_D 14
132 #define RIEMANN_FN_EVENT_METRIC_F 15
134 #define RIEMANN_FN_ATTRIBUTE_KEY 1
135 #define RIEMANN_FN_ATTRIBUTE_VALUE 2
137 #define RIEMANN_FN_STATE_TIME 1
138 #define RIEMANN_FN_STATE_STATE 2
139 #define RIEMANN_FN_STATE_SERVICE 3
140 #define RIEMANN_FN_STATE_HOST 4
141 #define RIEMANN_FN_STATE_DESCRIPTION 5
142 #define RIEMANN_FN_STATE_ONCE 6
143 #define RIEMANN_FN_STATE_TAGS 7
144 #define RIEMANN_FN_STATE_TTL 8
146 #define RIEMANN_FN_QUERY_STRING 1
148 /* type codes. see protocol definition above */
149 #define RIEMANN_WIRE_INTEGER 0
150 #define RIEMANN_WIRE_DOUBLE 1
151 #define RIEMANN_WIRE_BYTES 2
152 #define RIEMANN_WIRE_FLOAT 5
154 static expert_field ei_error_unknown_wire_tag
;
155 static expert_field ei_error_unknown_field_number
;
156 static expert_field ei_error_insufficient_data
;
159 riemann_verify_wire_format(uint64_t field_number
, const char *field_name
, int expected
, int actual
,
160 packet_info
*pinfo
, proto_item
*pi
)
162 if (expected
!= actual
) {
163 const char *wire_name
;
166 case RIEMANN_WIRE_INTEGER
:
167 wire_name
= "integer";
169 case RIEMANN_WIRE_BYTES
:
170 wire_name
= "bytes/string";
172 case RIEMANN_WIRE_FLOAT
:
175 case RIEMANN_WIRE_DOUBLE
:
176 wire_name
= "double";
179 wire_name
= "unknown (check packet-riemann.c)";
182 expert_add_info_format(pinfo
, pi
, &ei_error_unknown_wire_tag
,
183 "Expected %s (%d) field to be an %s (%d), but it is %d",
184 field_name
, (int)field_number
, wire_name
, expected
, actual
);
188 #define VERIFY_WIRE_FORMAT(field_name, expected) \
189 riemann_verify_wire_format(fn, field_name, expected, wire, pinfo, pi)
191 #define UNKNOWN_FIELD_NUMBER_FOR(message_name) \
192 expert_add_info_format(pinfo, pi, &ei_error_unknown_field_number, \
193 "Unknown field number %d for " message_name " (wire format %d)", \
196 #define VERIFY_SIZE_FOR(message_name) \
198 expert_add_info_format(pinfo, pi, &ei_error_insufficient_data, \
199 "Insufficient data for " message_name " (%d bytes needed)", \
204 riemann_get_uint64(tvbuff_t
*tvb
, unsigned offset
, unsigned *len
)
214 b
= tvb_get_uint8(tvb
, offset
++);
215 num
|= ((uint64_t)(b
& 0x7f) << shift
);
218 if ((b
& 0x80) == 0) {
226 riemann_get_string(wmem_allocator_t
*scope
, tvbuff_t
*tvb
, int offset
)
231 size
= riemann_get_uint64(tvb
, offset
, &len
);
233 return tvb_get_string_enc(scope
, tvb
, offset
, (int)size
, ENC_ASCII
);
237 riemann_dissect_int64(proto_tree
*riemann_tree
, tvbuff_t
*tvb
, unsigned offset
, int hf_index
)
242 num
= riemann_get_uint64(tvb
, offset
, &len
);
243 proto_tree_add_int64(riemann_tree
, hf_index
, tvb
, offset
, len
, num
);
248 riemann_dissect_sint64(proto_tree
*riemann_tree
, tvbuff_t
*tvb
, unsigned offset
, int hf_index
)
254 num
= riemann_get_uint64(tvb
, offset
, &len
);
255 /* zigzag decoding */
257 snum
= -((int64_t)(num
>> 1)) - 1;
259 snum
= (int64_t)(num
>> 1);
262 proto_tree_add_int64(riemann_tree
, hf_index
, tvb
, offset
, len
, snum
);
267 riemann_dissect_string(proto_tree
*riemann_tree
, tvbuff_t
*tvb
, unsigned offset
, int hf_index
)
270 unsigned len
= 0, orig_offset
= offset
;
272 size
= riemann_get_uint64(tvb
, offset
, &len
);
274 proto_tree_add_item(riemann_tree
, hf_index
, tvb
, offset
, (int)size
, ENC_ASCII
);
277 return offset
- orig_offset
;
281 riemann_dissect_attribute(packet_info
*pinfo
, proto_tree
*riemann_tree
,
282 tvbuff_t
*tvb
, unsigned offset
)
288 unsigned orig_offset
= offset
;
290 proto_tree
*attribute_tree
;
292 size
= (int64_t)riemann_get_uint64(tvb
, offset
, &len
);
293 pi
= proto_tree_add_item(riemann_tree
, hf_riemann_attribute
, tvb
, (int)offset
, (int)(size
+ len
), ENC_NA
);
294 attribute_tree
= proto_item_add_subtree(pi
, ett_attribute
);
298 tag
= riemann_get_uint64(tvb
, offset
, &len
);
304 case RIEMANN_FN_ATTRIBUTE_KEY
:
305 VERIFY_WIRE_FORMAT("Attribute.key", RIEMANN_WIRE_BYTES
);
306 len
= riemann_dissect_string(attribute_tree
, tvb
, offset
, hf_riemann_attribute_key
);
308 case RIEMANN_FN_ATTRIBUTE_VALUE
:
309 VERIFY_WIRE_FORMAT("Attribute.value", RIEMANN_WIRE_BYTES
);
310 len
= riemann_dissect_string(attribute_tree
, tvb
, offset
, hf_riemann_attribute_value
);
314 UNKNOWN_FIELD_NUMBER_FOR("Attribute");
319 VERIFY_SIZE_FOR("Attribute");
321 return offset
- orig_offset
;
325 riemann_dissect_query(packet_info
*pinfo
, proto_tree
*riemann_tree
,
326 tvbuff_t
*tvb
, unsigned offset
)
331 unsigned orig_offset
= offset
, len
= 0;
333 proto_tree
*query_tree
;
335 size
= (int64_t)riemann_get_uint64(tvb
, offset
, &len
);
336 pi
= proto_tree_add_item(riemann_tree
, hf_riemann_query
, tvb
, (int)offset
, (int)(size
+ len
), ENC_NA
);
337 query_tree
= proto_item_add_subtree(pi
, ett_query
);
341 tag
= riemann_get_uint64(tvb
, offset
, &len
);
347 case RIEMANN_FN_QUERY_STRING
:
348 VERIFY_WIRE_FORMAT("Query.string", RIEMANN_WIRE_BYTES
);
349 col_append_str(pinfo
->cinfo
, COL_INFO
, riemann_get_string(pinfo
->pool
, tvb
, offset
));
350 len
= riemann_dissect_string(query_tree
, tvb
, offset
, hf_riemann_query_string
);
354 UNKNOWN_FIELD_NUMBER_FOR("Query");
359 VERIFY_SIZE_FOR("Query");
361 return offset
- orig_offset
;
365 riemann_dissect_event(packet_info
*pinfo
, proto_tree
*riemann_tree
,
366 tvbuff_t
*tvb
, unsigned offset
)
368 unsigned orig_offset
= offset
, len
= 0;
373 proto_tree
*event_tree
;
374 bool need_comma
= false;
376 size
= riemann_get_uint64(tvb
, offset
, &len
);
377 pi
= proto_tree_add_item(riemann_tree
, hf_riemann_event
, tvb
, (int)offset
, (int)(size
+ len
), ENC_NA
);
378 event_tree
= proto_item_add_subtree(pi
, ett_event
);
382 const char *comma
= need_comma
? ", " : "";
383 tag
= riemann_get_uint64(tvb
, offset
, &len
);
389 case RIEMANN_FN_EVENT_TIME
:
390 VERIFY_WIRE_FORMAT("Event.time", RIEMANN_WIRE_INTEGER
);
391 len
= riemann_dissect_int64(event_tree
, tvb
, offset
, hf_riemann_event_time
);
393 case RIEMANN_FN_EVENT_STATE
:
394 VERIFY_WIRE_FORMAT("Event.state", RIEMANN_WIRE_BYTES
);
395 len
= riemann_dissect_string(event_tree
, tvb
, offset
, hf_riemann_event_state
);
397 case RIEMANN_FN_EVENT_SERVICE
:
398 VERIFY_WIRE_FORMAT("Event.service", RIEMANN_WIRE_BYTES
);
399 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "%s%s", comma
, riemann_get_string(pinfo
->pool
, tvb
, offset
));
400 len
= riemann_dissect_string(event_tree
, tvb
, offset
, hf_riemann_event_service
);
403 case RIEMANN_FN_EVENT_HOST
:
404 VERIFY_WIRE_FORMAT("Event.host", RIEMANN_WIRE_BYTES
);
405 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "%s%s", comma
, riemann_get_string(pinfo
->pool
, tvb
, offset
));
406 len
= riemann_dissect_string(event_tree
, tvb
, offset
, hf_riemann_event_host
);
409 case RIEMANN_FN_EVENT_DESCRIPTION
:
410 VERIFY_WIRE_FORMAT("Event.description", RIEMANN_WIRE_BYTES
);
411 len
= riemann_dissect_string(event_tree
, tvb
, offset
, hf_riemann_event_description
);
413 case RIEMANN_FN_EVENT_TAGS
:
414 VERIFY_WIRE_FORMAT("Event.tags", RIEMANN_WIRE_BYTES
);
415 len
= riemann_dissect_string(event_tree
, tvb
, offset
, hf_riemann_event_tag
);
417 case RIEMANN_FN_EVENT_TTL
:
418 VERIFY_WIRE_FORMAT("Event.ttl", RIEMANN_WIRE_FLOAT
);
419 proto_tree_add_item(event_tree
, hf_riemann_event_ttl
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
422 case RIEMANN_FN_EVENT_ATTRIBUTES
:
423 VERIFY_WIRE_FORMAT("Event.attributes", RIEMANN_WIRE_BYTES
);
424 len
= riemann_dissect_attribute(pinfo
, event_tree
, tvb
, offset
);
426 case RIEMANN_FN_EVENT_TIME_MICROS
:
427 VERIFY_WIRE_FORMAT("Event.time_micros", RIEMANN_WIRE_INTEGER
);
428 len
= riemann_dissect_int64(event_tree
, tvb
, offset
, hf_riemann_event_time_micros
);
430 case RIEMANN_FN_EVENT_METRIC_SINT64
:
431 VERIFY_WIRE_FORMAT("Event.metric_sint64", RIEMANN_WIRE_INTEGER
);
432 len
= riemann_dissect_sint64(event_tree
, tvb
, offset
, hf_riemann_event_metric_sint64
);
434 case RIEMANN_FN_EVENT_METRIC_D
:
435 VERIFY_WIRE_FORMAT("Event.metric_d", RIEMANN_WIRE_DOUBLE
);
436 proto_tree_add_item(event_tree
, hf_riemann_event_metric_d
, tvb
, offset
, 8, ENC_LITTLE_ENDIAN
);
439 case RIEMANN_FN_EVENT_METRIC_F
:
440 VERIFY_WIRE_FORMAT("Event.metric_f", RIEMANN_WIRE_FLOAT
);
441 proto_tree_add_item(event_tree
, hf_riemann_event_metric_f
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
446 UNKNOWN_FIELD_NUMBER_FOR("Event");
451 col_append_str(pinfo
->cinfo
, COL_INFO
, "; ");
452 VERIFY_SIZE_FOR("Event");
454 return offset
- orig_offset
;
458 riemann_dissect_state(packet_info
*pinfo
, proto_tree
*riemann_tree
,
459 tvbuff_t
*tvb
, unsigned offset
)
461 unsigned orig_offset
= offset
, len
= 0;
466 proto_tree
*state_tree
;
467 bool need_comma
= false;
469 size
= riemann_get_uint64(tvb
, offset
, &len
);
470 pi
= proto_tree_add_item(riemann_tree
, hf_riemann_state
, tvb
, offset
, (int)(size
+ len
), ENC_NA
);
471 state_tree
= proto_item_add_subtree(pi
, ett_state
);
475 const char *comma
= need_comma
? ", " : "";
476 tag
= riemann_get_uint64(tvb
, offset
, &len
);
482 case RIEMANN_FN_STATE_TIME
:
483 VERIFY_WIRE_FORMAT("State.time", RIEMANN_WIRE_INTEGER
);
484 len
= riemann_dissect_int64(state_tree
, tvb
, offset
, hf_riemann_state_time
);
486 case RIEMANN_FN_STATE_SERVICE
:
487 VERIFY_WIRE_FORMAT("State.service", RIEMANN_WIRE_BYTES
);
488 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "%s%s", comma
, riemann_get_string(pinfo
->pool
, tvb
, offset
));
489 len
= riemann_dissect_string(state_tree
, tvb
, offset
, hf_riemann_state_service
);
492 case RIEMANN_FN_STATE_HOST
:
493 VERIFY_WIRE_FORMAT("State.host", RIEMANN_WIRE_BYTES
);
494 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "%s%s", comma
, riemann_get_string(pinfo
->pool
, tvb
, offset
));
495 len
= riemann_dissect_string(state_tree
, tvb
, offset
, hf_riemann_state_host
);
498 case RIEMANN_FN_STATE_DESCRIPTION
:
499 VERIFY_WIRE_FORMAT("State.description", RIEMANN_WIRE_BYTES
);
500 len
= riemann_dissect_string(state_tree
, tvb
, offset
, hf_riemann_state_description
);
502 case RIEMANN_FN_STATE_TAGS
:
503 VERIFY_WIRE_FORMAT("State.tags", RIEMANN_WIRE_BYTES
);
504 len
= riemann_dissect_string(state_tree
, tvb
, offset
, hf_riemann_state_tag
);
506 case RIEMANN_FN_STATE_TTL
:
507 VERIFY_WIRE_FORMAT("State.ttl", RIEMANN_WIRE_FLOAT
);
508 proto_tree_add_item(state_tree
, hf_riemann_state_ttl
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
511 case RIEMANN_FN_STATE_STATE
:
512 VERIFY_WIRE_FORMAT("State.state", RIEMANN_WIRE_BYTES
);
513 len
= riemann_dissect_string(state_tree
, tvb
, offset
, hf_riemann_state_state
);
515 case RIEMANN_FN_STATE_ONCE
:
516 VERIFY_WIRE_FORMAT("State.once", RIEMANN_WIRE_INTEGER
);
517 proto_tree_add_item(state_tree
, hf_riemann_state_once
, tvb
, offset
, 1, ENC_NA
);
522 UNKNOWN_FIELD_NUMBER_FOR("State");
527 col_append_str(pinfo
->cinfo
, COL_INFO
, "; ");
528 VERIFY_SIZE_FOR("State");
530 return offset
- orig_offset
;
534 riemann_dissect_msg(packet_info
*pinfo
, proto_item
*pi
, proto_tree
*riemann_tree
,
535 tvbuff_t
*tvb
, unsigned offset
)
538 int64_t size
= (int64_t)tvb_reported_length_remaining(tvb
, offset
);
540 unsigned len
, orig_offset
= offset
;
541 bool cinfo_set
= false;
544 tag
= riemann_get_uint64(tvb
, offset
, &len
);
551 case RIEMANN_FN_MSG_OK
:
552 VERIFY_WIRE_FORMAT("Msg.ok", RIEMANN_WIRE_INTEGER
);
553 proto_tree_add_item(riemann_tree
, hf_riemann_msg_ok
, tvb
, offset
, 1, ENC_NA
);
556 case RIEMANN_FN_MSG_ERROR
:
557 VERIFY_WIRE_FORMAT("Msg.error", RIEMANN_WIRE_BYTES
);
558 len
= riemann_dissect_string(riemann_tree
, tvb
, offset
, hf_riemann_msg_error
);
560 case RIEMANN_FN_MSG_QUERY
:
561 VERIFY_WIRE_FORMAT("Msg.query", RIEMANN_WIRE_BYTES
);
563 col_set_str(pinfo
->cinfo
, COL_INFO
, "Query: ");
566 len
= riemann_dissect_query(pinfo
, riemann_tree
, tvb
, offset
);
568 case RIEMANN_FN_MSG_EVENTS
:
569 VERIFY_WIRE_FORMAT("Msg.events", RIEMANN_WIRE_BYTES
);
571 col_set_str(pinfo
->cinfo
, COL_INFO
, "Event: ");
574 len
= riemann_dissect_event(pinfo
, riemann_tree
, tvb
, offset
);
576 case RIEMANN_FN_MSG_STATES
:
577 VERIFY_WIRE_FORMAT("Msg.states", RIEMANN_WIRE_BYTES
);
579 col_set_str(pinfo
->cinfo
, COL_INFO
, "State: ");
582 len
= riemann_dissect_state(pinfo
, riemann_tree
, tvb
, offset
);
586 UNKNOWN_FIELD_NUMBER_FOR("Msg");
591 VERIFY_SIZE_FOR("Msg");
593 return offset
- orig_offset
;
597 is_riemann(tvbuff_t
*tvb
, unsigned offset
)
599 uint32_t reported_length
= tvb_reported_length_remaining(tvb
, offset
);
600 uint32_t captured_length
= tvb_captured_length_remaining(tvb
, offset
);
601 uint64_t tag
, field_number
, wire_format
;
604 if ((reported_length
< RIEMANN_MIN_LENGTH
) ||
605 (captured_length
< RIEMANN_MIN_NEEDED_FOR_HEURISTICS
)) {
608 tag
= riemann_get_uint64(tvb
, offset
, &len
);
609 field_number
= tag
>> 3;
610 wire_format
= tag
& 0x7;
611 if ((field_number
== RIEMANN_FN_MSG_OK
&& wire_format
== RIEMANN_WIRE_INTEGER
) ||
612 (field_number
== RIEMANN_FN_MSG_ERROR
&& wire_format
== RIEMANN_WIRE_BYTES
) ||
613 (field_number
== RIEMANN_FN_MSG_QUERY
&& wire_format
== RIEMANN_WIRE_BYTES
) ||
614 (field_number
== RIEMANN_FN_MSG_EVENTS
&& wire_format
== RIEMANN_WIRE_BYTES
) ||
615 (field_number
== RIEMANN_FN_MSG_STATES
&& wire_format
== RIEMANN_WIRE_BYTES
)) {
622 dissect_riemann(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, unsigned offset
)
625 proto_tree
*riemann_tree
;
627 if (!is_riemann(tvb
, offset
))
630 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "riemann");
631 col_clear(pinfo
->cinfo
, COL_INFO
);
633 pi
= proto_tree_add_item(tree
, proto_riemann
, tvb
, offset
, -1, ENC_NA
);
634 riemann_tree
= proto_item_add_subtree(pi
, ett_riemann
);
636 return riemann_dissect_msg(pinfo
, pi
, riemann_tree
, tvb
, offset
);
640 dissect_riemann_udp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
642 return dissect_riemann(tvb
, pinfo
, tree
, 0);
646 dissect_riemann_tcp_pdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
648 return dissect_riemann(tvb
, pinfo
, tree
, 4);
652 get_riemann_tcp_pdu_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
,
653 int offset
, void *data _U_
)
655 return (tvb_get_ntohl(tvb
, offset
) + 4);
659 dissect_riemann_tcp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
661 tcp_dissect_pdus(tvb
, pinfo
, tree
, true, 4, get_riemann_tcp_pdu_len
, dissect_riemann_tcp_pdu
, data
);
663 return tvb_captured_length(tvb
);
667 proto_register_riemann(void)
669 expert_module_t
*riemann_expert_module
;
671 static hf_register_info hf
[] = {
672 { &hf_riemann_msg_ok
,
673 { "ok", "riemann.msg.ok",
674 FT_BOOLEAN
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
676 { &hf_riemann_msg_error
,
677 { "error", "riemann.msg.error",
678 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
680 { &hf_riemann_attribute
,
681 { "attribute", "riemann.attribute",
682 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
684 { &hf_riemann_attribute_key
,
685 { "key", "riemann.attribute.key",
686 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
688 { &hf_riemann_attribute_value
,
689 { "value", "riemann.attribute.value",
690 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
693 { "query", "riemann.query",
694 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
696 { &hf_riemann_query_string
,
697 { "string", "riemann.query.string",
698 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
701 { "event", "riemann.event",
702 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
704 { &hf_riemann_event_state
,
705 { "state", "riemann.event.state",
706 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
708 { &hf_riemann_event_service
,
709 { "service", "riemann.event.service",
710 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
712 { &hf_riemann_event_host
,
713 { "host", "riemann.event.host",
714 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
716 { &hf_riemann_event_description
,
717 { "description", "riemann.event.description",
718 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
720 { &hf_riemann_event_tag
,
721 { "tag", "riemann.event.tag",
722 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
724 { &hf_riemann_event_time
,
725 { "time", "riemann.event.time",
726 FT_INT64
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}
728 { &hf_riemann_event_ttl
,
729 { "ttl", "riemann.event.ttl",
730 FT_FLOAT
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
732 { &hf_riemann_event_metric_d
,
733 { "metric_d", "riemann.event.metric_d",
734 FT_DOUBLE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
736 { &hf_riemann_event_metric_f
,
737 { "metric_f", "riemann.event.metric_f",
738 FT_FLOAT
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
740 { &hf_riemann_event_time_micros
,
741 { "time_micros", "riemann.event.time_micros",
742 FT_INT64
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}
744 { &hf_riemann_event_metric_sint64
,
745 { "metric_sint64", "riemann.event.metric_sint64",
746 FT_INT64
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}
749 { "state", "riemann.state",
750 FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
752 { &hf_riemann_state_service
,
753 { "service", "riemann.state.service",
754 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
756 { &hf_riemann_state_host
,
757 { "host", "riemann.state.host",
758 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
760 { &hf_riemann_state_description
,
761 { "description", "riemann.state.description",
762 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
764 { &hf_riemann_state_tag
,
765 { "tag", "riemann.state.tag",
766 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
768 { &hf_riemann_state_time
,
769 { "time", "riemann.state.time",
770 FT_INT64
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}
772 { &hf_riemann_state_ttl
,
773 { "ttl", "riemann.state.ttl",
774 FT_FLOAT
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
776 { &hf_riemann_state_state
,
777 { "state", "riemann.state.state",
778 FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
780 { &hf_riemann_state_once
,
781 { "once", "riemann.state.once",
782 FT_BOOLEAN
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}
786 static ei_register_info ei
[] = {
787 { &ei_error_unknown_wire_tag
,
788 { "riemann.unknown_wire_tag", PI_MALFORMED
, PI_ERROR
,
789 "Invalid format type", EXPFILL
}},
790 { &ei_error_unknown_field_number
,
791 { "riemann.unknown_field_number", PI_MALFORMED
, PI_ERROR
,
792 "Unknown field number", EXPFILL
}},
793 { &ei_error_insufficient_data
,
794 { "riemann.insufficient_data", PI_MALFORMED
, PI_ERROR
,
795 "Insufficient data", EXPFILL
}}
798 static int *ett
[] = {
806 proto_riemann
= proto_register_protocol("Riemann", "Riemann", "riemann");
807 riemann_expert_module
= expert_register_protocol(proto_riemann
);
808 expert_register_field_array(riemann_expert_module
, ei
, array_length(ei
));
810 proto_register_field_array(proto_riemann
, hf
, array_length(hf
));
811 proto_register_subtree_array(ett
, array_length(ett
));
813 riemann_udp_handle
= register_dissector("riemann.udp", dissect_riemann_udp
, proto_riemann
);
814 riemann_tcp_handle
= register_dissector("riemann.tcp", dissect_riemann_tcp
, proto_riemann
);
818 proto_reg_handoff_riemann(void)
820 dissector_add_for_decode_as_with_preference("tcp.port", riemann_tcp_handle
);
821 dissector_add_for_decode_as_with_preference("udp.port", riemann_udp_handle
);
825 * Editor modelines - https://www.wireshark.org/tools/modelines.html
830 * indent-tabs-mode: nil
833 * vi: set shiftwidth=4 tabstop=8 expandtab:
834 * :indentSize=4:tabSize=8:noTabs=true: