unit IPCap;
interface
uses
Windows, Messages, Classes, WinSock, SysUtils;
const
WM_CapIp = WM_USER + 200;
STATUS_FAILED = $FFFF; //定义异常出错代码
MAX_PACK_LEN = 65535; //接收的最大IP报文
MAX_ADDR_LEN = 16; //点分十进制地址的最大长度
MAX_PROTO_TEXT_LEN = 16; //子协议名称(如"TCP")最大长度
MAX_PROTO_NUM = 12; //子协议数量
MAX_HOSTNAME_LAN = 255; //最大主机名长度
CMD_PARAM_HELP = True;
IOC_IN = $80000000;
IOC_VENDOR = $18000000;
IOC_out = $40000000;
SIO_RCVALL = IOC_IN or IOC_VENDOR or 1; // or IOC_out;
SIO_RCVALL_MCAST = IOC_IN or IOC_VENDOR or 2;
SIO_RCVALL_IGMPMCAST = IOC_IN or IOC_VENDOR or 3;
SIO_KEEPALIVE_VALS = IOC_IN or IOC_VENDOR or 4;
SIO_ABSORB_RTRALERT = IOC_IN or IOC_VENDOR or 5;
SIO_UCAST_IF = IOC_IN or IOC_VENDOR or 6;
SIO_LIMIT_BROADCASTS = IOC_IN or IOC_VENDOR or 7;
SIO_INDEX_BIND = IOC_IN or IOC_VENDOR or 8;
SIO_INDEX_MCASTIF = IOC_IN or IOC_VENDOR or 9;
SIO_INDEX_ADD_MCAST = IOC_IN or IOC_VENDOR or 10;
SIO_INDEX_DEL_MCAST = IOC_IN or IOC_VENDOR or 11;
type
Tcp_KeepAlive = record
OnOff: Longword;
KeepAliveTime: Longword;
KeepAliveInterval: Longword;
end;
// New WSAIoctl Options
//IP头
_IpHdr = record
H_lenver: Byte; //4位首部长度+4位IP版本号
Tos: Char; //8位服务类型TOS
Total_Len: Char; //16位总长度(字节)
Ident: Word; //16位标识
Frag_And_Flags: Word; //3位标志位
Ttl: Byte; //8位生存时间 TTL
Proto: Byte; //8位协议 (TCP, UDP 或其他)
CheckSum: Word; //16位IP首部校验和
SourIP: Longword; //32位源IP地址
DestIP: Longword; //32位目的IP地址
end;
IP_HEADER = _IpHdr;
_TcpHdr = record //定义TCP首部
TCP_Sport: Word; //16位源端口
TCP_Dport: Word; //16位目的端口
Th_Seq: Longword; //32位序列号
Th_Ack: longword; //32位确认号
Th_Lenres: Byte; //4位首部长度/6位保留字
Th_Flag: Char; //6位标志位
Th_Win: Word; //16位窗口大小
Th_Sum: Word; //16位校验和
Th_Urp: Word; //16位紧急数据偏移量
end;
TCP_HEADER = _TcpHdr;
_UdpHdr = record //定义UDP首部
Uh_Sport: Word; //16位源端口
Uh_Dport: Word; //16位目的端口
Uh_Len: Word; //16位长度
Uh_Sum: Word; //16位校验和
end;
UDP_HEADER = _UdpHdr;
_IcmpHdr = record //定义ICMP首部
I_Type: Byte; //8位类型
I_Code: Byte; //8位代码
I_CkSum: Word; //16位校验和
I_Id: Word; //识别号(一般用进程号作为识别号)
// I_seq: Word ; //报文序列号
TimeStamp: Word; //时间戳
end;
ICMP_HEADER = _IcmpHdr;
_Protomap = record //定义子协议映射表
ProtoNum: Integer;
ProtoText: array[0..MAX_PROTO_TEXT_LEN] of Char;
end;
TPROTOMAP = _Protomap;