////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2004 Xilinx, Inc.  All rights reserved. 
// 
// Xilinx, Inc. 
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 
// COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS 
// ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 
// STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION 
// IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 
// FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. 
// XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 
// THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 
// ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 
// FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE. 
// 
// File   : udp.h
// Date   : 2002, March 20.
// Author : Sathya Thammanur
// Company: Xilinx
// Group  : Emerging Software Technologies
//
// Summary:
// Header file for UDP
//
// $Id: udp.h,v 1.2 2004/07/28 18:26:51 sathya Exp $
//
////////////////////////////////////////////////////////////////////////////////

#ifndef _UDP_H
#define _UDP_H

#include <net/ip.h>

#define UDP_HDR_LEN         0x0008      /* 8-byte header */
#define NO_UDP_CHECKSUM     0x0000      /* No udp checksum is calculated */
#define IP_PROTO_UDP        17          /* protocol field in IP header */ 
#define UDP_STRIP_HDR       0x01        /* remove header for udp handler type */
#define UDP_ADD_HDR         0x02        /* add header for udp handler type */
#define UDP_PORT            69          /* tftp port no. */
#define UDP_DATA            1460        /* max possible udp data for ethernet */

// udp header structure
struct xilnet_udp_hdr {
  unsigned short src_port;
  unsigned short dst_port;
  unsigned short udp_len;
  unsigned short check_sum;
};

// udp packet
struct xilnet_udp_pkt {
  struct xilnet_udp_hdr udp_hdr;
  unsigned char data[UDP_DATA];
};

// udp connection management

#define MAX_UDP_CONNS         5      // maximum no of open udp conns
#define UDP_CONN_OPEN         0      // waiting for client connection (only src port is known)
#define UDP_CONN_CLOSED       1      // connection can be used 
#define UDP_CONN_ESTABLISHED  2      // full conn established (both src and dst ports are known)


struct xilnet_udp_conn {
   unsigned short src_port;
   unsigned short dst_port;
   unsigned char src_ip[IP_VERSION];
   unsigned char dst_ip[IP_VERSION];
   unsigned char state;
   int fd; // socket descriptor into xsock_sockets table
} ;

extern struct xilnet_udp_conn xilnet_udp_conns[MAX_UDP_CONNS];


extern void xilnet_udp_init_conns();

#endif	/* _UDP_H */
