www.pudn.com > CapturePacket.rar > PacketMsg.h
// PacketMsg.h: interface for the CPacketMsg class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_PACKETMSG_H__07D44A00_DB78_464A_B980_13F72FBAA817__INCLUDED_)
#define AFX_PACKETMSG_H__07D44A00_DB78_464A_B980_13F72FBAA817__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "pcap.h"
#include "remote-ext.h"
class CPacketMsg
{
public:
typedef struct ip_address{
u_char byte1;
u_char byte2;
u_char byte3;
u_char byte4;
}ip_address;
/* IPv4 header */
typedef struct ip_header{
u_char ver_ihl; // Version (4 bits) + Internet header length (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; // Protocol
u_short crc; // Header checksum
ip_address saddr; // Source address
ip_address daddr; // Destination address
u_int op_pad; // Option + Padding
}ip_header;
/* UDP header*/
typedef struct udp_header{
u_short sport; // Source port
u_short dport; // Destination port
u_short len; // Datagram length
u_short crc; // Checksum
}udp_header;
char errBuf[PCAP_ERRBUF_SIZE];
int packetCount;
pcap_if_t *alldevs;
CPacketMsg();
virtual ~CPacketMsg();
BOOL getPacketInfo(int dev_num);
BOOL getNetCardInfo();
};
#endif // !defined(AFX_PACKETMSG_H__07D44A00_DB78_464A_B980_13F72FBAA817__INCLUDED_)