*
* Copyright 2000, Gerald Combs <gerald@zing.org>
*
- * $Id: packet-syslog.c,v 1.2 2000/06/11 15:54:02 gerald Exp $
+ * $Id: packet-syslog.c,v 1.11 2001/06/18 02:17:53 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
/* The maximum number if priority digits to read in. */
#define MAX_DIGITS 3
-/* On my RH 6.2 box, memcpy overwrites nearby chunks of memory if this is
- a multiple of four... */
-#define COL_INFO_LEN 35
+#define COL_INFO_LEN 32
#define ELLIPSIS "..." /* ISO 8859-1 doesn't appear to have a real ellipsis. */
static const value_string short_lev[] = {
upper five bits are the facility. T is the message text.
*/
-#if 0
static void dissect_syslog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
-{
- gint pri = -1, lev, fac;
- gint msg_off = 0, msg_len;
- gint ellipsis_len = (COL_INFO_LEN - strlen(ELLIPSIS)) - 1;
- proto_item *ti;
- proto_tree *syslog_tree;
- gchar msg_str[COL_INFO_LEN];
-#else
-static void dissect_syslog(const u_char *pd, int o, frame_data *fd, proto_tree *tree)
{
gint pri = -1, lev = -1, fac = -1;
gint msg_off = 0, msg_len;
proto_tree *syslog_tree;
gchar msg_str[COL_INFO_LEN];
- tvbuff_t *tvb;
- packet_info *pinfo = π
- tvb = tvb_new_subset(pinfo->compat_top_tvb, o, -1, -1);
-#endif
-
- pinfo->current_proto = "Syslog";
+ if (check_col(pinfo->fd, COL_PROTOCOL))
+ col_set_str(pinfo->fd, COL_PROTOCOL, "Syslog");
+ if (check_col(pinfo->fd, COL_INFO))
+ col_clear(pinfo->fd, COL_INFO);
+
msg_len = tvb_length(tvb);
if (tvb_get_guint8(tvb, 0) == '<' && isdigit(tvb_get_guint8(tvb, 1))) {
/* Copy the message into a string buffer, with a trailing ellipsis if needed. */
msg_len = tvb_length_remaining(tvb, msg_off);
- if (msg_len > ellipsis_len) {
+ if (msg_len >= COL_INFO_LEN) {
tvb_memcpy(tvb, msg_str, msg_off, ellipsis_len);
strcpy (msg_str + ellipsis_len, ELLIPSIS);
- msg_str[COL_INFO_LEN] = '\0';
} else {
tvb_memcpy(tvb, msg_str, msg_off, msg_len);
msg_str[msg_len] = '\0';
}
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_add_str(pinfo->fd, COL_PROTOCOL, "Syslog");
-
if (check_col(pinfo->fd, COL_INFO)) {
if (pri >= 0) {
col_add_fstr(pinfo->fd, COL_INFO, "%s.%s: %s",
{ &hf_syslog_facility,
{ "Facility", "syslog.facility",
FT_UINT8, BASE_DEC, VALS(long_fac), FACILITY_MASK,
- "Message facility" }
+ "Message facility", HFILL }
},
{ &hf_syslog_level,
{ "Level", "syslog.level",
FT_UINT8, BASE_DEC, VALS(long_lev), PRIORITY_MASK,
- "Message level" }
+ "Message level", HFILL }
},
{ &hf_syslog_msg_len,
{ "Message length", "syslog.msg_len",
FT_UINT32, BASE_DEC, NULL, 0x0,
- "Message length, excluding priority descriptor" }
+ "Message length, excluding priority descriptor", HFILL }
},
};
};
/* Register the protocol name and description */
- proto_syslog = proto_register_protocol("Syslog message", "syslog");
+ proto_syslog = proto_register_protocol("Syslog message", "Syslog", "syslog");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_syslog, hf, array_length(hf));
void
proto_reg_handoff_syslog(void)
{
- dissector_add("udp.port", UDP_PORT_SYSLOG, dissect_syslog);
+ dissector_add("udp.port", UDP_PORT_SYSLOG, dissect_syslog, proto_syslog);
}