]>
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 */
28 #include "netdissect-stdinc.h"
32 #include "netdissect.h"
33 #include "addrtoname.h"
40 ip_demux_print(netdissect_options
*ndo
,
42 u_int length
, u_int ver
, int fragmented
, u_int ttl_hl
,
43 uint8_t nh
, const u_char
*iph
)
54 if (!ND_TTEST_1(bp
)) {
55 ndo
->ndo_protocol
= "ah";
60 advance
= ah_print(ndo
, bp
);
69 esp_print(ndo
, bp
, length
, iph
, ver
, fragmented
, ttl_hl
);
71 * Either this has decrypted the payload and
72 * printed it, in which case there's nothing more
73 * to do, or it hasn't, in which case there's
81 ipcomp_print(ndo
, bp
);
83 * Either this has decompressed the payload and
84 * printed it, in which case there's nothing more
85 * to do, or it hasn't, in which case there's
92 sctp_print(ndo
, bp
, iph
, length
);
96 dccp_print(ndo
, bp
, iph
, length
);
100 tcp_print(ndo
, bp
, length
, iph
, fragmented
);
104 udp_print(ndo
, bp
, length
, iph
, fragmented
, ttl_hl
);
109 icmp_print(ndo
, bp
, length
, iph
, fragmented
);
111 ND_PRINT("[%s requires IPv4]",
112 tok2str(ipproto_values
,"unknown",nh
));
113 nd_print_invalid(ndo
);
119 icmp6_print(ndo
, bp
, length
, iph
, fragmented
);
121 ND_PRINT("[%s requires IPv6]",
122 tok2str(ipproto_values
,"unknown",nh
));
123 nd_print_invalid(ndo
);
129 * XXX - the current IANA protocol number assignments
130 * page lists 9 as "any private interior gateway
131 * (used by Cisco for their IGRP)" and 88 as
132 * "EIGRP" from Cisco.
134 * Recent BSD <netinet/in.h> headers define
135 * IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88.
136 * We define IP_PROTO_PIGP as 9 and
137 * IP_PROTO_EIGRP as 88; those names better
138 * match was the current protocol number
141 igrp_print(ndo
, bp
, length
);
145 eigrp_print(ndo
, bp
, length
);
149 ND_PRINT(" nd %u", length
);
153 egp_print(ndo
, bp
, length
);
158 ospf6_print(ndo
, bp
, length
);
160 ospf_print(ndo
, bp
, length
, iph
);
165 igmp_print(ndo
, bp
, length
);
167 ND_PRINT("[%s requires IPv4]",
168 tok2str(ipproto_values
,"unknown",nh
));
169 nd_print_invalid(ndo
);
174 /* ipv4-in-ip encapsulation */
175 ip_print(ndo
, bp
, length
);
179 /* ip6-in-ip encapsulation */
180 ip6_print(ndo
, bp
, length
);
184 rsvp_print(ndo
, bp
, length
);
188 gre_print(ndo
, bp
, length
);
192 mobile_print(ndo
, bp
, length
);
196 pim_print(ndo
, bp
, length
, iph
);
200 if (ndo
->ndo_packettype
== PT_CARP
) {
201 carp_print(ndo
, bp
, length
, ttl_hl
);
203 vrrp_print(ndo
, bp
, length
, iph
, ttl_hl
);
208 pgm_print(ndo
, bp
, length
, iph
);
211 case IPPROTO_ETHERNET
:
213 ether_print(ndo
, bp
, length
, ND_BYTES_AVAILABLE_AFTER(bp
), NULL
, NULL
);
215 ND_PRINT("[%s requires IPv6]",
216 tok2str(ipproto_values
,"unknown",nh
));
217 nd_print_invalid(ndo
);
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
);