Packet.h
上传用户:karykuang
上传日期:2010-02-26
资源大小:103k
文件大小:2k
源码类别:

TCP/IP协议栈

开发平台:

Visual C++

  1. // Packet.h: interface for the CPacket class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_PACKET_H__219DF6D1_5BBD_11D5_9C5D_0010B54D784D__INCLUDED_)
  5. #define AFX_PACKET_H__219DF6D1_5BBD_11D5_9C5D_0010B54D784D__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "CRC.h"
  10. #include "Ip.h"
  11. #define MAXRX 256
  12. #define PING 0
  13. #define REQ 1
  14. #define ACK 2
  15. #define NAK 3
  16. #define REJ 4
  17. #define TERM_REQ 5
  18. #define TERM_ACK 6
  19. #define CODE_REJ 7
  20. #define PROTOCAL_REJ 8
  21. #define ECHO_REQ 9
  22. #define ECHO_REP 10
  23. #define DISCARD_REQ 11
  24. #define IDENTIFICATION 12
  25. #define TIME_REM 13
  26. #define LCP_CODE_MAX 13
  27. #define IPCP_CODE_MAX 7
  28. #define IP 0x0021
  29. #define IPCP 0x8021
  30. #define CCP 0x80FD
  31. #define LCP 0xC021
  32. #define PAP 0xC023
  33. #define INITIAL 0
  34. #define LCPOPEN 1
  35. #define LCPESTABLISH 2
  36. #define LCPDOWN 3
  37. #define PAPOPEN 4
  38. #define PAPPASS 5
  39. #define IPCPOPEN 6
  40. #define IPCPNAK 7
  41. #define IPCPOK 8
  42. #define IPCPACK 9
  43. #define IPSTART 10
  44. #define IPCPREOPEN 11
  45. #define IPCPRENAK 12
  46. #define IPCPREOK 13
  47. //#define 
  48. #define IP_ICMP 01
  49. #define IP_TCP 06
  50. #define IP_UDP 17
  51. //in ICMP protocol
  52. #define ICMP_PING 0x08
  53. #define ICMP_PINGREPLY 0x00
  54. class CPacket  
  55. {
  56. public:
  57. CPacket();
  58. virtual ~CPacket();
  59. bool checkpacket(BYTE *packetstr);
  60. void testoption(WORD wType,BYTE bCode,BYTE* pOptionstr);
  61. void makepacket(WORD wType,BYTE bCode,BYTE* pPacketRx);
  62. int charactermap(int iLen);
  63. int ipheader(int i);
  64. public:
  65. void makeIPpacket(BYTE protocal, BYTE type, BYTE *temp);
  66. void InitPacket();
  67. WORD wType;
  68. int compress,iLenpos,iHeadcheckpos,iIcmpcheckpos;
  69. int PF_compress;
  70. BYTE bState;
  71. BYTE bID; //unique packet id
  72. BOOL reject; //make sure whether my packet is ACK or REJ
  73. BOOL map; //map control character
  74. int iOptionnum; //get the option number
  75. BYTE bPacketTx1[256]; //send packet buffer
  76. BYTE bPacketTx[256];
  77. int TxLen;
  78. PPP_OPTION option[8];
  79. IP_HEADER IP_header;
  80. IP_HEADER IP_headerTx;
  81. ICMP_HEADER ICMP_header;
  82. PPP_UDP m_udp;
  83. BYTE bIpaddress[4];
  84. CCRC m_crc;
  85. BYTE IP_protocal;
  86. BYTE recPacketS;
  87. BYTE RxCompress;
  88. BYTE IPCP_s;
  89. };
  90. #endif // !defined(AFX_PACKET_H__219DF6D1_5BBD_11D5_9C5D_0010B54D784D__INCLUDED_)