Packet.h
资源名称:PPP0208.rar [点击查看]
上传用户:karykuang
上传日期:2010-02-26
资源大小:103k
文件大小:2k
源码类别:
TCP/IP协议栈
开发平台:
Visual C++
- // Packet.h: interface for the CPacket class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_PACKET_H__219DF6D1_5BBD_11D5_9C5D_0010B54D784D__INCLUDED_)
- #define AFX_PACKET_H__219DF6D1_5BBD_11D5_9C5D_0010B54D784D__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "CRC.h"
- #include "Ip.h"
- #define MAXRX 256
- #define PING 0
- #define REQ 1
- #define ACK 2
- #define NAK 3
- #define REJ 4
- #define TERM_REQ 5
- #define TERM_ACK 6
- #define CODE_REJ 7
- #define PROTOCAL_REJ 8
- #define ECHO_REQ 9
- #define ECHO_REP 10
- #define DISCARD_REQ 11
- #define IDENTIFICATION 12
- #define TIME_REM 13
- #define LCP_CODE_MAX 13
- #define IPCP_CODE_MAX 7
- #define IP 0x0021
- #define IPCP 0x8021
- #define CCP 0x80FD
- #define LCP 0xC021
- #define PAP 0xC023
- #define INITIAL 0
- #define LCPOPEN 1
- #define LCPESTABLISH 2
- #define LCPDOWN 3
- #define PAPOPEN 4
- #define PAPPASS 5
- #define IPCPOPEN 6
- #define IPCPNAK 7
- #define IPCPOK 8
- #define IPCPACK 9
- #define IPSTART 10
- #define IPCPREOPEN 11
- #define IPCPRENAK 12
- #define IPCPREOK 13
- //#define
- #define IP_ICMP 01
- #define IP_TCP 06
- #define IP_UDP 17
- //in ICMP protocol
- #define ICMP_PING 0x08
- #define ICMP_PINGREPLY 0x00
- class CPacket
- {
- public:
- CPacket();
- virtual ~CPacket();
- bool checkpacket(BYTE *packetstr);
- void testoption(WORD wType,BYTE bCode,BYTE* pOptionstr);
- void makepacket(WORD wType,BYTE bCode,BYTE* pPacketRx);
- int charactermap(int iLen);
- int ipheader(int i);
- public:
- void makeIPpacket(BYTE protocal, BYTE type, BYTE *temp);
- void InitPacket();
- WORD wType;
- int compress,iLenpos,iHeadcheckpos,iIcmpcheckpos;
- int PF_compress;
- BYTE bState;
- BYTE bID; //unique packet id
- BOOL reject; //make sure whether my packet is ACK or REJ
- BOOL map; //map control character
- int iOptionnum; //get the option number
- BYTE bPacketTx1[256]; //send packet buffer
- BYTE bPacketTx[256];
- int TxLen;
- PPP_OPTION option[8];
- IP_HEADER IP_header;
- IP_HEADER IP_headerTx;
- ICMP_HEADER ICMP_header;
- PPP_UDP m_udp;
- BYTE bIpaddress[4];
- CCRC m_crc;
- BYTE IP_protocal;
- BYTE recPacketS;
- BYTE RxCompress;
- BYTE IPCP_s;
- };
- #endif // !defined(AFX_PACKET_H__219DF6D1_5BBD_11D5_9C5D_0010B54D784D__INCLUDED_)