00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __LWIP_ICMP_H__
00036 #define __LWIP_ICMP_H__
00037
00038 #include "net/arch.h"
00039
00040 #include "net/opt.h"
00041 #include "net/pbuf.h"
00042
00043 #include "net/netif.h"
00044
00045 #define ICMP_ER 0
00046 #define ICMP_DUR 3
00047 #define ICMP_SQ 4
00048 #define ICMP_RD 5
00049 #define ICMP_ECHO 8
00050 #define ICMP_TE 11
00051 #define ICMP_PP 12
00052 #define ICMP_TS 13
00053 #define ICMP_TSR 14
00054 #define ICMP_IRQ 15
00055 #define ICMP_IR 16
00056
00057 enum icmp_dur_type {
00058 ICMP_DUR_NET = 0,
00059 ICMP_DUR_HOST = 1,
00060 ICMP_DUR_PROTO = 2,
00061 ICMP_DUR_PORT = 3,
00062 ICMP_DUR_FRAG = 4,
00063 ICMP_DUR_SR = 5
00064 };
00065
00066 enum icmp_te_type {
00067 ICMP_TE_TTL = 0,
00068 ICMP_TE_FRAG = 1
00069 };
00070
00071 void icmp_input(struct pbuf *p, struct netif *inp);
00072
00073 void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
00074 void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
00075
00076 struct icmp_echo_hdr {
00077 PACK_STRUCT_FIELD(uInt16 _type_code);
00078 PACK_STRUCT_FIELD(uInt16 chksum);
00079 PACK_STRUCT_FIELD(uInt16 id);
00080 PACK_STRUCT_FIELD(uInt16 seqno);
00081 } PACK_STRUCT_STRUCT;
00082
00083
00084
00085 struct icmp_dur_hdr {
00086 PACK_STRUCT_FIELD(uInt16 _type_code);
00087 PACK_STRUCT_FIELD(uInt16 chksum);
00088 PACK_STRUCT_FIELD(uInt32 unused);
00089 } PACK_STRUCT_STRUCT;
00090
00091 struct icmp_te_hdr {
00092 PACK_STRUCT_FIELD(uInt16 _type_code);
00093 PACK_STRUCT_FIELD(uInt16 chksum);
00094 PACK_STRUCT_FIELD(uInt32 unused);
00095 } PACK_STRUCT_STRUCT;
00096
00097 #define ICMPH_TYPE(hdr) (NTOHS((hdr)->_type_code) >> 8)
00098 #define ICMPH_CODE(hdr) (NTOHS((hdr)->_type_code) & 0xff)
00099
00100 #define ICMPH_TYPE_SET(hdr, type) ((hdr)->_type_code = HTONS(ICMPH_CODE(hdr) | ((type) << 8)))
00101 #define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = HTONS((code) | (ICMPH_TYPE(hdr) << 8)))
00102
00103 #endif
00104