00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef UDP_H_
00012 #define UDP_H_
00013
00014 #ifdef __INET__
00015
00016 struct s_udp_pcb;
00017
00018 struct s_udp_datagram
00019 {
00020 TAILQ_ENTRY(s_udp_datagram) udp_next;
00021 struct s_udp_pcb *udp_pcb;
00022 struct sockaddr_in udp_sin;
00023 struct s_data_buf *udp_data;
00024 int64_t udp_ar;
00025 size_t udp_data_size;
00026 };
00027
00028 TAILQ_HEAD(s_udp_datagramq, s_udp_datagram);
00029
00030 struct s_udp_pcb
00031 {
00032 LIST_ENTRY(s_udp_pcb) udp_next;
00033 int udp_lock;
00034 struct s_in_pcb *udp_in_pcb;
00035 int64_t udp_holders;
00036
00037 struct s_udp_datagramq udp_rcvq;
00038 struct s_udp_datagramq udp_sndq;
00039 };
00040
00041 LIST_HEAD(s_udp_pcb_list, s_udp_pcb);
00042
00043 struct s_udp_proto_info
00044 {
00045 struct s_in_pcb_list in_pcb_list;
00046 struct s_udp_pcb_list udp_pcb_list;
00047 };
00048
00049 extern struct s_udp_proto_info udp_proto_info;
00050
00051 #endif
00052
00053 struct s_udp_hdr
00054 {
00055 u_int16_t udp_sp;
00056 u_int16_t udp_dp;
00057 u_int16_t udp_len;
00058 u_int16_t udp_sum;
00059 };
00060
00061 #define UDP_HEADER_LEN sizeof (struct s_udp_hdr)
00062
00063
00064 #ifdef __INET__
00065
00066 void udp_proto_init(void);
00067 void udp_dump(struct s_pkbuf *pk);
00068 int aa_udp_send(struct s_udp_datagram *datagram);
00069 int udp_output(struct s_pkbuf *pk);
00070 int aa_udp_input(struct s_pkbuf *pk);
00071 int aa_udp_close(struct s_udp_pcb *pcb);
00072
00073 int udp_detach(struct s_socket *so);
00074 int udp_attach(struct s_socket *so);
00075 int udp_poll(struct s_socket *so, t_pollrec *pollrec);
00076 int udp_bind(struct s_socket *so, struct sockaddr *sa, socklen_t salen);
00077 int udp_connect(struct s_socket *so, struct sockaddr *sa, socklen_t salen);
00078 int udp_send(struct s_socket *so, struct s_data_buf *data, size_t data_size, struct sockaddr *sa, socklen_t salen);
00079 size_t udp_recv(struct s_socket *so, pid_t pid, struct sockaddr *sa, socklen_t *salen, vaddr_t uaddr, size_t usize);
00080 int udp_getpeername(struct s_socket *so, struct sockaddr *sa, socklen_t *salen);
00081 int udp_getsockname(struct s_socket *so, struct sockaddr *sa, socklen_t *salen);
00082 #endif
00083 #endif