Add a "BYTES_ARE_IN_FRAME()" macro, to test whether there are a

specified number of bytes of captured data in the frame at the specified
offset, and a "IS_DATA_IN_FRAME()" macro, to test whether there are any
bytes of captured data in the frame at the specified offset, and convert
some bounds checks to use them.

Add a dissector for the Internet Printing Protocol.

svn path=/trunk/; revision=685
This commit is contained in:
Guy Harris 1999-09-17 05:56:58 +00:00
parent ff20b92b67
commit 96e79ab6f8
13 changed files with 583 additions and 25 deletions

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
# $Id: Makefile.am,v 1.73 1999/09/17 04:38:14 gram Exp $
# $Id: Makefile.am,v 1.74 1999/09/17 05:56:53 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@ -74,6 +74,7 @@ ethereal_SOURCES = \
packet-icp.c \
packet-ip.c \
packet-ip.h \
packet-ipp.c \
packet-ipsec.c \
packet-ipv6.c \
packet-ipv6.h \

View File

@ -2,7 +2,7 @@
* Routines for the disassembly of the "Cisco Discovery Protocol"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
* $Id: packet-cdp.c,v 1.13 1999/08/25 00:42:49 guy Exp $
* $Id: packet-cdp.c,v 1.14 1999/09/17 05:56:53 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -97,7 +97,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
pntohs(&pd[offset]));
offset += 2;
while( offset < pi.captured_len ){
while( IS_DATA_IN_FRAME(offset) ){
type = pntohs(&pd[offset + TLV_TYPE]);
length = pntohs(&pd[offset + TLV_LENGTH]);
type_str = val_to_str(type, type_vals,

View File

@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
* $Id: packet-giop.c,v 1.5 1999/08/26 07:34:42 guy Exp $
* $Id: packet-giop.c,v 1.6 1999/09/17 05:56:53 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -211,7 +211,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
#define END_OF_GIOP_MESSAGE (offset - first_offset - GIOP_HEADER_SIZE)
if (pi.captured_len < offset + GIOP_HEADER_SIZE) {
if (!BYTES_ARE_IN_FRAME(offset, GIOP_HEADER_SIZE)) {
dissect_data(pd, offset, fd, tree);
return;
}
@ -304,7 +304,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
offset += GIOP_HEADER_SIZE;
if (pi.captured_len < offset + message_size) {
if (!BYTES_ARE_IN_FRAME(offset, message_size)) {
dissect_data(pd, offset, fd, tree);
return;
}
@ -691,7 +691,7 @@ void dissect_giop(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
offset = first_offset + GIOP_HEADER_SIZE + message_size;
if (offset < pi.captured_len) {
if (IS_DATA_IN_FRAME(offset)) {
dissect_data(pd, offset, fd, tree);
}

View File

@ -2,7 +2,7 @@
* Routines for the Generic Routing Encapsulation (GRE) protocol
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
*
* $Id: packet-gre.c,v 1.5 1999/08/26 07:34:42 guy Exp $
* $Id: packet-gre.c,v 1.6 1999/09/17 05:56:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -77,7 +77,7 @@ dissect_gre(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
col_add_str(fd, COL_INFO, "Encapsulated unknown");
}
if (pi.captured_len > offset && tree) {
if (IS_DATA_IN_FRAME(offset) && tree) {
int is_ppp;
proto_item * ti;
proto_tree * gre_tree;

View File

@ -3,7 +3,7 @@
*
* Guy Harris <guy@netapp.com>
*
* $Id: packet-http.c,v 1.8 1999/09/12 18:46:57 guy Exp $
* $Id: packet-http.c,v 1.9 1999/09/17 05:56:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -47,6 +47,7 @@ static int is_http_request_or_reply(const u_char *data, int linelen);
void dissect_http(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
gboolean is_ipp = (pi.srcport == 631 || pi.destport == 631);
proto_tree *http_tree;
proto_item *ti;
const u_char *data, *dataend;
@ -58,7 +59,7 @@ void dissect_http(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
dataend = data + END_OF_FRAME;
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "HTTP");
col_add_str(fd, COL_PROTOCOL, is_ipp ? "IPP" : "HTTP");
if (check_col(fd, COL_INFO)) {
/*
* Put the first line from the buffer into the summary,
@ -168,8 +169,12 @@ void dissect_http(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
data = lineend;
}
if (data < dataend)
dissect_data(&pd[offset], offset, fd, http_tree);
if (data < dataend) {
if (is_ipp)
dissect_ipp(pd, offset, fd, tree);
else
dissect_data(&pd[offset], offset, fd, http_tree);
}
}
}

538
packet-ipp.c Normal file
View File

@ -0,0 +1,538 @@
/* packet-ipp.c
* Routines for IPP packet disassembly
*
* Guy Harris <guy@netapp.com>
*
* $Id: packet-ipp.c,v 1.1 1999/09/17 05:56:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* Copyright 1998 Gerald Combs
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <string.h>
#include <ctype.h>
#include <glib.h>
#include "packet.h"
static int proto_ipp = -1;
#define PRINT_JOB 0x0002
#define PRINT_URI 0x0003
#define VALIDATE_JOB 0x0004
#define CREATE_JOB 0x0005
#define SEND_DOCUMENT 0x0006
#define SEND_URI 0x0007
#define CANCEL_JOB 0x0008
#define GET_JOB_ATTRIBUTES 0x0009
#define GET_JOBS 0x000A
#define GET_PRINTER_ATTRIBUTES 0x000B
static const value_string operation_vals[] = {
{ PRINT_JOB, "Print-Job" },
{ PRINT_URI, "Print-URI" },
{ VALIDATE_JOB, "Validate-Job" },
{ CREATE_JOB, "Create-Job" },
{ SEND_DOCUMENT, "Send-Document" },
{ SEND_URI, "Send-URI" },
{ CANCEL_JOB, "Cancel-Job" },
{ GET_JOB_ATTRIBUTES, "Get-Job-Attributes" },
{ GET_JOBS, "Get-Jobs" },
{ GET_PRINTER_ATTRIBUTES, "Get-Printer-Attributes" },
{ 0, NULL }
};
#define STATUS_SUCCESSFUL 0x0000
#define STATUS_INFORMATIONAL 0x0100
#define STATUS_REDIRECTION 0x0200
#define STATUS_CLIENT_ERROR 0x0400
#define STATUS_SERVER_ERROR 0x0500
#define STATUS_TYPE_MASK 0xFF00
#define SUCCESSFUL_OK 0x0000
#define SUCCESSFUL_OK_IGN_OR_SUB_ATTR 0x0001
#define SUCCESSFUL_OK_CONFLICTING_ATTR 0x0002
#define CLIENT_ERROR_BAD_REQUEST 0x0400
#define CLIENT_ERROR_FORBIDDEN 0x0401
#define CLIENT_ERROR_NOT_AUTHENTICATED 0x0402
#define CLIENT_ERROR_NOT_AUTHORIZED 0x0403
#define CLIENT_ERROR_NOT_POSSIBLE 0x0404
#define CLIENT_ERROR_TIMEOUT 0x0405
#define CLIENT_ERROR_NOT_FOUND 0x0406
#define CLIENT_ERROR_GONE 0x0407
#define CLIENT_ERROR_REQ_ENTITY_TOO_LRG 0x0408
#define CLIENT_ERROR_REQ_VALUE_TOO_LONG 0x0409
#define CLIENT_ERROR_DOC_FMT_NOT_SUPP 0x040A
#define CLIENT_ERROR_ATTR_OR_VAL_NOT_SUPP 0x040B
#define CLIENT_ERROR_URI_SCHEME_NOT_SUPP 0x040C
#define CLIENT_ERROR_CHARSET_NOT_SUPP 0x040D
#define CLIENT_ERROR_CONFLICTING_ATTRS 0x040E
#define SERVER_ERROR_INTERNAL_ERROR 0x0500
#define SERVER_ERROR_OPERATION_NOT_SUPP 0x0501
#define SERVER_ERROR_SERVICE_UNAVAIL 0x0502
#define SERVER_ERROR_VERSION_NOT_SUPP 0x0503
#define SERVER_ERROR_DEVICE_ERROR 0x0504
#define SERVER_ERROR_TEMPORARY_ERROR 0x0505
#define SERVER_ERROR_NOT_ACCEPTING_JOBS 0x0506
#define SERVER_ERROR_BUSY 0x0507
#define SERVER_ERROR_JOB_CANCELED 0x0508
static const value_string status_vals[] = {
{ SUCCESSFUL_OK, "Successful-OK" },
{ SUCCESSFUL_OK_IGN_OR_SUB_ATTR, "Successful-OK-Ignored-Or-Substituted-Attributes" },
{ SUCCESSFUL_OK_CONFLICTING_ATTR, "Successful-OK-Conflicting-Attributes" },
{ CLIENT_ERROR_BAD_REQUEST, "Client-Error-Bad-Request" },
{ CLIENT_ERROR_FORBIDDEN, "Client-Error-Forbidden" },
{ CLIENT_ERROR_NOT_AUTHENTICATED, "Client-Error-Not-Authenticated" },
{ CLIENT_ERROR_NOT_AUTHORIZED, "Client-Error-Not-Authorized" },
{ CLIENT_ERROR_NOT_POSSIBLE, "Client-Error-Not-Possible" },
{ CLIENT_ERROR_TIMEOUT, "Client-Error-Timeout" },
{ CLIENT_ERROR_NOT_FOUND, "Client-Error-Not-Found" },
{ CLIENT_ERROR_GONE, "Client-Error-Gone" },
{ CLIENT_ERROR_REQ_ENTITY_TOO_LRG, "Client-Error-Request-Entity-Too-Large" },
{ CLIENT_ERROR_REQ_VALUE_TOO_LONG, "Client-Error-Request-Value-Too-Long" },
{ CLIENT_ERROR_DOC_FMT_NOT_SUPP, "Client-Error-Document-Format-Not-Supported" },
{ CLIENT_ERROR_ATTR_OR_VAL_NOT_SUPP, "Client-Error-Attributes-Or-Values-Not-Supported" },
{ CLIENT_ERROR_URI_SCHEME_NOT_SUPP, "Client-Error-URI-Scheme-Not-Supported" },
{ CLIENT_ERROR_CHARSET_NOT_SUPP, "Client-Error-Charset-Not-Supported" },
{ CLIENT_ERROR_CONFLICTING_ATTRS, "Client-Error-Conflicting-Attributes" },
{ SERVER_ERROR_INTERNAL_ERROR, "Server-Error-Internal-Error" },
{ SERVER_ERROR_OPERATION_NOT_SUPP, "Server-Error-Operation-Not-Supported" },
{ SERVER_ERROR_SERVICE_UNAVAIL, "Server-Error-Service-Unavailable" },
{ SERVER_ERROR_VERSION_NOT_SUPP, "Server-Error-Version-Not-Supported" },
{ SERVER_ERROR_DEVICE_ERROR, "Server-Error-Device-Error" },
{ SERVER_ERROR_TEMPORARY_ERROR, "Server-Error-Temporary-Error" },
{ SERVER_ERROR_NOT_ACCEPTING_JOBS, "Server-Error-Not-Accepting-Jobs" },
{ SERVER_ERROR_BUSY, "Server-Error-Busy" },
{ SERVER_ERROR_JOB_CANCELED, "Server-Error-Job-Canceled" },
{ 0, NULL }
};
static void parse_attributes(const u_char *pd, int offset, frame_data *fd,
proto_tree *tree);
static proto_tree *add_integer_tree(proto_tree *tree, const u_char *pd,
int offset, guint name_length, guint value_length);
static void add_integer_value(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length);
static proto_tree *add_octetstring_tree(proto_tree *tree, const u_char *pd,
int offset, guint name_length, guint value_length);
static void add_octetstring_value(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length);
static proto_tree *add_charstring_tree(proto_tree *tree, const u_char *pd,
int offset, guint name_length, guint value_length);
static void add_charstring_value(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length);
static int add_value_head(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length);
void dissect_ipp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
proto_tree *ipp_tree;
proto_item *ti;
gboolean is_request = (pi.destport == 631);
guint16 status_code;
gchar *status_fmt;
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "IPP");
if (check_col(fd, COL_INFO)) {
if (is_request)
col_add_str(fd, COL_INFO, "IPP request");
else
col_add_str(fd, COL_INFO, "IPP response");
}
if (tree) {
ti = proto_tree_add_item(tree, proto_ipp, offset, END_OF_FRAME, NULL);
ipp_tree = proto_item_add_subtree(ti, ETT_IPP);
proto_tree_add_text(ipp_tree, offset, 2, "Version: %u.%u",
pd[offset], pd[offset + 1]);
offset += 2;
if (is_request) {
proto_tree_add_text(ipp_tree, offset, 2, "Operation-id: %s",
val_to_str(pntohs(&pd[offset]), operation_vals,
"Unknown (0x%04x)"));
} else {
status_code = pntohs(&pd[offset]);
switch (status_code & STATUS_TYPE_MASK) {
case STATUS_SUCCESSFUL:
status_fmt = "Successful (0x%04x)";
break;
case STATUS_INFORMATIONAL:
status_fmt = "Informational (0x%04x)";
break;
case STATUS_REDIRECTION:
status_fmt = "Redirection (0x%04x)";
break;
case STATUS_CLIENT_ERROR:
status_fmt = "Client error (0x%04x)";
break;
case STATUS_SERVER_ERROR:
status_fmt = "Server error (0x%04x)";
break;
default:
status_fmt = "Unknown (0x%04x)";
break;
}
proto_tree_add_text(ipp_tree, offset, 2, "Status-code: %s",
val_to_str(status_code, status_vals, status_fmt));
}
offset += 2;
proto_tree_add_text(ipp_tree, offset, 4, "Request ID: %u",
pntohl(&pd[offset]));
offset += 4;
parse_attributes(pd, offset, fd, ipp_tree);
}
}
#define TAG_TYPE(tag) ((tag) & 0xF0)
#define TAG_TYPE_DELIMITER 0x00
#define TAG_TYPE_INTEGER 0x20
#define TAG_TYPE_OCTETSTRING 0x30
#define TAG_TYPE_CHARSTRING 0x40
#define TAG_END_OF_ATTRIBUTES 0x03
#define TAG_INTEGER 0x21
#define TAG_BOOLEAN 0x22
#define TAG_ENUM 0x23
#define TAG_OCTETSTRING 0x30
#define TAG_DATETIME 0x31
#define TAG_RESOLUTION 0x32
#define TAG_RANGEOFINTEGER 0x33
#define TAG_TEXTWITHLANGUAGE 0x35
#define TAG_NAMEWITHLANGUAGE 0x36
#define TAG_TEXTWITHOUTLANGUAGE 0x41
#define TAG_NAMEWITHOUTLANGUAGE 0x42
#define TAG_KEYWORD 0x44
#define TAG_URI 0x45
#define TAG_URISCHEME 0x46
#define TAG_CHARSET 0x47
#define TAG_NATURALLANGUAGE 0x48
#define TAG_MIMEMEDIATYPE 0x49
static const value_string tag_vals[] = {
/* Delimiter tags */
{ 0x01, "Operation attributes" },
{ 0x02, "Job attributes" },
{ TAG_END_OF_ATTRIBUTES, "End of attributes" },
{ 0x04, "Printer attributes" },
{ 0x05, "Unsupported attributes" },
/* Value tags */
{ 0x10, "Unsupported" },
{ 0x12, "Unknown" },
{ 0x13, "No value" },
{ TAG_INTEGER, "Integer" },
{ TAG_BOOLEAN, "Boolean" },
{ TAG_ENUM, "Enum" },
{ TAG_OCTETSTRING, "Octet string" },
{ TAG_DATETIME, "Date/Time" },
{ TAG_RESOLUTION, "Resolution" },
{ TAG_RANGEOFINTEGER, "Range of integer" },
{ TAG_TEXTWITHLANGUAGE, "Text with language" },
{ TAG_NAMEWITHLANGUAGE, "Name with language" },
{ TAG_TEXTWITHOUTLANGUAGE, "Text without language" },
{ TAG_NAMEWITHOUTLANGUAGE, "Name without language" },
{ TAG_KEYWORD, "Keyword" },
{ TAG_URI, "URI" },
{ TAG_URISCHEME, "URI scheme" },
{ TAG_CHARSET, "Character set" },
{ TAG_NATURALLANGUAGE, "Natural language" },
{ TAG_MIMEMEDIATYPE, "MIME media type" },
{ 0, NULL }
};
static void
parse_attributes(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
guint8 tag;
gchar *tag_desc;
guint16 name_length, value_length;
proto_tree *as_tree = tree;
proto_item *tas = NULL;
proto_tree *attr_tree = tree;
while (IS_DATA_IN_FRAME(offset)) {
tag = pd[offset];
tag_desc = val_to_str(tag, tag_vals, "Reserved (0x%02x)");
if (TAG_TYPE(tag) == TAG_TYPE_DELIMITER) {
tas = proto_tree_add_text(tree, offset, 1,
"%s", tag_desc);
if (tag == TAG_END_OF_ATTRIBUTES) {
/*
* Put any non-delimiter tags after this
* one directly under the IPP tree
* (there shouldn't be any).
*/
as_tree = tree;
} else {
/*
* Create a new tree under this tag
* when we see a non-delimiter tag.
*/
as_tree = NULL;
}
attr_tree = tree;
offset++;
} else {
/*
* Value tag - get the name length.
*/
if (!BYTES_ARE_IN_FRAME(offset + 1, 2)) {
/*
* We ran past the end of the frame.
* Quit (we need to be able to handle
* stuff that crosses frames to do more)
*/
break;
}
name_length = pntohs(&pd[offset + 1]);
/*
* OK, get the value length.
*/
if (!BYTES_ARE_IN_FRAME(offset + 1 + 2, name_length)) {
/*
* We ran past the end of the frame.
* Quit (we need to be able to handle
* stuff that crosses frames to do more)
*/
break;
}
value_length = pntohs(&pd[offset + 1 + 2 + name_length]);
/*
* OK, does the value run past the end of the
* frame?
*/
if (!BYTES_ARE_IN_FRAME(offset + 1 + 2 + name_length + 2,
value_length)) {
/*
* We ran past the end of the frame.
* Quit (we need to be able to handle
* stuff that crosses frames to do more)
*/
break;
}
if (as_tree == NULL) {
/*
* OK, there's an attribute to hang
* under a delimiter tag, but we don't
* have a tree for that tag yet; create
* a tree.
*/
as_tree = proto_item_add_subtree(tas,
ETT_IPP_AS);
attr_tree = as_tree;
}
switch (TAG_TYPE(tag)) {
case TAG_TYPE_INTEGER:
if (name_length != 0) {
/*
* This is an attribute, not
* an additional value, so
* start a tree for it.
*/
attr_tree = add_integer_tree(as_tree,
pd, offset, name_length,
value_length);
}
add_integer_value(tag, tag_desc, attr_tree, pd,
offset, name_length, value_length);
break;
case TAG_TYPE_OCTETSTRING:
if (name_length != 0) {
/*
* This is an attribute, not
* an additional value, so
* start a tree for it.
*/
attr_tree = add_octetstring_tree(as_tree,
pd, offset, name_length,
value_length);
}
add_octetstring_value(tag, tag_desc,
attr_tree, pd, offset, name_length,
value_length);
break;
case TAG_TYPE_CHARSTRING:
if (name_length != 0) {
/*
* This is an attribute, not
* an additional value, so
* start a tree for it.
*/
attr_tree = add_charstring_tree(as_tree,
pd, offset, name_length,
value_length);
}
add_charstring_value(tag, tag_desc,
attr_tree, pd, offset, name_length,
value_length);
break;
}
offset += 1 + 2 + name_length + 2 + value_length;
}
}
}
static proto_tree *
add_integer_tree(proto_tree *tree, const u_char *pd, int offset,
guint name_length, guint value_length)
{
proto_item *ti;
if (value_length != 4) {
ti = proto_tree_add_text(tree, offset,
1 + 2 + name_length + 2 + value_length,
"%.*s: Invalid integer (length is %u, should be 4)",
name_length, &pd[offset + 1 + 2],
value_length);
} else {
ti = proto_tree_add_text(tree, offset,
1 + 2 + name_length + 2 + value_length,
"%.*s: %u",
name_length, &pd[offset + 1 + 2],
pntohl(&pd[1 + 2 + name_length + 2]));
}
return proto_item_add_subtree(ti, ETT_IPP_ATTR);
}
static void
add_integer_value(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length)
{
offset = add_value_head(tag, tag_desc, tree, pd, offset,
name_length, value_length);
if (value_length == 4) {
proto_tree_add_text(tree, offset, value_length,
"Value: %u", pntohl(&pd[1 + 2 + name_length + 2]));
}
}
static proto_tree *
add_octetstring_tree(proto_tree *tree, const u_char *pd, int offset,
guint name_length, guint value_length)
{
proto_item *ti;
ti = proto_tree_add_text(tree, offset,
1 + 2 + name_length + 2 + value_length,
"%.*s: %s",
name_length,
&pd[offset + 1 + 2]);
bytes_to_str(&pd[offset + 1 + 2 + name_length + 2], value_length);
return proto_item_add_subtree(ti, ETT_IPP_ATTR);
}
static void
add_octetstring_value(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length)
{
offset = add_value_head(tag, tag_desc, tree, pd, offset,
name_length, value_length);
proto_tree_add_text(tree, offset, value_length,
"Value: %s", bytes_to_str(&pd[offset], value_length));
}
static proto_tree *
add_charstring_tree(proto_tree *tree, const u_char *pd, int offset,
guint name_length, guint value_length)
{
proto_item *ti;
ti = proto_tree_add_text(tree, offset,
1 + 2 + name_length + 2 + value_length,
"%.*s: %.*s",
name_length, &pd[offset + 1 + 2],
value_length, &pd[offset + 1 + 2 + name_length + 2]);
return proto_item_add_subtree(ti, ETT_IPP_ATTR);
}
static void
add_charstring_value(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length)
{
offset = add_value_head(tag, tag_desc, tree, pd, offset,
name_length, value_length);
proto_tree_add_text(tree, offset, value_length,
"Value: %.*s", value_length, &pd[offset]);
}
static int
add_value_head(guint tag, gchar *tag_desc, proto_tree *tree,
const u_char *pd, int offset, guint name_length, guint value_length)
{
proto_tree_add_text(tree, offset, 1, "Tag: %s", tag_desc);
offset += 1;
proto_tree_add_text(tree, offset, 2, "Name length: %u",
name_length);
offset += 2;
if (name_length != 0) {
proto_tree_add_text(tree, offset, name_length,
"Name: %.*s", name_length, &pd[offset]);
}
offset += name_length;
proto_tree_add_text(tree, offset, 2, "Value length: %u",
value_length);
offset += 2;
return offset;
}
void
proto_register_ipp(void)
{
/* static hf_register_info hf[] = {
{ &variable,
{ "Name", "ipp.abbreviation", TYPE, VALS_POINTER }},
};*/
proto_ipp = proto_register_protocol("Internet Printing Protocol", "ipp");
/* proto_register_field_array(proto_ipp, hf, array_length(hf));*/
}

View File

@ -2,7 +2,7 @@
* Routines for the Internet Security Association and Key Management Protocol (ISAKMP)
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
*
* $Id: packet-isakmp.c,v 1.8 1999/08/26 07:34:41 guy Exp $
* $Id: packet-isakmp.c,v 1.9 1999/09/17 05:56:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -289,7 +289,7 @@ void dissect_isakmp(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_INFO, "%s", exchtype2str(hdr->exch_type));
if (pi.captured_len > offset && tree) {
if (IS_DATA_IN_FRAME(offset) && tree) {
proto_item * ti;
proto_tree * isakmp_tree;

View File

@ -2,7 +2,7 @@
* Routines for LPR and LPRng packet disassembly
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
* $Id: packet-lpd.c,v 1.9 1999/08/25 17:38:36 guy Exp $
* $Id: packet-lpd.c,v 1.10 1999/09/17 05:56:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -127,7 +127,7 @@ dissect_lpd(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
printer = strdup(&pd[offset]);
line_pos = printer;
curr_offset = offset;
while (pi.captured_len > curr_offset) {
while (IS_DATA_IN_FRAME(curr_offset)) {
newline = strchr(line_pos, '\n');
if (!newline) {
proto_tree_add_text(lpd_tree, curr_offset,

View File

@ -2,7 +2,7 @@
* Routines for the Point-to-Point Tunnelling Protocol (PPTP)
* Brad Robel-Forrest <brad.robel-forrest@watchguard.com>
*
* $Id: packet-pptp.c,v 1.4 1999/08/26 07:34:40 guy Exp $
* $Id: packet-pptp.c,v 1.5 1999/09/17 05:56:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -390,7 +390,7 @@ dissect_pptp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_INFO, "%s", cntrltype2str(cntrl_type));
if (pi.captured_len > offset && tree) {
if (IS_DATA_IN_FRAME(offset) && tree) {
guint16 msg_type;
proto_item * ti;
proto_tree * pptp_tree;

View File

@ -2,7 +2,7 @@
* Routines for smb packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
* $Id: packet-smb.c,v 1.24 1999/08/26 07:34:38 guy Exp $
* $Id: packet-smb.c,v 1.25 1999/09/17 05:56:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -1444,7 +1444,7 @@ dissect_negprot_smb(const u_char *pd, int offset, frame_data *fd, proto_tree *tr
}
while (pi.captured_len > offset) {
while (IS_DATA_IN_FRAME(offset)) {
const char *str;
if (tree) {

View File

@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
* $Id: packet-tcp.c,v 1.32 1999/08/28 08:31:27 guy Exp $
* $Id: packet-tcp.c,v 1.33 1999/09/17 05:56:56 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -489,7 +489,8 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
} else if (PORT_IS(TCP_PORT_PPTP)) {
pi.match_port = TCP_PORT_PPTP;
dissect_pptp(pd, offset, fd, tree);
} else if (PORT_IS(TCP_PORT_HTTP) || PORT_IS(TCP_ALT_PORT_HTTP))
} else if (PORT_IS(TCP_PORT_HTTP) || PORT_IS(TCP_ALT_PORT_HTTP)
|| PORT_IS(631))
dissect_http(pd, offset, fd, tree);
else if (PORT_IS(TCP_PORT_NBSS)) {
pi.match_port = TCP_PORT_NBSS;

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.99 1999/09/14 08:06:23 guy Exp $
* $Id: packet.h,v 1.100 1999/09/17 05:56:57 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -72,6 +72,13 @@
* See dissect_data() for an example.
*/
#define END_OF_FRAME (pi.captured_len - offset)
/* Check whether the "len" bytes of data starting at "offset" is
* entirely inside the captured data for this packet. */
#define BYTES_ARE_IN_FRAME(offset, len) ((offset) + (len) <= pi.captured_len)
/* Check whether there's any data at all starting at "offset". */
#define IS_DATA_IN_FRAME(offset) ((offset) < pi.captured_len)
/* To pass one of two strings, singular or plural */
#define plurality(d,s,p) ((d) == 1 ? (s) : (p))
@ -330,6 +337,9 @@ enum {
ETT_ATM_LANE_LC_LAN_DEST_RD,
ETT_MP,
ETT_MP_FLAGS,
ETT_IPP,
ETT_IPP_AS,
ETT_IPP_ATTR,
NUM_TREE_TYPES /* last item number plus one */
};
@ -440,6 +450,7 @@ void dissect_icmp(const u_char *, int, frame_data *, proto_tree *);
void dissect_icmpv6(const u_char *, int, frame_data *, proto_tree *);
void dissect_igmp(const u_char *, int, frame_data *, proto_tree *);
void dissect_ip(const u_char *, int, frame_data *, proto_tree *);
void dissect_ipp(const u_char *, int, frame_data *, proto_tree *);
void dissect_ipv6(const u_char *, int, frame_data *, proto_tree *);
void dissect_ipx(const u_char *, int, frame_data *, proto_tree *);
void dissect_llc(const u_char *, int, frame_data *, proto_tree *);

View File

@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
* $Id: proto.c,v 1.27 1999/09/15 06:13:20 gram Exp $
* $Id: proto.c,v 1.28 1999/09/17 05:56:58 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -108,6 +108,7 @@ void proto_register_icmpv6(void);
void proto_register_icp(void);
void proto_register_igmp(void);
void proto_register_ip(void);
void proto_register_ipp(void);
void proto_register_ipsec(void);
void proto_register_ipv6(void);
void proto_register_ipx(void);
@ -214,6 +215,7 @@ proto_init(void)
proto_register_icp();
proto_register_igmp();
proto_register_ip();
proto_register_ipp();
proto_register_ipsec();
proto_register_ipv6();
proto_register_ipx();