SourceCodeSky QQ客服 SourceCodeSky 400电话 客服电话 暂无

tcpview.c ( 文件浏览 )

  • keepall 发布于 2016-08-23 22:15
  • 浏览次数:485
  • 下载次数: 0
  • 下载需 10 积分
  • 侵权举报

/* http://www.cotse.com  Fear the swimming Elephant! */

/**
 ** version     : v1.01
 ** architecture: SunOS 4.1 [Sun3/Sun4]
 ** compilation : cc -O4 tcpw.c -o tcpw; strip tcpw
 ** source rights: this is an EXTREMELLY VICIOUS program, it is ADVISED
 **     that if you must keep this source online, KEEP IT IN ENCRYPTED
 **     FORM.
 **/

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sys/stropts.h>
#include <sys/signal.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/nit_if.h>
#include <net/nit_buf.h>
#include <net/if_arp.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <netinet/ip_var.h>
#include <netinet/udp_var.h>
#include <netinet/in_systm.h>
#include <netinet/tcp.h>
#include <netinet/ip_icmp.h>

char *malloc();
char *device;
int debug = 0,            /* debug */
  fastdump = 0,            /* do no sequential packet processing */
  oneway = 0;            /* oneway watch */

char *ProgName;

#define  NIT_DEV  "/dev/nit"
#define  CHUNKSIZE  4096    /* device buffer size */

int if_fd = -1;
int Packet[CHUNKSIZE + 32];

#define  STREAM_NULL  (0)
#define  STREAM_STOD  (1)
#define  STREAM_DTOS  (2)
#define  STREAM_MAX  (3)

struct PktStack {
  u_char data[CHUNKSIZE];
  int Len;
  u_long Seq;
};

#define  STACK_MAX  (10)

struct PktStack pkt_stack[STREAM_MAX][STACK_MAX];
int pkt_snum[STREAM_MAX];
u_long seq_num[STREAM_MAX];
char *Hostname[STREAM_MAX];
struct in_addr IPaddr[STREAM_MAX];
int TCPport[STREAM_MAX];

#define  ISeq(s,d)  ((s) == (d))
#define  ISneq(s,d)  ((s) != (d))

void
Pexit(err, msg)
  int err;
  char *msg;
{
  perror(msg);
  exit(err);
}

void
Zexit(err, msg)
  int err;
  char *msg;
{
  fprintf(stderr, msg);
  exit(err);
}

#define  FREEstk(SK,St,Rc) {
  SK.Len = (-1);
  if(!(--pkt_snum[St]))
    return(Rc);
  }
#define  ALLOCstk(SK,Len,Data,S,St) {
  bcopy(Data,SK.data,Len);
  SK.Len = Len;
  SK.Seq = S;
  pkt_snum[St]++;
  }
#define  pr_packet(p,length) {
  while(length-- >0)
  fputc(*p++,stdout);
  fflush(stdout);
  }
#define  MAL_pr_packet(i_p,i_length) {
  register u_char *p = i_p;
  register int length = i_length;
  pr_packet(p,length);
  }
#define  DEBUGstk(Msg,Num,Seq) if(debug) {
  printf(Msg,Num,Seq); fflush(stdout);
  }
#define  SPKT  pkt_stack[Tp][i]

/* find and print any packets in the stack IF they are sequential
 * after ours
 */
int
cpr_stack(Tp)
  register int Tp;
{
  register int i, pr = 1;

  while (pr)
    for (pr = i = 0; (i < STACK_MAX) && (!pr); i++) {
      if (ISneq(SPKT.Len, (-1))) {
    if (SPKT.Seq <= seq_num[Tp]) {    /* check for old packets */
      DEBUGstk("DISCARD(%d/%08X)\n",
           pkt_snum[Tp], SPKT.Seq);
      FREEstk(SPKT, Tp, 0);
    } else if (ISeq(SPKT.Seq, (seq_num[Tp] [!==More==!]			
...
展开> <收缩

下载源码到电脑,阅读使用更方便

1 积分

快速下载
还剩0行未阅读,继续阅读
免费下载源码
Sponsored links

源码文件列表

温馨提示: 点击源码文件名可预览文件内容哦 ^_^
...
名称 大小 修改日期
/tcpview.c 13.32 KB 2000-07-19 15:50:22
Sponsored links
正在加载中……

Switch to the English version?

Yes
SourceCodeSky 英文版
No
SourceCodeSky 中文版

完善个人资料,获价值¥30元积分奖励!