1 #ifndef __UIP_ICMP_H__ 2 #define __UIP_ICMP_H__ 3 4 #include "uip.h" 5 #include "uip_arch.h" 6 7 #define UIP_ICMP_TTL 255 8 9 #define UIP_ICMP_ER 0 /* echo reply */ 10 #define UIP_ICMP_DUR 3 /* destination unreachable */ 11 #define UIP_ICMP_SQ 4 /* source quench */ 12 #define UIP_ICMP_RD 5 /* redirect */ 13 #define UIP_ICMP_ECHO 8 /* echo */ 14 #define UIP_ICMP_TE 11 /* time exceeded */ 15 #define UIP_ICMP_PP 12 /* parameter problem */ 16 #define UIP_ICMP_TS 13 /* timestamp */ 17 #define UIP_ICMP_TSR 14 /* timestamp reply */ 18 #define UIP_ICMP_IRQ 15 /* information request */ 19 #define UIP_ICMP_IR 16 /* information reply */ 20 21 #define UIP_ICMPH_TYPE(hdr) (ntohs((hdr)->_type_code) >> 8) 22 #define UIP_ICMPH_CODE(hdr) (ntohs((hdr)->_type_code) & 0xff) 23 24 #define UIP_ICMPH_TYPE_SET(hdr, type) ((hdr)->_type_code = htons(UIP_ICMPH_CODE(hdr) | ((type) << 8))) 25 #define UIP_ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (UIP_ICMPH_TYPE(hdr) << 8))) 26 27 enum uip_icmp_dur_type { 28 UIP_ICMP_DUR_NET = 0, /* net unreachable */ 29 UIP_ICMP_DUR_HOST = 1, /* host unreachable */ 30 UIP_ICMP_DUR_PROTO = 2, /* protocol unreachable */ 31 UIP_ICMP_DUR_PORT = 3, /* port unreachable */ 32 UIP_ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ 33 UIP_ICMP_DUR_SR = 5 /* source route failed */ 34 }; 35 36 PACK_STRUCT_BEGIN 37 struct uip_icmp_echo_hdr { 38 PACK_STRUCT_FIELD(u16_t _type_code); 39 PACK_STRUCT_FIELD(u16_t chksum); 40 PACK_STRUCT_FIELD(u16_t id); 41 PACK_STRUCT_FIELD(u16_t seqno); 42 } PACK_STRUCT_STRUCT; 43 PACK_STRUCT_END 44 45 PACK_STRUCT_BEGIN 46 struct uip_icmp_dur_hdr { 47 PACK_STRUCT_FIELD(u16_t _type_code); 48 PACK_STRUCT_FIELD(u16_t chksum); 49 PACK_STRUCT_FIELD(u32_t unused); 50 } PACK_STRUCT_STRUCT; 51 PACK_STRUCT_END 52 53 struct uip_pbuf; 54 struct uip_netif; 55 56 void uip_icmpinput(struct uip_pbuf *p,struct uip_netif *inp); 57 void uip_icmp_destunreach(struct uip_pbuf *p,enum uip_icmp_dur_type t); 58 59 #endif 60