Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / clients / net-snk / app / netlib / dhcp.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 _DHCP_H_
14 #define _DHCP_H_
15
16 #include <stdint.h>
17
18 #ifdef USE_MTFTP
19 #include <netlib/mtftp.h>
20 #else
21 #include <netlib/tftp.h>
22 #endif
23
24 /** \struct btphdr
25  *  A header for BootP/DHCP-messages.
26  *  For more information see RFC 951 / RFC 2131.
27  */
28 struct btphdr {
29         uint8_t op;          /**< Identifies is it request (1) or reply (2)    */
30         uint8_t htype;       /**< HW address type (ethernet usually)           */
31         uint8_t hlen;        /**< HW address length                            */
32         uint8_t hops;        /**< This info used by relay agents (not used)    */
33         uint32_t xid;        /**< This ID is used to match queries and replies */
34         uint16_t secs;       /**< Unused                                       */
35         uint16_t unused;     /**< Unused                                       */
36         uint32_t ciaddr;     /**< Client IP address (if client knows it)       */
37         uint32_t yiaddr;     /**< "Your" (client) IP address                   */
38         uint32_t siaddr;     /**< Next server IP address (TFTP server IP)      */
39         uint32_t giaddr;     /**< Gateway IP address (used by relay agents)    */
40         uint8_t chaddr[16];  /**< Client HW address                            */
41         uint8_t sname[64];   /**< Server host name (TFTP server name)          */
42         uint8_t file[128];   /**< Boot file name                               */
43         uint8_t vend[64];    /**< Optional parameters field (DHCP-options)     */
44 };
45
46 int bootp(char *ret_buffer, filename_ip_t *, unsigned int);
47 int dhcpv4(char *ret_buffer, filename_ip_t *);
48 void dhcp_send_release(int fd);
49
50 /* Handles DHCP-packets, which are detected by receive_ether. */
51 extern int8_t handle_dhcp(int fd, uint8_t * packet, int32_t packetsize);
52
53 #endif