1999-10-14 03:50:51 +00:00
|
|
|
/* ipproto.c
|
|
|
|
* Routines for converting IPv4 protocol/v6 nxthdr field into string
|
|
|
|
*
|
2003-11-24 21:42:13 +00:00
|
|
|
* $Id: ipproto.c,v 1.24 2003/11/24 21:42:13 guy Exp $
|
1999-10-14 03:50:51 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
There is really no need to have the BGP dissector and the LDP dissector
have two independent "value_string" tables mapping RFC 1700 address
family numbers to names, nor is there any need to have the BGP dissector
and the PIM dissector have two independent sets of #defines for RFC 1700
address family numbers; put a single "value_string" table in "afn.c" and
put a declaration of it, and #defines for the address family numbers,
into "afn.h", and have the dissectors use that.
Move the #define for PGM into "ipproto.h", and add an entry for it in
the "value_string" table in "ipproto.c".
Have the PGM dissector use the standard Ethereal mechanisms for
resolving addresses, and have it use "value_string" tables for mapping
option types, the OPX bits, and packet types to strings. Use
"bytes_to_str()" to turn byte arrays into strings of hex digits. Pass
the packet type string to "dissect_pgmopts()" as an argument, rather
than making it a global. Don't use "proto_tree_add_XXX_format" routines
if you can possibly just use "proto_tree_add_XXX"; give various fields
the correct radix and type, and VALS() strings if necessary, to make
that happen (and to make filtering on them more pleasant). Put the
type, length, and total length of the options into the protocol tree as
separate fields. Don't have separate type, length, and OPX fields for
every type of option; one field will suffice. Don't format a string
with "sprintf()" and then pass that string to "col_add_fstr()" with a
format of "%s" and the string as an argument - "col_add_fstr()" can
format strings itself (that's what the "f" stands for). Don't byte-swap
and then un-byte-swap IPv4 address fields in the header, just leave them
network byte order to start with. Use the correct fields for
"proto_tree_add_XXX", rather than using the same field multiple times.
Quit early if an address family identifier isn't AFNUM_INET, as that
means the structure we use to dissect the header doesn't match the
actual header.
svn path=/trunk/; revision=3761
2001-07-21 10:27:13 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-10-14 03:50:51 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-10-14 03:50:51 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-10-14 03:50:51 +00:00
|
|
|
* 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.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-10-14 03:50:51 +00:00
|
|
|
* 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_NETDB_H
|
|
|
|
# include <netdb.h>
|
|
|
|
#endif
|
|
|
|
|
2000-08-11 13:37:21 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2001-04-17 06:29:14 +00:00
|
|
|
#include "ipproto.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/resolv.h>
|
1999-10-14 03:50:51 +00:00
|
|
|
#include "packet-ip.h"
|
|
|
|
|
2002-08-30 02:11:16 +00:00
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
1999-10-14 03:50:51 +00:00
|
|
|
static const value_string ipproto_val[] = {
|
|
|
|
#if 0
|
|
|
|
{ IP_PROTO_IP, "IPv4" },
|
|
|
|
#endif
|
|
|
|
{ IP_PROTO_HOPOPTS, "IPv6 hop-by-hop option" },
|
|
|
|
{ IP_PROTO_ICMP, "ICMP" },
|
|
|
|
{ IP_PROTO_IGMP, "IGMP" },
|
|
|
|
{ IP_PROTO_GGP, "GGP" },
|
|
|
|
{ IP_PROTO_IPIP, "IPIP" },
|
2001-03-05 20:11:36 +00:00
|
|
|
#if 0
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_IPV4, "IPv4" },
|
2001-03-05 20:11:36 +00:00
|
|
|
#endif
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_STREAM, "Stream" },
|
|
|
|
{ IP_PROTO_TCP, "TCP" },
|
|
|
|
{ IP_PROTO_CBT, "CBT" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_EGP, "EGP" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_IGP, "IGRP" },
|
|
|
|
{ IP_PROTO_BBN_RCC, "BBN RCC" },
|
|
|
|
{ IP_PROTO_NVPII, "Network Voice" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_PUP, "PUP" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_ARGUS, "ARGUS" },
|
|
|
|
{ IP_PROTO_EMCON, "EMCON" },
|
|
|
|
{ IP_PROTO_XNET, "XNET" },
|
|
|
|
{ IP_PROTO_CHAOS, "CHAOS" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_UDP, "UDP" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_MUX, "Multiplex" },
|
|
|
|
{ IP_PROTO_DCNMEAS, "DCN Measurement" },
|
|
|
|
{ IP_PROTO_HMP, "Host Monitoring" },
|
|
|
|
{ IP_PROTO_PRM, "Packet radio" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_IDP, "IDP" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_TRUNK1, "Trunk-1" },
|
|
|
|
{ IP_PROTO_TRUNK2, "Trunk-2" },
|
|
|
|
{ IP_PROTO_LEAF1, "Leaf-1" },
|
|
|
|
{ IP_PROTO_LEAF2, "Leaf-2" },
|
|
|
|
{ IP_PROTO_RDP, "Reliable Data" },
|
|
|
|
{ IP_PROTO_IRT, "IRT" },
|
|
|
|
{ IP_PROTO_TP, "ISO TP4" },
|
|
|
|
{ IP_PROTO_BULK, "Bulk Data" },
|
|
|
|
{ IP_PROTO_MFE_NSP, "MFE NSP" },
|
|
|
|
{ IP_PROTO_MERIT, "Merit Internodal" },
|
|
|
|
{ IP_PROTO_SEP, "Sequential Exchange" },
|
|
|
|
{ IP_PROTO_3PC, "3rd Party Connect" },
|
|
|
|
{ IP_PROTO_IDPR, "Interdomain routing" },
|
|
|
|
{ IP_PROTO_XTP, "XTP" },
|
|
|
|
{ IP_PROTO_DDP, "Datagram delivery"},
|
|
|
|
{ IP_PROTO_CMTP, "Control Message" },
|
|
|
|
{ IP_PROTO_TPPP, "TP++" },
|
|
|
|
{ IP_PROTO_IL, "IL" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_IPV6, "IPv6" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_SDRP, "Source demand routing" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_ROUTING, "IPv6 routing" },
|
2000-03-21 05:15:12 +00:00
|
|
|
{ IP_PROTO_FRAGMENT,"IPv6 fragment" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_IDRP, "IDRP" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_RSVP, "RSVP" },
|
|
|
|
{ IP_PROTO_GRE, "GRE" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_MHRP, "MHRP" },
|
|
|
|
{ IP_PROTO_BNA, "BNA" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_ESP, "ESP" },
|
|
|
|
{ IP_PROTO_AH, "AH" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_INSLP, "INSLP" },
|
|
|
|
{ IP_PROTO_SWIPE, "SWIPE" },
|
|
|
|
{ IP_PROTO_NARP, "NBMA ARP"},
|
|
|
|
{ IP_PROTO_TLSP, "TLSP Kryptonet" },
|
|
|
|
{ IP_PROTO_SKIP, "SKIP" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_ICMPV6, "ICMPv6" },
|
|
|
|
{ IP_PROTO_NONE, "IPv6 no next header" },
|
2000-03-21 05:15:12 +00:00
|
|
|
{ IP_PROTO_DSTOPTS, "IPv6 destination option" },
|
2003-11-24 21:42:13 +00:00
|
|
|
{ IP_PROTO_MIPV6_OLD, "Mobile IPv6 (old)" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_SATEXPAK,"SATNET EXPAK" },
|
|
|
|
{ IP_PROTO_KRYPTOLAN, "Kryptolan" },
|
|
|
|
{ IP_PROTO_RVD, "Remote Virtual Disk" },
|
|
|
|
{ IP_PROTO_IPPC, "IPPC" },
|
|
|
|
{ IP_PROTO_SATMON, "SATNET Monitoring" },
|
|
|
|
{ IP_PROTO_VISA, "VISA" },
|
|
|
|
{ IP_PROTO_IPCV, "IPCV" },
|
|
|
|
{ IP_PROTO_CPNX, "CPNX" },
|
|
|
|
{ IP_PROTO_CPHB, "CPHB" },
|
|
|
|
{ IP_PROTO_WSN, "Wang Span" },
|
|
|
|
{ IP_PROTO_PVP, "Packet Video" },
|
|
|
|
{ IP_PROTO_BRSATMON,"Backroom SATNET Mon" },
|
|
|
|
{ IP_PROTO_SUNND, "Sun ND Protocol" },
|
|
|
|
{ IP_PROTO_WBMON, "Wideband Mon" },
|
|
|
|
{ IP_PROTO_WBEXPAK, "Wideband Expak" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_EON, "EON" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_VMTP, "VMTP" },
|
|
|
|
{ IP_PROTO_SVMTP, "Secure VMTP" },
|
|
|
|
{ IP_PROTO_VINES, "VINES" },
|
|
|
|
{ IP_PROTO_TTP, "TTP" },
|
|
|
|
{ IP_PROTO_NSFNETIGP,"NSFNET IGP" },
|
|
|
|
{ IP_PROTO_DGP, "Dissimilar Gateway" },
|
|
|
|
{ IP_PROTO_TCF, "TCF" },
|
|
|
|
{ IP_PROTO_EIGRP, "EIGRP" },
|
|
|
|
{ IP_PROTO_OSPF, "OSPF IGP" },
|
|
|
|
{ IP_PROTO_SPRITE, "Sprite RPC" },
|
|
|
|
{ IP_PROTO_LARP, "Locus ARP" },
|
|
|
|
{ IP_PROTO_MTP, "Multicast Transport" },
|
|
|
|
{ IP_PROTO_AX25, "AX.25 Frames" },
|
|
|
|
{ IP_PROTO_IPINIP, "IP in IP" },
|
|
|
|
{ IP_PROTO_MICP, "MICP" },
|
|
|
|
{ IP_PROTO_SCCCP, "Semaphore" },
|
|
|
|
{ IP_PROTO_ETHERIP, "Ether in IP" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_ENCAP, "ENCAP" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_GMTP, "GMTP" },
|
|
|
|
{ IP_PROTO_IFMP, "Ipsilon Flow" },
|
|
|
|
{ IP_PROTO_PNNI, "PNNI over IP" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ IP_PROTO_PIM, "PIM" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_ARIS, "ARIS" },
|
|
|
|
{ IP_PROTO_SCPS, "SCPS" },
|
|
|
|
{ IP_PROTO_QNX, "QNX" },
|
|
|
|
{ IP_PROTO_AN, "Active Networks" },
|
1999-10-15 05:30:43 +00:00
|
|
|
{ IP_PROTO_IPCOMP, "IPComp" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_SNP, "Sitara Networks" },
|
|
|
|
{ IP_PROTO_COMPAQ, "Compaq Peer" },
|
|
|
|
{ IP_PROTO_IPX, "IPX IN IP" },
|
1999-11-21 14:43:53 +00:00
|
|
|
{ IP_PROTO_VRRP, "VRRP" },
|
There is really no need to have the BGP dissector and the LDP dissector
have two independent "value_string" tables mapping RFC 1700 address
family numbers to names, nor is there any need to have the BGP dissector
and the PIM dissector have two independent sets of #defines for RFC 1700
address family numbers; put a single "value_string" table in "afn.c" and
put a declaration of it, and #defines for the address family numbers,
into "afn.h", and have the dissectors use that.
Move the #define for PGM into "ipproto.h", and add an entry for it in
the "value_string" table in "ipproto.c".
Have the PGM dissector use the standard Ethereal mechanisms for
resolving addresses, and have it use "value_string" tables for mapping
option types, the OPX bits, and packet types to strings. Use
"bytes_to_str()" to turn byte arrays into strings of hex digits. Pass
the packet type string to "dissect_pgmopts()" as an argument, rather
than making it a global. Don't use "proto_tree_add_XXX_format" routines
if you can possibly just use "proto_tree_add_XXX"; give various fields
the correct radix and type, and VALS() strings if necessary, to make
that happen (and to make filtering on them more pleasant). Put the
type, length, and total length of the options into the protocol tree as
separate fields. Don't have separate type, length, and OPX fields for
every type of option; one field will suffice. Don't format a string
with "sprintf()" and then pass that string to "col_add_fstr()" with a
format of "%s" and the string as an argument - "col_add_fstr()" can
format strings itself (that's what the "f" stands for). Don't byte-swap
and then un-byte-swap IPv4 address fields in the header, just leave them
network byte order to start with. Use the correct fields for
"proto_tree_add_XXX", rather than using the same field multiple times.
Quit early if an address family identifier isn't AFNUM_INET, as that
means the structure we use to dissect the header doesn't match the
actual header.
svn path=/trunk/; revision=3761
2001-07-21 10:27:13 +00:00
|
|
|
{ IP_PROTO_PGM, "PGM" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_L2TP, "Layer 2 Tunneling" },
|
|
|
|
{ IP_PROTO_DDX, "DDX" },
|
|
|
|
{ IP_PROTO_IATP, "IATP" },
|
|
|
|
{ IP_PROTO_STP, "STP" },
|
|
|
|
{ IP_PROTO_SRP, "SpectraLink" },
|
|
|
|
{ IP_PROTO_UTI, "UTI" },
|
|
|
|
{ IP_PROTO_SMP, "SMP" },
|
|
|
|
{ IP_PROTO_SM, "SM" },
|
|
|
|
{ IP_PROTO_PTP, "PTP" },
|
|
|
|
{ IP_PROTO_ISIS, "ISIS over IP" },
|
|
|
|
{ IP_PROTO_FIRE, "FIRE" },
|
|
|
|
{ IP_PROTO_CRTP, "CRTP" },
|
|
|
|
{ IP_PROTO_CRUDP, "CRUDP" },
|
|
|
|
{ IP_PROTO_SSCOPMCE,"SSCOPMCE" },
|
|
|
|
{ IP_PROTO_IPLT, "IPLT" },
|
|
|
|
{ IP_PROTO_SPS, "Secure Packet" },
|
|
|
|
{ IP_PROTO_PIPE, "PIPE" },
|
2000-05-26 21:54:59 +00:00
|
|
|
{ IP_PROTO_SCTP, "SCTP" },
|
2003-08-07 21:08:07 +00:00
|
|
|
{ IP_PROTO_FC, "Fibre Channel" },
|
|
|
|
{ IP_PROTO_RSVPE2EI,"RSVP E2EI" },
|
2003-11-24 21:42:13 +00:00
|
|
|
{ IP_PROTO_MIPV6, "Mobile IPv6" },
|
2003-11-02 22:12:35 +00:00
|
|
|
{ IP_PROTO_NCS_HEARTBEAT,"Novell NCS Heartbeat" },
|
1999-10-14 03:50:51 +00:00
|
|
|
{ 0, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *ipprotostr(int proto) {
|
|
|
|
static char buf[128];
|
|
|
|
const char *s;
|
|
|
|
#ifdef HAVE_GETPROTOBYNUMBER
|
|
|
|
struct protoent *pe;
|
|
|
|
#endif
|
|
|
|
|
1999-10-22 08:02:21 +00:00
|
|
|
if ((s = match_strval(proto, ipproto_val)) != NULL)
|
1999-10-14 03:50:51 +00:00
|
|
|
goto ok;
|
|
|
|
|
|
|
|
#ifdef HAVE_GETPROTOBYNUMBER
|
2002-01-13 20:35:12 +00:00
|
|
|
/*
|
|
|
|
* XXX - have another flag for resolving network-layer
|
|
|
|
* protocol names?
|
|
|
|
*/
|
|
|
|
if (g_resolv_flags != 0) {
|
1999-10-14 03:50:51 +00:00
|
|
|
pe = getprotobynumber(proto);
|
|
|
|
if (pe) {
|
|
|
|
s = pe->p_name;
|
|
|
|
goto ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
s = "Unknown";
|
|
|
|
|
|
|
|
ok:
|
|
|
|
snprintf(buf, sizeof(buf), "%s", s);
|
|
|
|
return buf;
|
|
|
|
}
|