141c99275SPeter Avalos /*
241c99275SPeter Avalos * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
341c99275SPeter Avalos * The Regents of the University of California. All rights reserved.
441c99275SPeter Avalos *
541c99275SPeter Avalos * Redistribution and use in source and binary forms, with or without
641c99275SPeter Avalos * modification, are permitted provided that: (1) source code distributions
741c99275SPeter Avalos * retain the above copyright notice and this paragraph in its entirety, (2)
841c99275SPeter Avalos * distributions including binary code include the above copyright notice and
941c99275SPeter Avalos * this paragraph in its entirety in the documentation or other materials
1041c99275SPeter Avalos * provided with the distribution, and (3) all advertising materials mentioning
1141c99275SPeter Avalos * features or use of this software display the following acknowledgement:
1241c99275SPeter Avalos * ``This product includes software developed by the University of California,
1341c99275SPeter Avalos * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1441c99275SPeter Avalos * the University nor the names of its contributors may be used to endorse
1541c99275SPeter Avalos * or promote products derived from this software without specific prior
1641c99275SPeter Avalos * written permission.
1741c99275SPeter Avalos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1841c99275SPeter Avalos * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1941c99275SPeter Avalos * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2041c99275SPeter Avalos */
2141c99275SPeter Avalos
22411677aeSAaron LI /* \summary: IPv6 fragmentation header printer */
2341c99275SPeter Avalos
2441c99275SPeter Avalos #ifdef HAVE_CONFIG_H
25*ed775ee7SAntonio Huete Jimenez #include <config.h>
2641c99275SPeter Avalos #endif
2741c99275SPeter Avalos
28*ed775ee7SAntonio Huete Jimenez #include "netdissect-stdinc.h"
2941c99275SPeter Avalos
30411677aeSAaron LI #include "netdissect.h"
31411677aeSAaron LI #include "extract.h"
3241c99275SPeter Avalos
3341c99275SPeter Avalos #include "ip6.h"
3441c99275SPeter Avalos
3541c99275SPeter Avalos int
frag6_print(netdissect_options * ndo,const u_char * bp,const u_char * bp2)36*ed775ee7SAntonio Huete Jimenez frag6_print(netdissect_options *ndo, const u_char *bp, const u_char *bp2)
3741c99275SPeter Avalos {
38*ed775ee7SAntonio Huete Jimenez const struct ip6_frag *dp;
39*ed775ee7SAntonio Huete Jimenez const struct ip6_hdr *ip6;
4041c99275SPeter Avalos
41*ed775ee7SAntonio Huete Jimenez ndo->ndo_protocol = "frag6";
4241c99275SPeter Avalos dp = (const struct ip6_frag *)bp;
4341c99275SPeter Avalos ip6 = (const struct ip6_hdr *)bp2;
4441c99275SPeter Avalos
45411677aeSAaron LI if (ndo->ndo_vflag) {
46*ed775ee7SAntonio Huete Jimenez ND_PRINT("frag (0x%08x:%u|%zu)",
47*ed775ee7SAntonio Huete Jimenez GET_BE_U_4(dp->ip6f_ident),
48*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(dp->ip6f_offlg) & IP6F_OFF_MASK,
49*ed775ee7SAntonio Huete Jimenez sizeof(struct ip6_hdr) + GET_BE_U_2(ip6->ip6_plen) -
50*ed775ee7SAntonio Huete Jimenez (bp - bp2) - sizeof(struct ip6_frag));
5141c99275SPeter Avalos } else {
52*ed775ee7SAntonio Huete Jimenez ND_PRINT("frag (%u|%zu)",
53*ed775ee7SAntonio Huete Jimenez GET_BE_U_2(dp->ip6f_offlg) & IP6F_OFF_MASK,
54*ed775ee7SAntonio Huete Jimenez sizeof(struct ip6_hdr) + GET_BE_U_2(ip6->ip6_plen) -
55*ed775ee7SAntonio Huete Jimenez (bp - bp2) - sizeof(struct ip6_frag));
5641c99275SPeter Avalos }
5741c99275SPeter Avalos
5841c99275SPeter Avalos /* it is meaningless to decode non-first fragment */
59*ed775ee7SAntonio Huete Jimenez if ((GET_BE_U_2(dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
6041c99275SPeter Avalos return -1;
6141c99275SPeter Avalos else
6241c99275SPeter Avalos {
63*ed775ee7SAntonio Huete Jimenez ND_PRINT(" ");
6441c99275SPeter Avalos return sizeof(struct ip6_frag);
6541c99275SPeter Avalos }
6641c99275SPeter Avalos }
67