* Routines for unix rlogin packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet-rlogin.c,v 1.20 2001/09/30 23:14:43 guy Exp $
+ * $Id: packet-rlogin.c,v 1.26 2002/01/24 09:20:51 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include <string.h>
#include <glib.h>
-#include "packet.h"
-#include "conversation.h"
+#include <epan/packet.h>
+#include <epan/conversation.h>
#include "packet-tcp.h"
tvb_memcpy(tvb, (guint8 *)hash_info->name, 0, stringlen);
hash_info->name[stringlen] = '\0';
- if (check_col(pinfo->fd, COL_INFO)) /* update summary */
- col_append_str(pinfo->fd, COL_INFO,
+ if (check_col(pinfo->cinfo, COL_INFO)) /* update summary */
+ col_append_str(pinfo->cinfo, COL_INFO,
", User information");
}
}
gint ti_offset;
proto_item *user_info_item, *window_info_item;
- ti = proto_tree_add_item( tree, proto_rlogin, tvb, 0,
- tvb_length(tvb), FALSE);
+ ti = proto_tree_add_item( tree, proto_rlogin, tvb, 0, -1, FALSE);
rlogin_tree = proto_item_add_subtree(ti, ett_rlogin);
if ( length == 0) /* exit if no captured data */
return;
- if ( tcpinfo->urgent_pointer && /* if control message */
+ /*
+ * XXX - this works only if the urgent pointer points to something
+ * in this segment; to make it work if the urgent pointer points
+ * to something past this segment, we'd have to remember the urgent
+ * pointer setting for this conversation.
+ */
+ if ( tcpinfo->urgent && /* if urgent pointer set */
length >= tcpinfo->urgent_pointer) { /* and it's in this frame */
int urgent_offset = tcpinfo->urgent_pointer - 1;
* First frame of conversation, hence user info?
*/
user_info_item = proto_tree_add_item( rlogin_tree, hf_user_info, tvb,
- offset, tvb_length_remaining(tvb, offset), FALSE);
+ offset, -1, FALSE);
/*
* Do server user name.
/*
* There's more data in the frame.
*/
- proto_tree_add_text(rlogin_tree, tvb, offset,
- tvb_length_remaining(tvb, offset), "Data");
+ proto_tree_add_text(rlogin_tree, tvb, offset, -1, "Data");
}
}
static void
dissect_rlogin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- struct tcpinfo *tcpinfo = pinfo->private;
+ struct tcpinfo *tcpinfo = pinfo->private_data;
conversation_t *conversation;
rlogin_hash_entry_t *hash_info;
+ guint length;
gint ti_offset;
/* Lookup this connection*/
hash_info);
}
- if (check_col(pinfo->fd, COL_PROTOCOL)) /* update protocol */
- col_set_str(pinfo->fd, COL_PROTOCOL, "Rlogin");
+ if (check_col(pinfo->cinfo, COL_PROTOCOL)) /* update protocol */
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "Rlogin");
- if (check_col(pinfo->fd, COL_INFO)){ /* display packet info*/
+ if (check_col(pinfo->cinfo, COL_INFO)){ /* display packet info*/
char temp[1000];
- col_clear(pinfo->fd, COL_INFO);
+ col_clear(pinfo->cinfo, COL_INFO);
if ( hash_info->name[0]) {
strcpy( temp, "User name: ");
strcat( temp, hash_info->name);
else
temp[0] = 0;
- if ( tvb_get_guint8(tvb, 0) == '\0')
- strcat( temp, "Start Handshake");
- else if ( tcpinfo->urgent_pointer)
- strcat( temp, "Control Message");
-
- else { /* check for terminal info */
- ti_offset = tvb_find_guint8(tvb, 0, -1, 0xff);
- if (ti_offset != -1 &&
- tvb_bytes_exist(tvb, ti_offset + 1, 1) &&
- tvb_get_guint8(tvb, ti_offset + 1) == 0xff)
- strcat( temp, "Terminal Info");
- else {
- int i;
- int bytes_to_copy;
-
- strcat( temp, "Data: ");
- i = strlen( temp);
- bytes_to_copy = tvb_length(tvb);
- if (bytes_to_copy > 128)
- bytes_to_copy = 128;
- tvb_memcpy(tvb, (guint8 *)&temp[i], 0,
- bytes_to_copy);
- temp[i + bytes_to_copy] = '\0';
+ length = tvb_length(tvb);
+ if (length != 0) {
+ if ( tvb_get_guint8(tvb, 0) == '\0')
+ strcat( temp, "Start Handshake");
+ else if ( tcpinfo->urgent &&
+ length >= tcpinfo->urgent_pointer )
+ strcat( temp, "Control Message");
+
+ else { /* check for terminal info */
+ ti_offset = tvb_find_guint8(tvb, 0, -1, 0xff);
+ if (ti_offset != -1 &&
+ tvb_bytes_exist(tvb, ti_offset + 1, 1) &&
+ tvb_get_guint8(tvb, ti_offset + 1) == 0xff)
+ strcat( temp, "Terminal Info");
+ else {
+ int i;
+ int bytes_to_copy;
+
+ strcat( temp, "Data: ");
+ i = strlen( temp);
+ bytes_to_copy = tvb_length(tvb);
+ if (bytes_to_copy > 128)
+ bytes_to_copy = 128;
+ tvb_memcpy(tvb, (guint8 *)&temp[i], 0,
+ bytes_to_copy);
+ temp[i + bytes_to_copy] = '\0';
+ }
}
}
- col_add_str(pinfo->fd, COL_INFO, temp);
+ col_add_str(pinfo->cinfo, COL_INFO, temp);
}
rlogin_state_machine( hash_info, tvb, pinfo);
/* dissector install routine */
- dissector_add("tcp.port", TCP_PORT_RLOGIN, dissect_rlogin,
- proto_rlogin);
+ dissector_handle_t rlogin_handle;
+
+ rlogin_handle = create_dissector_handle(dissect_rlogin, proto_rlogin);
+ dissector_add("tcp.port", TCP_PORT_RLOGIN, rlogin_handle);
}