2 * Routines for converting IPv4 protocol/v6 nxthdr field into string
4 * $Id: ipproto.c,v 1.17 2002/01/21 07:36:31 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
39 #ifdef NEED_SNPRINTF_H
40 # include "snprintf.h"
44 #include <epan/packet.h>
45 #include <epan/resolv.h>
46 #include "packet-ip.h"
48 static const value_string ipproto_val[] = {
49 { IP_PROTO_ICMP, "ICMP" },
50 { IP_PROTO_IGMP, "IGMP" },
51 { IP_PROTO_EIGRP, "EIGRP" },
52 { IP_PROTO_IGRP, "IGRP" },
53 { IP_PROTO_TCP, "TCP" },
54 { IP_PROTO_UDP, "UDP" },
55 { IP_PROTO_OSPF, "OSPF" },
57 { IP_PROTO_IP, "IPv4" },
59 { IP_PROTO_HOPOPTS, "IPv6 hop-by-hop option" },
60 { IP_PROTO_ICMP, "ICMP" },
61 { IP_PROTO_IGMP, "IGMP" },
62 { IP_PROTO_GGP, "GGP" },
63 { IP_PROTO_IPIP, "IPIP" },
65 { IP_PROTO_IPV4, "IPv4" },
67 { IP_PROTO_EGP, "EGP" },
68 { IP_PROTO_PUP, "PUP" },
69 { IP_PROTO_UDP, "UDP" },
70 { IP_PROTO_IDP, "IDP" },
71 { IP_PROTO_TP, "TP" },
72 { IP_PROTO_IPV6, "IPv6" },
73 { IP_PROTO_ROUTING, "IPv6 routing" },
74 { IP_PROTO_FRAGMENT,"IPv6 fragment" },
75 { IP_PROTO_RSVP, "RSVP" },
76 { IP_PROTO_GRE, "GRE" },
77 { IP_PROTO_ESP, "ESP" },
78 { IP_PROTO_AH, "AH" },
79 { IP_PROTO_ICMPV6, "ICMPv6" },
80 { IP_PROTO_NONE, "IPv6 no next header" },
81 { IP_PROTO_DSTOPTS, "IPv6 destination option" },
82 { IP_PROTO_EON, "EON" },
83 { IP_PROTO_OSPF, "OSPF" },
84 { IP_PROTO_ENCAP, "ENCAP" },
85 { IP_PROTO_PIM, "PIM" },
86 { IP_PROTO_IPCOMP, "IPComp" },
87 { IP_PROTO_VRRP, "VRRP" },
88 { IP_PROTO_VINES, "VINES" },
89 { IP_PROTO_PGM, "PGM" },
90 { IP_PROTO_SCTP, "SCTP" },
94 const char *ipprotostr(int proto) {
97 #ifdef HAVE_GETPROTOBYNUMBER
101 if ((s = match_strval(proto, ipproto_val)) != NULL)
104 #ifdef HAVE_GETPROTOBYNUMBER
106 * XXX - have another flag for resolving network-layer
109 if (g_resolv_flags != 0) {
110 pe = getprotobynumber(proto);
121 snprintf(buf, sizeof(buf), "%s", s);