]>
The Tcpdump Group git mirrors - tcpdump/blob - print-ip-demux.c
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 /* \summary: IPv4/IPv6 payload printer */
26 #include "netdissect-stdinc.h"
28 #include "netdissect.h"
29 #include "addrtoname.h"
36 ip_demux_print(netdissect_options
*ndo
,
38 u_int length
, u_int ver
, int fragmented
, u_int ttl_hl
,
39 uint8_t nh
, const u_char
*iph
)
50 if (!ND_TTEST_1(bp
)) {
51 ndo
->ndo_protocol
= "ah";
56 advance
= ah_print(ndo
, bp
);
65 esp_print(ndo
, bp
, length
, iph
, ver
, fragmented
, ttl_hl
);
67 * Either this has decrypted the payload and
68 * printed it, in which case there's nothing more
69 * to do, or it hasn't, in which case there's
77 ipcomp_print(ndo
, bp
);
79 * Either this has decompressed the payload and
80 * printed it, in which case there's nothing more
81 * to do, or it hasn't, in which case there's
88 sctp_print(ndo
, bp
, iph
, length
);
92 dccp_print(ndo
, bp
, iph
, length
);
96 tcp_print(ndo
, bp
, length
, iph
, fragmented
);
100 udp_print(ndo
, bp
, length
, iph
, fragmented
, ttl_hl
);
105 icmp_print(ndo
, bp
, length
, fragmented
);
107 ND_PRINT("[%s requires IPv4]",
108 tok2str(ipproto_values
,"unknown",nh
));
109 nd_print_invalid(ndo
);
115 icmp6_print(ndo
, bp
, length
, iph
, fragmented
);
117 ND_PRINT("[%s requires IPv6]",
118 tok2str(ipproto_values
,"unknown",nh
));
119 nd_print_invalid(ndo
);
125 * XXX - the current IANA protocol number assignments
126 * page lists 9 as "any private interior gateway
127 * (used by Cisco for their IGRP)" and 88 as
128 * "EIGRP" from Cisco.
130 * Recent FreeBSD, DragonFly BSD, and macOS <netinet/in.h>
131 * headers define IPPROTO_PIGP as 9 and IPPROTO_IGRP
132 * as 88. We define IPPROTO_PIGP ("private interior
133 * gateway protocol") as 9 and IPPROTO_EIGRP as 88;
134 * those names better match what the current protocol
135 * number assignments say.
137 igrp_print(ndo
, bp
, length
);
141 eigrp_print(ndo
, bp
, length
);
145 ND_PRINT(" nd %u", length
);
149 egp_print(ndo
, bp
, length
);
154 ospf6_print(ndo
, bp
, length
);
156 ospf_print(ndo
, bp
, length
, iph
);
161 igmp_print(ndo
, bp
, length
);
163 ND_PRINT("[%s requires IPv4]",
164 tok2str(ipproto_values
,"unknown",nh
));
165 nd_print_invalid(ndo
);
170 /* ipv4-in-ip encapsulation */
171 ip_print(ndo
, bp
, length
);
175 /* ip6-in-ip encapsulation */
176 ip6_print(ndo
, bp
, length
);
180 rsvp_print(ndo
, bp
, length
);
184 gre_print(ndo
, bp
, length
);
188 mobile_print(ndo
, bp
, length
);
192 pim_print(ndo
, bp
, length
, iph
);
196 if (ndo
->ndo_packettype
== PT_CARP
) {
197 carp_print(ndo
, bp
, length
, ttl_hl
);
199 vrrp_print(ndo
, bp
, length
, iph
, ttl_hl
, ver
);
204 pgm_print(ndo
, bp
, length
, iph
);
207 case IPPROTO_ETHERNET
:
209 ether_print(ndo
, bp
, length
, ND_BYTES_AVAILABLE_AFTER(bp
), NULL
, NULL
);
211 ND_PRINT("[%s requires IPv6]",
212 tok2str(ipproto_values
,"unknown",nh
));
213 nd_print_invalid(ndo
);
218 nhrp_print(ndo
, bp
, length
);
222 ND_PRINT("no next header");
226 if (ndo
->ndo_nflag
==0 && (p_name
= netdb_protoname(nh
)) != NULL
)
227 ND_PRINT(" %s", p_name
);
229 ND_PRINT(" ip-proto-%u", nh
);
230 ND_PRINT(" %u", length
);