1999-03-23 03:14:46 +00:00
|
|
|
/* packet-ip.h
|
|
|
|
* Definitions for IP packet disassembly structures and routines
|
|
|
|
*
|
2001-03-05 20:11:36 +00:00
|
|
|
* $Id: packet-ip.h,v 1.18 2001/03/05 20:11:36 guy Exp $
|
1999-03-23 03:14:46 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __PACKET_IP_H__
|
|
|
|
#define __PACKET_IP_H__
|
|
|
|
|
2000-02-15 21:06:58 +00:00
|
|
|
void capture_ip(const u_char *, int, packet_counts *);
|
|
|
|
|
1999-03-28 18:32:03 +00:00
|
|
|
#define IP_PROTO_IP 0 /* dummy for IP */
|
|
|
|
#define IP_PROTO_HOPOPTS 0 /* IP6 hop-by-hop options */
|
|
|
|
#define IP_PROTO_ICMP 1 /* control message protocol */
|
|
|
|
#define IP_PROTO_IGMP 2 /* group mgmt protocol */
|
|
|
|
#define IP_PROTO_GGP 3 /* gateway^2 (deprecated) */
|
|
|
|
#define IP_PROTO_IPIP 4 /* IP inside IP */
|
|
|
|
#define IP_PROTO_IPV4 4 /* IP header */
|
|
|
|
#define IP_PROTO_TCP 6 /* tcp */
|
|
|
|
#define IP_PROTO_EGP 8 /* exterior gateway protocol */
|
2001-03-05 20:11:36 +00:00
|
|
|
#define IP_PROTO_IGRP 9
|
1999-03-28 18:32:03 +00:00
|
|
|
#define IP_PROTO_PUP 12 /* pup */
|
|
|
|
#define IP_PROTO_UDP 17 /* user datagram protocol */
|
|
|
|
#define IP_PROTO_IDP 22 /* xns idp */
|
|
|
|
#define IP_PROTO_TP 29 /* tp-4 w/ class negotiation */
|
|
|
|
#define IP_PROTO_IPV6 41 /* IP6 header */
|
|
|
|
#define IP_PROTO_ROUTING 43 /* IP6 routing header */
|
|
|
|
#define IP_PROTO_FRAGMENT 44 /* IP6 fragmentation header */
|
1999-06-11 16:45:02 +00:00
|
|
|
#define IP_PROTO_RSVP 46 /* Resource ReSerVation protocol */
|
1999-06-11 15:30:55 +00:00
|
|
|
#define IP_PROTO_GRE 47 /* GRE */
|
1999-03-28 18:32:03 +00:00
|
|
|
#define IP_PROTO_ESP 50 /* ESP */
|
|
|
|
#define IP_PROTO_AH 51 /* AH */
|
|
|
|
#define IP_PROTO_ICMPV6 58 /* ICMP6 */
|
|
|
|
#define IP_PROTO_NONE 59 /* IP6 no next header */
|
|
|
|
#define IP_PROTO_DSTOPTS 60 /* IP6 no next header */
|
|
|
|
#define IP_PROTO_EON 80 /* ISO cnlp */
|
2000-01-20 21:34:16 +00:00
|
|
|
#define IP_PROTO_VINES 83 /* Vines over raw IP */
|
|
|
|
#define IP_PROTO_EIGRP 88
|
1999-03-28 18:32:03 +00:00
|
|
|
#define IP_PROTO_OSPF 89
|
|
|
|
#define IP_PROTO_ENCAP 98 /* encapsulation header */
|
|
|
|
#define IP_PROTO_PIM 103 /* Protocol Independent Mcast */
|
1999-10-15 05:30:43 +00:00
|
|
|
#define IP_PROTO_IPCOMP 108 /* IP payload compression */
|
1999-11-21 14:43:53 +00:00
|
|
|
#define IP_PROTO_VRRP 112 /* Virtual Router Redundancy Protocol */
|
2000-05-26 21:54:59 +00:00
|
|
|
#define IP_PROTO_SCTP 132 /* Stream Control Transmission Protocol */
|
1999-03-28 18:32:03 +00:00
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
typedef enum {
|
|
|
|
NO_LENGTH, /* option has no data, hence no length */
|
|
|
|
FIXED_LENGTH, /* option always has the same length */
|
|
|
|
VARIABLE_LENGTH /* option is variable-length - optlen is minimum */
|
|
|
|
} opt_len_type;
|
|
|
|
|
|
|
|
/* Member of table of IP or TCP options. */
|
1999-08-28 08:31:28 +00:00
|
|
|
typedef struct ip_tcp_opt {
|
1999-03-23 03:14:46 +00:00
|
|
|
int optcode; /* code for option */
|
1999-11-16 11:44:20 +00:00
|
|
|
char *name; /* name of option */
|
|
|
|
int *subtree_index; /* pointer to subtree index for option */
|
1999-03-23 03:14:46 +00:00
|
|
|
opt_len_type len_type; /* type of option length field */
|
|
|
|
int optlen; /* value length should be (minimum if VARIABLE) */
|
Add a "col_clear()" routine, to clear a column; it appears (and it
doesn't just seem to be a profiling artifact) that, at least on FreeBSD
3.4, it's significantly more efficient to clear out a column by stuffing
a '\0' into the first byte of the column data than to do so by copying a
null string (I guess when copying one byte, the fixed overhead of the
procedure call and of "strcpy()" is significant).
Have the TCP dissector set the Protocol column, and clear the Info
column, before doing anything that might cause an exception to be
thrown, so that if we *do* get an exception thrown, the frame at least
shows up as TCP.
Instead of, in the TCP dissector, constructing a string and then
stuffing it into the Info column, just append to the Info column, which
avoids one string copy.
Pass a "frame_data" pointer to dissectors for TCP and IP (and PPP)
options, so they can use it to append to the Info column.
svn path=/trunk/; revision=2744
2000-12-04 06:37:46 +00:00
|
|
|
void (*dissect)(const struct ip_tcp_opt *, tvbuff_t *, int, guint,
|
|
|
|
frame_data *, proto_tree *);
|
1999-03-23 03:14:46 +00:00
|
|
|
/* routine to dissect option */
|
|
|
|
} ip_tcp_opt;
|
|
|
|
|
|
|
|
/* Routine to dissect IP or TCP options. */
|
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors.
Register the IP dissector and have dissectors that call it directly
(rather than through a port table) call it through a handle.
Add a routine "tvb_set_reported_length()" which a dissector can use if
it was handed a tvbuff that contains more data than is actually in its
part of the packet - for example, handing a padded Ethernet frame to IP;
the routine sets the reported length of the tvbuff (and also adjusts the
actual length, as appropriate). Then use it in IP.
Given that, "ethertype()" can determine how much of the Ethernet frame
was actually part of an IP datagram (and can do the same for other
protocols under Ethernet that use "tvb_set_reported_length()"; have it
return the actual length, and have "dissect_eth()" and "dissect_vlan()"
use that to mark trailer data in Ethernet II frames as well as in 802.3
frames.
svn path=/trunk/; revision=2658
2000-11-18 10:38:33 +00:00
|
|
|
void dissect_ip_tcp_options(tvbuff_t *, int, guint,
|
Add a "col_clear()" routine, to clear a column; it appears (and it
doesn't just seem to be a profiling artifact) that, at least on FreeBSD
3.4, it's significantly more efficient to clear out a column by stuffing
a '\0' into the first byte of the column data than to do so by copying a
null string (I guess when copying one byte, the fixed overhead of the
procedure call and of "strcpy()" is significant).
Have the TCP dissector set the Protocol column, and clear the Info
column, before doing anything that might cause an exception to be
thrown, so that if we *do* get an exception thrown, the frame at least
shows up as TCP.
Instead of, in the TCP dissector, constructing a string and then
stuffing it into the Info column, just append to the Info column, which
avoids one string copy.
Pass a "frame_data" pointer to dissectors for TCP and IP (and PPP)
options, so they can use it to append to the Info column.
svn path=/trunk/; revision=2744
2000-12-04 06:37:46 +00:00
|
|
|
const ip_tcp_opt *, int, int, frame_data *, proto_tree *);
|
1999-03-23 03:14:46 +00:00
|
|
|
|
2000-04-20 07:05:58 +00:00
|
|
|
/* Dissector table for "ip.proto"; used by IPv6 as well as IPv4 */
|
2000-04-25 08:55:11 +00:00
|
|
|
extern dissector_table_t ip_dissector_table;
|
2000-04-20 07:05:58 +00:00
|
|
|
|
1999-03-23 03:14:46 +00:00
|
|
|
#endif
|