winpcap截获HTTP代码,winpcap没有,自己稍微写了一下
// DataFilter.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#define WPCAP
#define HAVE_REMOTE
#include <pcap.h>
#include <vector>
using namespace std;
struct PacketInfo
{
int Sort; //序列号
string Info; //包的内容
};
/* 4字节的IP地址 */
typedef struct ip_address{
u_char byte1;
u_char byte2;
u_char byte3;
u_char byte4;
}ip_address;
/* IPv4 首部 */
typedef struct ip_header{
u_char ver_ihl; // 版本 (4 bits) + 首部长度 (4 bits)
u_char tos; // 服务类型(Type of service)
u_short tlen; // 总长(Total length)
u_short identification; // 标识(Identification)
u_short flags_fo; // 标志位(Flags) (3 bits) + 段偏移量(Fragment offset) (13 bits)
u_char ttl; // 存活时间(Time to live)
u_char proto; /