Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / clients / net-snk / app / netlib / udp.h
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 #ifndef _UDP_H
14 #define _UDP_H
15
16 #include <stdint.h>
17
18 #define IPTYPE_UDP         17
19
20 #define UDPPORT_BOOTPS     67   /**< UDP port of BootP/DHCP-server */
21 #define UDPPORT_BOOTPC     68   /**< UDP port of BootP/DHCP-client */
22 #define UDPPORT_DNSS       53   /**< UDP port of DNS-server        */
23 #define UDPPORT_DNSC    32769   /**< UDP port of DNS-client        */
24 #define UDPPORT_TFTPC    2001   /**< UDP port of TFTP-client       */
25 #define UDPPORT_DHCPV6C   546   /**< UDP port of DHCPv6-client     */
26
27 /** \struct udphdr
28  *  A header for UDP-packets.
29  *  For more information see RFC 768.
30  */
31 struct udphdr {
32         uint16_t uh_sport;   /**< Source port                                  */
33         uint16_t uh_dport;   /**< Destinantion port                            */
34         uint16_t uh_ulen;    /**< Length in octets, incl. this header and data */
35         uint16_t uh_sum;     /**< Checksum                                     */
36 };
37 typedef struct udphdr udp_hdr_t;
38
39 typedef int32_t *(*handle_upper_udp_t)(uint8_t *, int32_t);
40 typedef void    *(*handle_upper_udp_dun_t)(uint8_t);
41
42 /* Handles UDP-packets that are detected by any network layer. */
43 extern int8_t handle_udp(int fd, uint8_t * udp_packet, int32_t packetsize);
44
45 /* Handles UDP related ICMP-Dest.Unreachable packets that are detected by
46  * the network layers. */
47 extern void handle_udp_dun(uint8_t * udp_packet, uint32_t packetsize, uint8_t err_code);
48
49 /* fills udp header */
50 extern void fill_udphdr(uint8_t *packet, uint16_t packetsize,
51                         uint16_t src_port, uint16_t dest_port);
52
53 #ifdef USE_MTFTP
54 extern void net_set_tftp_port(uint16_t tftp_port);
55 extern void net_set_mtftp_port(uint16_t tftp_port);
56 #endif
57
58 #endif