1 | //////////////////////////////////////////////////////////////////////////////// |
---|
2 | // Copyright (c) 2004 Xilinx, Inc. All rights reserved. |
---|
3 | // |
---|
4 | // Xilinx, Inc. |
---|
5 | // XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A |
---|
6 | // COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS |
---|
7 | // ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR |
---|
8 | // STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION |
---|
9 | // IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE |
---|
10 | // FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. |
---|
11 | // XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO |
---|
12 | // THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO |
---|
13 | // ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE |
---|
14 | // FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY |
---|
15 | // AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
16 | // |
---|
17 | // File : udp.h |
---|
18 | // Date : 2002, March 20. |
---|
19 | // Author : Sathya Thammanur |
---|
20 | // Company: Xilinx |
---|
21 | // Group : Emerging Software Technologies |
---|
22 | // |
---|
23 | // Summary: |
---|
24 | // Header file for UDP |
---|
25 | // |
---|
26 | // $Id: udp.h,v 1.2.8.6 2005/11/15 23:41:10 salindac Exp $ |
---|
27 | // |
---|
28 | //////////////////////////////////////////////////////////////////////////////// |
---|
29 | |
---|
30 | //////////////////////////////////////////////////////////////////////////////// |
---|
31 | // see copyright.txt for Rice University/Mango Communications modifications |
---|
32 | //////////////////////////////////////////////////////////////////////////////// |
---|
33 | |
---|
34 | #ifndef _UDP_H |
---|
35 | #define _UDP_H |
---|
36 | |
---|
37 | #ifdef __cplusplus |
---|
38 | extern "C" { |
---|
39 | #endif |
---|
40 | |
---|
41 | #include <xilnet_ip.h> |
---|
42 | #include <xilnet_config.h> |
---|
43 | |
---|
44 | #define UDP_HDR_LEN 0x0008 /* 8-byte header */ |
---|
45 | #define NO_UDP_CHECKSUM 0x0000 /* No udp checksum is calculated */ |
---|
46 | #define IP_PROTO_UDP 17 /* protocol field in IP header */ |
---|
47 | #define UDP_STRIP_HDR 0x01 /* remove header for udp handler type */ |
---|
48 | #define UDP_ADD_HDR 0x02 /* add header for udp handler type */ |
---|
49 | #define UDP_PORT 69 /* tftp port no. */ |
---|
50 | #define UDP_DATA 1460 /* max possible udp data for ethernet */ |
---|
51 | |
---|
52 | // udp header structure |
---|
53 | struct xilnet_udp_hdr { |
---|
54 | unsigned short src_port; |
---|
55 | unsigned short dst_port; |
---|
56 | unsigned short udp_len; |
---|
57 | unsigned short check_sum; |
---|
58 | }; |
---|
59 | |
---|
60 | // udp packet |
---|
61 | struct xilnet_udp_pkt { |
---|
62 | struct xilnet_udp_hdr udp_hdr; |
---|
63 | unsigned char data[UDP_DATA]; |
---|
64 | }; |
---|
65 | |
---|
66 | // udp connection management |
---|
67 | |
---|
68 | |
---|
69 | #define UDP_CONN_OPEN 0 // waiting for client connection (only src port is known) |
---|
70 | #define UDP_CONN_CLOSED 1 // connection can be used |
---|
71 | #define UDP_CONN_ESTABLISHED 2 // full conn established (both src and dst ports are known) |
---|
72 | |
---|
73 | |
---|
74 | struct xilnet_udp_conn { |
---|
75 | unsigned short src_port; |
---|
76 | unsigned short dst_port; |
---|
77 | unsigned char src_ip[IP_VERSION]; |
---|
78 | unsigned char dst_ip[IP_VERSION]; |
---|
79 | unsigned char state; |
---|
80 | int fd; // socket descriptor into xsock_sockets table |
---|
81 | } ; |
---|
82 | |
---|
83 | extern struct xilnet_udp_conn xilnet_udp_conns[MAX_UDP_CONNS]; |
---|
84 | |
---|
85 | |
---|
86 | extern void xilnet_udp_init_conns(); |
---|
87 | |
---|
88 | #ifdef __cplusplus |
---|
89 | } |
---|
90 | #endif |
---|
91 | |
---|
92 | #endif /* _UDP_H */ |
---|