⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _frag6.c

📁 This directory contains source code for tcpdump, a tool for network monitoring and data acquisition
💻 C
字号:
/*
 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
 *      The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that: (1) source code distributions
 * retain the above copyright notice and this paragraph in its entirety, (2)
 * distributions including binary code include the above copyright notice and
 * this paragraph in its entirety in the documentation or other materials
 * provided with the distribution, and (3) all advertising materials mentioning
 * features or use of this software display the following acknowledgement:
 * ``This product includes software developed by the University of California,
 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
 * the University nor the names of its contributors may be used to endorse
 * or promote products derived from this software without specific prior
 * written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#if 0
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.3.2.1 2000/01/11 06:58:24 fenner Exp $";
#endif

#include <stdio.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>

#include <net/if.h>

#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
#include <netinet/ipv6.h>

#include "interfac.h"
#include "a2name.h"

#ifdef USE_INET6

#ifndef IP6F_OFF_MASK
#define IP6F_OFF_MASK  0xFFF8
#endif

int frag6_print (const u_char * bp, const u_char * bp2)
{
  const struct ipv6_fraghdr *dp  = (struct ipv6_fraghdr*) bp;
  const struct ipv6hdr      *ip6 = (struct ipv6hdr*) bp2;

  TCHECK (dp->frag_off);

  if (vflag)
       PRINTF ("frag (0x%08lx:%d|%ld)",
               ntohl (dp->identification),
               ntohs (dp->frag_off & IP6F_OFF_MASK),
               sizeof(*ip6) + ntohs (ip6->ipv6_len) -
               (long) (bp - bp2) - sizeof(struct ipv6_fraghdr));
  else PRINTF ("frag (%d|%ld)",
               ntohs (dp->frag_off & IP6F_OFF_MASK),
               sizeof(*ip6) + ntohs (ip6->ipv6_len) -
               (long) (bp - bp2) - sizeof(struct ipv6_fraghdr));

#if 0
  /* it is meaningless to decode non-first fragment */
  if (ntohs (dp->frag_off & IP6F_OFF_MASK) != 0)
     return (65535);
#endif

  PUTCHAR (' ');
  return sizeof(struct ipv6_fraghdr);

trunc:
  PUTS ("[|frag]");
  return (65535);
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -