00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ICMP_H_
00012 #define ICMP_H_
00013
00014 struct s_icmp_hdr
00015 {
00016 u_int8_t icmp_type;
00017 u_int8_t icmp_code;
00018 u_int16_t icmp_sum;
00019 union {
00020 struct {
00021 u_int16_t icmp_id;
00022 u_int16_t icmp_seq;
00023 } icmp_echo;
00024 u_int32_t icmp_gw;
00025 struct {
00026 u_int16_t icmp_unused;
00027 u_int16_t icmp_mtu;
00028 } icmp_frag;
00029 } icmp_info;
00030 } __attribute__ ((packed));
00031
00032 #define ICMP_HEADER_LEN sizeof (struct s_icmp_hdr)
00033
00034 #ifdef __INET__
00035
00036 struct s_icmp_action
00037 {
00038 u_int8_t icmp_type;
00039 void (*icmp_action)(struct s_pkbuf *pk);
00040 };
00041
00042 struct s_icmp_snd
00043 {
00044 TAILQ_ENTRY(s_icmp_snd) icmp_next;
00045 struct s_data_buf *icmp_data;
00046 size_t icmp_data_size;
00047 };
00048
00049 TAILQ_HEAD(s_icmp_sndq, s_icmp_snd);
00050
00051 struct s_icmp_pcb
00052 {
00053 LIST_ENTRY(s_icmp_pcb) icmp_next;
00054 int icmp_lock;
00055 struct s_in_pcb *icmp_in_pcb;
00056 struct s_pkq icmp_rcvq;
00057 struct s_icmp_sndq icmp_sndq;
00058 int64_t icmp_holders;
00059 };
00060
00061 LIST_HEAD(s_icmp_pcb_list, s_icmp_pcb);
00062
00063 struct s_icmp_proto_info
00064 {
00065 struct s_in_pcb_list in_pcb;
00066 struct s_icmp_pcb_list icmp_pcb;
00067 };
00068
00069 #endif
00070
00071
00072
00073
00074
00075 #define ICMP_REPLY 0
00076 #define ICMP_ECHO 8
00077 #define ICMP_DEST_UNREACH 3
00078
00079
00080
00081
00082
00083 #define ICMP_NET_UNREACH 0
00084 #define ICMP_HOST_UNREACH 1
00085 #define ICMP_PROT_UNREACH 2
00086 #define ICMP_PORT_UNREACH 3
00087 #define ICMP_FRAG_NEEDED 4
00088 #define ICMP_SR_FAILED 5
00089 #define ICMP_NET_UNKNOWN 6
00090 #define ICMP_HOST_UNKNOWN 7
00091 #define ICMP_HOST_ISOLATED 8
00092 #define ICMP_NET_ANO 9
00093 #define ICMP_HOST_ANO 10
00094 #define ICMP_NET_UNR_TOS 11
00095 #define ICMP_HOST_UNR_TOS 12
00096 #define ICMP_PKT_FILTERED 13
00097 #define ICMP_PREC_VIOLATION 14
00098 #define ICMP_PREC_CUTOFF 15
00099 #define NR_ICMP_UNREACH 15
00100
00101
00102 #ifdef __INET__
00103
00104 void icmp_proto_init(void);
00105 int icmp_attach(struct s_socket *so);
00106 int icmp_detach(struct s_socket *so);
00107 int icmp_send(struct s_socket *so, struct s_data_buf *data, size_t data_size, struct sockaddr *sa, socklen_t salen);
00108 size_t icmp_recv(struct s_socket *so, pid_t pid, struct sockaddr *sa, socklen_t *salen, vaddr_t uaddr, size_t usize);
00109 void icmp_unreach_send(struct in_addr *dst_addr, u_int8_t code);
00110 void icmp_echo(struct s_pkbuf *pk);
00111 void icmp_dump(struct s_pkbuf *pk);
00112 int aa_icmp_input(struct s_pkbuf *pk);
00113 #endif
00114 #endif