156893Sfenner/*
256893Sfenner * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
356893Sfenner *	The Regents of the University of California.  All rights reserved.
456893Sfenner *
556893Sfenner * Redistribution and use in source and binary forms, with or without
656893Sfenner * modification, are permitted provided that: (1) source code distributions
756893Sfenner * retain the above copyright notice and this paragraph in its entirety, (2)
856893Sfenner * distributions including binary code include the above copyright notice and
956893Sfenner * this paragraph in its entirety in the documentation or other materials
1056893Sfenner * provided with the distribution, and (3) all advertising materials mentioning
1156893Sfenner * features or use of this software display the following acknowledgement:
1256893Sfenner * ``This product includes software developed by the University of California,
1356893Sfenner * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1456893Sfenner * the University nor the names of its contributors may be used to endorse
1556893Sfenner * or promote products derived from this software without specific prior
1656893Sfenner * written permission.
1756893Sfenner * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1856893Sfenner * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1956893Sfenner * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2056893Sfenner */
2156893Sfenner
2256893Sfenner#ifndef lint
23127668Sbmsstatic const char rcsid[] _U_ =
24190207Srpaulo    "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp $";
2556893Sfenner#endif
2656893Sfenner
2756893Sfenner#ifdef HAVE_CONFIG_H
2856893Sfenner#include "config.h"
2956893Sfenner#endif
3056893Sfenner
3156893Sfenner#ifdef INET6
3256893Sfenner
33127668Sbms#include <tcpdump-stdinc.h>
3456893Sfenner
3556893Sfenner#include <stdio.h>
3656893Sfenner
3775115Sfenner#include "ip6.h"
3856893Sfenner
3956893Sfenner#include "interface.h"
4056893Sfenner#include "addrtoname.h"
41127668Sbms#include "extract.h"
4256893Sfenner
4356893Sfennerint
4456893Sfennerfrag6_print(register const u_char *bp, register const u_char *bp2)
4556893Sfenner{
4656893Sfenner	register const struct ip6_frag *dp;
4756893Sfenner	register const struct ip6_hdr *ip6;
4856893Sfenner
4998524Sfenner	dp = (const struct ip6_frag *)bp;
5098524Sfenner	ip6 = (const struct ip6_hdr *)bp2;
5156893Sfenner
5256893Sfenner	TCHECK(dp->ip6f_offlg);
5356893Sfenner
5456893Sfenner	if (vflag) {
5556893Sfenner		printf("frag (0x%08x:%d|%ld)",
56127668Sbms		       EXTRACT_32BITS(&dp->ip6f_ident),
57127668Sbms		       EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
58127668Sbms		       sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
5956893Sfenner			       (long)(bp - bp2) - sizeof(struct ip6_frag));
6056893Sfenner	} else {
6156893Sfenner		printf("frag (%d|%ld)",
62127668Sbms		       EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
63127668Sbms		       sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
6456893Sfenner			       (long)(bp - bp2) - sizeof(struct ip6_frag));
6556893Sfenner	}
6656893Sfenner
6775115Sfenner#if 1
6856893Sfenner	/* it is meaningless to decode non-first fragment */
69127668Sbms	if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
70127668Sbms		return -1;
7156893Sfenner	else
7256893Sfenner#endif
7356893Sfenner	{
7456893Sfenner		fputs(" ", stdout);
7556893Sfenner		return sizeof(struct ip6_frag);
7656893Sfenner	}
7756893Sfennertrunc:
7856893Sfenner	fputs("[|frag]", stdout);
79127668Sbms	return -1;
8056893Sfenner#undef TCHECK
8156893Sfenner}
8256893Sfenner#endif /* INET6 */
83