Make the message popped up if you try to do a capture on a Win32 machine
[obnox/wireshark/wip.git] / packet-syslog.c
index c66eef70d9ef0715e5b8a8a90ca0c6310e102f15..c6767078b7d3688b1df4ab62edcc65a63324bc9e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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>
@@ -45,9 +45,7 @@
 /* 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[] = {
@@ -138,17 +136,7 @@ static gint ett_syslog = -1;
    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;
@@ -157,12 +145,11 @@ static void dissect_syslog(const u_char *pd, int o, frame_data *fd, proto_tree *
   proto_tree *syslog_tree;
   gchar msg_str[COL_INFO_LEN];
 
-  tvbuff_t *tvb;
-  packet_info *pinfo = &pi;
-  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))) {
@@ -181,18 +168,14 @@ static void dissect_syslog(const u_char *pd, int o, frame_data *fd, proto_tree *
 
   /* 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", 
@@ -235,17 +218,17 @@ void proto_register_syslog(void)
     { &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 }
     },
   };
 
@@ -255,7 +238,7 @@ void proto_register_syslog(void)
   };
 
   /* 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));
@@ -265,5 +248,5 @@ void proto_register_syslog(void)
 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);
 }