1b0453382SBill Fenner /*
2b0453382SBill Fenner * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
3b0453382SBill Fenner * The Regents of the University of California. All rights reserved.
4b0453382SBill Fenner *
5b0453382SBill Fenner * Redistribution and use in source and binary forms, with or without
6b0453382SBill Fenner * modification, are permitted provided that: (1) source code distributions
7b0453382SBill Fenner * retain the above copyright notice and this paragraph in its entirety, (2)
8b0453382SBill Fenner * distributions including binary code include the above copyright notice and
9b0453382SBill Fenner * this paragraph in its entirety in the documentation or other materials
10b0453382SBill Fenner * provided with the distribution, and (3) all advertising materials mentioning
11b0453382SBill Fenner * features or use of this software display the following acknowledgement:
12b0453382SBill Fenner * ``This product includes software developed by the University of California,
13b0453382SBill Fenner * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14b0453382SBill Fenner * the University nor the names of its contributors may be used to endorse
15b0453382SBill Fenner * or promote products derived from this software without specific prior
16b0453382SBill Fenner * written permission.
17b0453382SBill Fenner * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18b0453382SBill Fenner * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19b0453382SBill Fenner * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20b0453382SBill Fenner */
21b0453382SBill Fenner
223340d773SGleb Smirnoff /* \summary: IPv6 fragmentation header printer */
233340d773SGleb Smirnoff
24ee67461eSJoseph Mingrone #include <config.h>
25b0453382SBill Fenner
26ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
27b0453382SBill Fenner
283340d773SGleb Smirnoff #include "netdissect.h"
295b0fe478SBruce M Simpson #include "extract.h"
30b0453382SBill Fenner
310bff6a5aSEd Maste #include "ip6.h"
320bff6a5aSEd Maste
33b0453382SBill Fenner int
frag6_print(netdissect_options * ndo,const u_char * bp,const u_char * bp2)34ee67461eSJoseph Mingrone frag6_print(netdissect_options *ndo, const u_char *bp, const u_char *bp2)
35b0453382SBill Fenner {
36ee67461eSJoseph Mingrone const struct ip6_frag *dp;
37ee67461eSJoseph Mingrone const struct ip6_hdr *ip6;
38b0453382SBill Fenner
39ee67461eSJoseph Mingrone ndo->ndo_protocol = "frag6";
40a90e161bSBill Fenner dp = (const struct ip6_frag *)bp;
41a90e161bSBill Fenner ip6 = (const struct ip6_hdr *)bp2;
42b0453382SBill Fenner
43*0a7e5f1fSJoseph Mingrone ND_PRINT("frag (");
44*0a7e5f1fSJoseph Mingrone if (ndo->ndo_vflag)
45*0a7e5f1fSJoseph Mingrone ND_PRINT("0x%08x:", GET_BE_U_4(dp->ip6f_ident));
46*0a7e5f1fSJoseph Mingrone ND_PRINT("%u|", GET_BE_U_2(dp->ip6f_offlg) & IP6F_OFF_MASK);
47*0a7e5f1fSJoseph Mingrone if ((bp - bp2) + sizeof(struct ip6_frag) >
48*0a7e5f1fSJoseph Mingrone sizeof(struct ip6_hdr) + GET_BE_U_2(ip6->ip6_plen))
49*0a7e5f1fSJoseph Mingrone ND_PRINT("[length < 0] (invalid))");
50*0a7e5f1fSJoseph Mingrone else
51*0a7e5f1fSJoseph Mingrone ND_PRINT("%zu)",
52ee67461eSJoseph Mingrone sizeof(struct ip6_hdr) + GET_BE_U_2(ip6->ip6_plen) -
53ee67461eSJoseph Mingrone (bp - bp2) - sizeof(struct ip6_frag));
54b0453382SBill Fenner
55b0453382SBill Fenner /* it is meaningless to decode non-first fragment */
56ee67461eSJoseph Mingrone if ((GET_BE_U_2(dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
575b0fe478SBruce M Simpson return -1;
58*0a7e5f1fSJoseph Mingrone else {
59ee67461eSJoseph Mingrone ND_PRINT(" ");
60b0453382SBill Fenner return sizeof(struct ip6_frag);
61b0453382SBill Fenner }
62b0453382SBill Fenner }
63