2 * Routines for converting IPv4 protocol/v6 nxthdr field into string
4 * $Id: ipproto.c,v 1.9 2000/08/11 13:35:31 deniel Exp $
6 * Gilbert Ramirez <gram@xiexie.org>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@zing.org>
10 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
42 #ifdef NEED_SNPRINTF_H
43 # include "snprintf.h"
50 #include "packet-ip.h"
51 #include "packet-ipv6.h"
53 static const value_string ipproto_val[] = {
54 { IP_PROTO_ICMP, "ICMP" },
55 { IP_PROTO_IGMP, "IGMP" },
56 { IP_PROTO_EIGRP, "IGRP/EIGRP" },
57 { IP_PROTO_TCP, "TCP" },
58 { IP_PROTO_UDP, "UDP" },
59 { IP_PROTO_OSPF, "OSPF" },
61 { IP_PROTO_IP, "IPv4" },
63 { IP_PROTO_HOPOPTS, "IPv6 hop-by-hop option" },
64 { IP_PROTO_ICMP, "ICMP" },
65 { IP_PROTO_IGMP, "IGMP" },
66 { IP_PROTO_GGP, "GGP" },
67 { IP_PROTO_IPIP, "IPIP" },
68 { IP_PROTO_IPV4, "IPv4" },
69 { IP_PROTO_TCP, "TCP" },
70 { IP_PROTO_EGP, "EGP" },
71 { IP_PROTO_PUP, "PUP" },
72 { IP_PROTO_UDP, "UDP" },
73 { IP_PROTO_IDP, "IDP" },
74 { IP_PROTO_TP, "TP" },
75 { IP_PROTO_IPV6, "IPv6" },
76 { IP_PROTO_ROUTING, "IPv6 routing" },
77 { IP_PROTO_FRAGMENT,"IPv6 fragment" },
78 { IP_PROTO_RSVP, "RSVP" },
79 { IP_PROTO_GRE, "GRE" },
80 { IP_PROTO_ESP, "ESP" },
81 { IP_PROTO_AH, "AH" },
82 { IP_PROTO_ICMPV6, "ICMPv6" },
83 { IP_PROTO_NONE, "IPv6 no next header" },
84 { IP_PROTO_DSTOPTS, "IPv6 destination option" },
85 { IP_PROTO_EON, "EON" },
86 { IP_PROTO_OSPF, "OSPF" },
87 { IP_PROTO_ENCAP, "ENCAP" },
88 { IP_PROTO_PIM, "PIM" },
89 { IP_PROTO_IPCOMP, "IPComp" },
90 { IP_PROTO_VRRP, "VRRP" },
91 { IP_PROTO_VINES, "VINES" },
92 { IP_PROTO_SCTP, "SCTP" },
96 const char *ipprotostr(int proto) {
99 #ifdef HAVE_GETPROTOBYNUMBER
103 if ((s = match_strval(proto, ipproto_val)) != NULL)
106 #ifdef HAVE_GETPROTOBYNUMBER
107 if (g_resolving_actif) {
108 pe = getprotobynumber(proto);
119 snprintf(buf, sizeof(buf), "%s", s);