📄 icmp.h
字号:
/***********************************************************************
*
* FILE NAME VERSION
*
* ICMP.H 1.0
*
* COMPONENT
*
* ICMP - Internet Control Message Protocol
*
* DESCRIPTION
*
* Holds the defines for the ICMP protocol.
*
* DATA STRUCTURES
*
* ICMP_LAYER
* ICMP_ECHO_LIST_ENTRY
* ICMP_ECHO_LIST
*
* DEPENDENCIES
*
* No other file dependencies
*
*************************************************************************/
#ifndef ICMP_H
#define ICMP_H
#include "C:\wql\tcpipsocket\target.h"
#include "C:\wql\tcpipsocket\ip.h"
typedef struct ICMP_LAYER_STRUCT
{
UINT8 icmp_type; /* Type of ICMP message. */
UINT8 icmp_code; /* Sub code. */
UINT16 icmp_cksum; /* Ones complement check sum .*/
union { /* ICMP header union. */
UINT8 ih_pptr;
UINT8 ih_gwaddr[4];
struct ih_idseq {
INT16 icd_id;
INT16 icd_seq;
} ih_idseq;
INT32 ih_void;
struct ih_pmtu {
INT16 ipm_void;
INT16 ipm_nextmtu;
}ih_pmtu;
}icmp_hun;
union {
struct id_ts {
UINT32 its_otime;
UINT32 its_rtime;
UINT32 its_ttime;
} id_ts;
IPLAYER id_ip;
UINT32 id_mask;
INT8 id_data[32]; // BUFFER
} icmp_dun;
}ICMP_LAYER;
//******************************************
typedef struct ICMP_ECHO_Cache
{
UINT8 * dest_ip;
UINT16 Timer;
UINT8 Flag;
} ICMP_ECHO_Cache;
// define echo flag status
#define ICMP_REPLY 2
#define ICMP_TIMER_ERR 1
#define ICMP_NORMAL 0
#define ICMP_WAIT 4
/* ICMP echo request definitions. */
#define ICMP_ECHO_REQ_ID 0x4154 /* AT */
#define ICMP_DEFAULT_ECHO_TIMEOUT (5 * SCK_Ticks_Per_Second)
#define ICMP_ECHO_REQ_HEADER_SIZE 8
/* ICMP Type definitions. */
#define ICMP_ECHOREPLY 0
#define ICMP_UNREACH 3
#define ICMP_SOURCEQUENCH 4
#define ICMP_REDIRECT 5
#define ICMP_ECHO 8
#define ICMP_TIMXCEED 11
#define ICMP_PARAPROB 12
#define ICMP_TIMESTAMP 13
#define ICMP_TIMESTAMPREPLY 14
#define ICMP_INFOREQUEST 15
#define ICMP_INFOREPLY 16
/* ICMP code definitions. */
#define ICMP_UNREACH_NET 0
#define ICMP_UNREACH_HOST 1
#define ICMP_UNREACH_PROTOCOL 2
#define ICMP_UNREACH_PORT 3
#define ICMP_UNREACH_NEEDFRAG 4
#define ICMP_UNREACH_SRCFAIL 5
#define ICMP_TIMXCEED_TTL 0
#define ICMP_TIMXCEED_REASM 1
#define ICMP_PARAPROB_OFFSET 0
#define ICMP_REDIRECT_NET 0
#define ICMP_REDIRECT_HOST 1
#define ICMP_REDIRECT_TOSNET 2
#define ICMP_REDIRECT_TOSHOST 3
#define icmp_cache_num 1
/* Function Prototypes. */
void ICMP_Send_Error(UINT8 type, UINT8 code1, UINT8 * dest);
void ICMP_Init();
void ICMP_Send_Echo_Request( UINT8 *, UINT16);
//void ICMP_Echo_Reply (UINT8 *buf_ptr,UINT8 * IP_ADDR);
UINT8 ICMP_Interpret (UINT8* buf_ptr, UINT16 buf_size , UINT8 *ip_source);
void ICMP_dest_unreach_send(UINT8 *DD, UINT8 *IP_ADDR);
#endif /* ICMP_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -