blob: 4e32b19d424bee075d95614c1fd4ffb85350ee67 [file] [log] [blame]
wdenkefee1702002-07-20 20:14:13 +00001/*
2 * Copied from LiMon - BOOTP.
3 *
4 * Copyright 1994, 1995, 2000 Neil Russell.
5 * (See License)
6 * Copyright 2000 Paolo Scaffardi
7 */
8
9#ifndef __BOOTP_H__
10#define __BOOTP_H__
11
12#ifndef __NET_H__
Joe Hershberger3090b7e32012-05-15 08:59:06 +000013#include <net.h>
wdenkefee1702002-07-20 20:14:13 +000014#endif /* __NET_H__ */
15
16/**********************************************************************/
17
Sean Anderson7ccc6042023-10-14 16:47:52 -040018#define PORT_BOOTPS 67 /* BOOTP server UDP port */
19#define PORT_BOOTPC 68 /* BOOTP client UDP port */
20
wdenkefee1702002-07-20 20:14:13 +000021/*
22 * BOOTP header.
23 */
Jon Loeliger643d1ab2007-07-09 17:45:14 -050024#if defined(CONFIG_CMD_DHCP)
Joe Hershberger3090b7e32012-05-15 08:59:06 +000025/* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */
Joe Hershbergerf8315732012-05-23 07:58:14 +000026#define OPT_FIELD_SIZE 312
Joe Hershberger3090b7e32012-05-15 08:59:06 +000027#if defined(CONFIG_BOOTP_VENDOREX)
28extern u8 *dhcp_vendorex_prep(u8 *e); /*rtn new e after add own opts. */
29extern u8 *dhcp_vendorex_proc(u8 *e); /*rtn next e if mine,else NULL */
30#endif
wdenkefee1702002-07-20 20:14:13 +000031#else
Joe Hershbergerf8315732012-05-23 07:58:14 +000032#define OPT_FIELD_SIZE 64
wdenkefee1702002-07-20 20:14:13 +000033#endif
34
Joe Hershberger7044c6b2015-04-08 01:41:09 -050035struct bootp_hdr {
Sergey Temerkhanov717234e2015-04-08 01:41:23 -050036 u8 bp_op; /* Operation */
wdenkefee1702002-07-20 20:14:13 +000037# define OP_BOOTREQUEST 1
38# define OP_BOOTREPLY 2
Sergey Temerkhanov717234e2015-04-08 01:41:23 -050039 u8 bp_htype; /* Hardware type */
wdenkefee1702002-07-20 20:14:13 +000040# define HWT_ETHER 1
Sergey Temerkhanov717234e2015-04-08 01:41:23 -050041 u8 bp_hlen; /* Hardware address length */
wdenkefee1702002-07-20 20:14:13 +000042# define HWL_ETHER 6
Sergey Temerkhanov717234e2015-04-08 01:41:23 -050043 u8 bp_hops; /* Hop count (gateway thing) */
Sergey Temerkhanov5917e7d2015-04-08 01:41:22 -050044 u32 bp_id; /* Transaction ID */
Sergey Temerkhanov717234e2015-04-08 01:41:23 -050045 u16 bp_secs; /* Seconds since boot */
46 u16 bp_spare1; /* Alignment */
Joe Hershberger049a95a2015-04-08 01:41:01 -050047 struct in_addr bp_ciaddr; /* Client IP address */
48 struct in_addr bp_yiaddr; /* Your (client) IP address */
49 struct in_addr bp_siaddr; /* Server IP address */
50 struct in_addr bp_giaddr; /* Gateway IP address */
Sergey Temerkhanov717234e2015-04-08 01:41:23 -050051 u8 bp_chaddr[16]; /* Client hardware address */
Joe Hershberger3090b7e32012-05-15 08:59:06 +000052 char bp_sname[64]; /* Server host name */
53 char bp_file[128]; /* Boot file name */
Joe Hershbergerf8315732012-05-23 07:58:14 +000054 char bp_vend[OPT_FIELD_SIZE]; /* Vendor information */
Denis Pynkin704f3ac2017-07-21 19:28:42 +030055} __attribute__((packed));
wdenkefee1702002-07-20 20:14:13 +000056
Joe Hershberger7044c6b2015-04-08 01:41:09 -050057#define BOOTP_HDR_SIZE sizeof(struct bootp_hdr)
wdenkefee1702002-07-20 20:14:13 +000058
59/**********************************************************************/
60/*
61 * Global functions and variables.
62 */
63
64/* bootp.c */
Sergey Temerkhanov5917e7d2015-04-08 01:41:22 -050065extern u32 bootp_id; /* ID of cur BOOTP request */
Joe Hershberger7044c6b2015-04-08 01:41:09 -050066extern int bootp_try;
wdenkefee1702002-07-20 20:14:13 +000067
68
69/* Send a BOOTP request */
Joe Hershberger7044c6b2015-04-08 01:41:09 -050070void bootp_reset(void);
71void bootp_request(void);
wdenkefee1702002-07-20 20:14:13 +000072
73/****************** DHCP Support *********************/
Joe Hershberger7044c6b2015-04-08 01:41:09 -050074void dhcp_request(void);
wdenkefee1702002-07-20 20:14:13 +000075
76/* DHCP States */
77typedef enum { INIT,
78 INIT_REBOOT,
79 REBOOTING,
80 SELECTING,
81 REQUESTING,
82 REBINDING,
83 BOUND,
84 RENEWING } dhcp_state_t;
85
86#define DHCP_DISCOVER 1
87#define DHCP_OFFER 2
88#define DHCP_REQUEST 3
89#define DHCP_DECLINE 4
90#define DHCP_ACK 5
91#define DHCP_NAK 6
92#define DHCP_RELEASE 7
93
wdenkefee1702002-07-20 20:14:13 +000094/**********************************************************************/
95
96#endif /* __BOOTP_H__ */