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 24b0453382SBill Fenner #ifdef HAVE_CONFIG_H 25b0453382SBill Fenner #include "config.h" 26b0453382SBill Fenner #endif 27b0453382SBill Fenner 283340d773SGleb Smirnoff #include <netdissect-stdinc.h> 29b0453382SBill Fenner 303340d773SGleb Smirnoff #include "netdissect.h" 315b0fe478SBruce M Simpson #include "extract.h" 32b0453382SBill Fenner 33*0bff6a5aSEd Maste #include "ip6.h" 34*0bff6a5aSEd Maste 35b0453382SBill Fenner int 363c602fabSXin LI frag6_print(netdissect_options *ndo, register const u_char *bp, register const u_char *bp2) 37b0453382SBill Fenner { 38b0453382SBill Fenner register const struct ip6_frag *dp; 39b0453382SBill Fenner register const struct ip6_hdr *ip6; 40b0453382SBill Fenner 41a90e161bSBill Fenner dp = (const struct ip6_frag *)bp; 42a90e161bSBill Fenner ip6 = (const struct ip6_hdr *)bp2; 43b0453382SBill Fenner 44*0bff6a5aSEd Maste ND_TCHECK(*dp); 45b0453382SBill Fenner 463c602fabSXin LI if (ndo->ndo_vflag) { 473c602fabSXin LI ND_PRINT((ndo, "frag (0x%08x:%d|%ld)", 485b0fe478SBruce M Simpson EXTRACT_32BITS(&dp->ip6f_ident), 495b0fe478SBruce M Simpson EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK, 505b0fe478SBruce M Simpson sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) - 513c602fabSXin LI (long)(bp - bp2) - sizeof(struct ip6_frag))); 52b0453382SBill Fenner } else { 533c602fabSXin LI ND_PRINT((ndo, "frag (%d|%ld)", 545b0fe478SBruce M Simpson EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK, 555b0fe478SBruce M Simpson sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) - 563c602fabSXin LI (long)(bp - bp2) - sizeof(struct ip6_frag))); 57b0453382SBill Fenner } 58b0453382SBill Fenner 59b0453382SBill Fenner /* it is meaningless to decode non-first fragment */ 605b0fe478SBruce M Simpson if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0) 615b0fe478SBruce M Simpson return -1; 62b0453382SBill Fenner else 63b0453382SBill Fenner { 643c602fabSXin LI ND_PRINT((ndo, " ")); 65b0453382SBill Fenner return sizeof(struct ip6_frag); 66b0453382SBill Fenner } 67b0453382SBill Fenner trunc: 683c602fabSXin LI ND_PRINT((ndo, "[|frag]")); 695b0fe478SBruce M Simpson return -1; 70b0453382SBill Fenner } 71