print-frag6.c revision 313537
179388Smsmith/* 2141238Snjl * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 379388Smsmith * The Regents of the University of California. All rights reserved. 479388Smsmith * 579388Smsmith * Redistribution and use in source and binary forms, with or without 679388Smsmith * modification, are permitted provided that: (1) source code distributions 779388Smsmith * retain the above copyright notice and this paragraph in its entirety, (2) 879388Smsmith * distributions including binary code include the above copyright notice and 979388Smsmith * this paragraph in its entirety in the documentation or other materials 1079388Smsmith * provided with the distribution, and (3) all advertising materials mentioning 1179388Smsmith * features or use of this software display the following acknowledgement: 1279388Smsmith * ``This product includes software developed by the University of California, 1379388Smsmith * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 1479388Smsmith * the University nor the names of its contributors may be used to endorse 1579388Smsmith * or promote products derived from this software without specific prior 1679388Smsmith * written permission. 1779388Smsmith * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 1879388Smsmith * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 1979388Smsmith * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 2079388Smsmith */ 2179388Smsmith 2279388Smsmith/* \summary: IPv6 fragmentation header printer */ 2379388Smsmith 2479388Smsmith#ifdef HAVE_CONFIG_H 2579388Smsmith#include "config.h" 2679388Smsmith#endif 2779388Smsmith 28119418Sobrien#include <netdissect-stdinc.h> 29119418Sobrien 30119418Sobrien#include "ip6.h" 3179388Smsmith#include "netdissect.h" 3279388Smsmith#include "extract.h" 33122904Snjl 34141238Snjlint 3579388Smsmithfrag6_print(netdissect_options *ndo, register const u_char *bp, register const u_char *bp2) 36123132Sjhb{ 37129879Sphk register const struct ip6_frag *dp; 38122904Snjl register const struct ip6_hdr *ip6; 39122904Snjl 40122766Snjl dp = (const struct ip6_frag *)bp; 41243404Savg ip6 = (const struct ip6_hdr *)bp2; 42122766Snjl 43122766Snjl ND_TCHECK(dp->ip6f_offlg); 4479388Smsmith 45122766Snjl if (ndo->ndo_vflag) { 46122904Snjl ND_PRINT((ndo, "frag (0x%08x:%d|%ld)", 4779388Smsmith EXTRACT_32BITS(&dp->ip6f_ident), 48216443Sjkim EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK, 49216443Sjkim sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) - 50282678Skib (long)(bp - bp2) - sizeof(struct ip6_frag))); 51282678Skib } else { 52216443Sjkim ND_PRINT((ndo, "frag (%d|%ld)", 53122904Snjl EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK, 5479388Smsmith sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) - 55193530Sjkim (long)(bp - bp2) - sizeof(struct ip6_frag))); 56193530Sjkim } 57193530Sjkim 5879388Smsmith /* it is meaningless to decode non-first fragment */ 5979388Smsmith if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0) 6079388Smsmith return -1; 61141415Snjl else 6279388Smsmith { 6379388Smsmith ND_PRINT((ndo, " ")); 64119529Snjl return sizeof(struct ip6_frag); 6579388Smsmith } 6691123Smsmithtrunc: 6779388Smsmith ND_PRINT((ndo, "[|frag]")); 68122766Snjl return -1; 69122766Snjl} 70122766Snjl