[2229] | 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 | #include <xil_types.h> |
---|
| 44 | |
---|
| 45 | #define UDP_HDR_LEN 0x0008 /* 8-byte header */ |
---|
| 46 | #define NO_UDP_CHECKSUM 0x0000 /* No udp checksum is calculated */ |
---|
| 47 | #define IP_PROTO_UDP 17 /* protocol field in IP header */ |
---|
| 48 | #define UDP_STRIP_HDR 0x01 /* remove header for udp handler type */ |
---|
| 49 | #define UDP_ADD_HDR 0x02 /* add header for udp handler type */ |
---|
| 50 | #define UDP_PORT 69 /* tftp port no. */ |
---|
| 51 | #define UDP_DATA 1460 /* max possible udp data for ethernet */ |
---|
| 52 | |
---|
| 53 | // udp header structure |
---|
| 54 | struct xilnet_udp_hdr { |
---|
| 55 | unsigned short src_port; |
---|
| 56 | unsigned short dst_port; |
---|
| 57 | unsigned short udp_len; |
---|
| 58 | unsigned short check_sum; |
---|
| 59 | }; |
---|
| 60 | |
---|
| 61 | // udp packet |
---|
| 62 | struct xilnet_udp_pkt { |
---|
| 63 | struct xilnet_udp_hdr udp_hdr; |
---|
| 64 | unsigned char data[UDP_DATA]; |
---|
| 65 | }; |
---|
| 66 | |
---|
| 67 | typedef struct { |
---|
| 68 | u32 srcIPAddr; |
---|
| 69 | u16 srcPort; |
---|
| 70 | u16 destPort; |
---|
| 71 | } pktSrcInfo; |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | // udp connection management |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | #define UDP_CONN_OPEN 0 // waiting for client connection (only src port is known) |
---|
| 78 | #define UDP_CONN_CLOSED 1 // connection can be used |
---|
| 79 | #define UDP_CONN_ESTABLISHED 2 // full conn established (both src and dst ports are known) |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | struct xilnet_udp_conn { |
---|
| 83 | unsigned short src_port; |
---|
| 84 | unsigned short dst_port; |
---|
| 85 | unsigned char src_ip[IP_VERSION]; |
---|
| 86 | unsigned char dst_ip[IP_VERSION]; |
---|
| 87 | unsigned char state; |
---|
| 88 | unsigned char reserved; |
---|
| 89 | int fd; // socket descriptor into xsock_sockets table |
---|
| 90 | void (*rxCallback)(); |
---|
| 91 | } ; |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | #ifdef __cplusplus |
---|
| 95 | } |
---|
| 96 | #endif |
---|
| 97 | |
---|
| 98 | #endif /* _UDP_H */ |
---|