wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Based on LiMon - BOOTP. |
| 3 | * |
| 4 | * Copyright 1994, 1995, 2000 Neil Russell. |
| 5 | * (See License) |
| 6 | * Copyright 2000 Roland Borde |
| 7 | * Copyright 2000 Paolo Scaffardi |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 8 | * Copyright 2000-2004 Wolfgang Denk, wd@denx.de |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 11 | #include <common.h> |
| 12 | #include <command.h> |
| 13 | #include <net.h> |
| 14 | #include "bootp.h" |
| 15 | #include "tftp.h" |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 16 | #include "nfs.h" |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 17 | #ifdef CONFIG_STATUS_LED |
| 18 | #include <status_led.h> |
| 19 | #endif |
Anatolij Gustschin | c0fe04b | 2011-11-19 10:29:58 +0000 | [diff] [blame] | 20 | #include <linux/compiler.h> |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 21 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 22 | #define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 23 | |
Bartlomiej Sieka | 49f3bdb | 2008-10-01 15:26:28 +0200 | [diff] [blame] | 24 | #define TIMEOUT 5000UL /* Milliseconds before trying BOOTP again */ |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 25 | #ifndef CONFIG_NET_RETRY_COUNT |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 26 | # define TIMEOUT_COUNT 5 /* # of timeouts before giving up */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 27 | #else |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 28 | # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 29 | #endif |
| 30 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 31 | #define PORT_BOOTPS 67 /* BOOTP server UDP port */ |
| 32 | #define PORT_BOOTPC 68 /* BOOTP client UDP port */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 33 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 34 | #ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */ |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 35 | #define CONFIG_DHCP_MIN_EXT_LEN 64 |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 36 | #endif |
| 37 | |
| 38 | ulong BootpID; |
| 39 | int BootpTry; |
| 40 | #ifdef CONFIG_BOOTP_RANDOM_DELAY |
| 41 | ulong seed1, seed2; |
| 42 | #endif |
| 43 | |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 44 | #if defined(CONFIG_CMD_DHCP) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 45 | dhcp_state_t dhcp_state = INIT; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 46 | unsigned long dhcp_leasetime; |
| 47 | IPaddr_t NetDHCPServerIP; |
Luca Ceresoli | 03eb129 | 2011-04-18 06:19:50 +0000 | [diff] [blame] | 48 | static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, |
| 49 | unsigned len); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 50 | |
| 51 | /* For Debug */ |
wdenk | 3e38691 | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 52 | #if 0 |
| 53 | static char *dhcpmsg2str(int type) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 54 | { |
| 55 | switch (type) { |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 56 | case 1: return "DHCPDISCOVER"; break; |
| 57 | case 2: return "DHCPOFFER"; break; |
| 58 | case 3: return "DHCPREQUEST"; break; |
| 59 | case 4: return "DHCPDECLINE"; break; |
| 60 | case 5: return "DHCPACK"; break; |
| 61 | case 6: return "DHCPNACK"; break; |
| 62 | case 7: return "DHCPRELEASE"; break; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 63 | default: return "UNKNOWN/INVALID MSG TYPE"; break; |
| 64 | } |
| 65 | } |
wdenk | 3e38691 | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 66 | #endif |
Jon Loeliger | 610f2e9 | 2007-07-10 11:05:02 -0500 | [diff] [blame] | 67 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 68 | |
| 69 | static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len) |
| 70 | { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 71 | struct Bootp_t *bp = (struct Bootp_t *) pkt; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 72 | int retval = 0; |
| 73 | |
| 74 | if (dest != PORT_BOOTPC || src != PORT_BOOTPS) |
| 75 | retval = -1; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 76 | else if (len < sizeof(struct Bootp_t) - OPT_SIZE) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 77 | retval = -2; |
| 78 | else if (bp->bp_op != OP_BOOTREQUEST && |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 79 | bp->bp_op != OP_BOOTREPLY && |
| 80 | bp->bp_op != DHCP_OFFER && |
| 81 | bp->bp_op != DHCP_ACK && |
| 82 | bp->bp_op != DHCP_NAK) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 83 | retval = -3; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 84 | else if (bp->bp_htype != HWT_ETHER) |
| 85 | retval = -4; |
| 86 | else if (bp->bp_hlen != HWL_ETHER) |
| 87 | retval = -5; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 88 | else if (NetReadLong((ulong *)&bp->bp_id) != BootpID) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 89 | retval = -6; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 90 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 91 | debug("Filtering pkt = %d\n", retval); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 92 | |
| 93 | return retval; |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet |
| 98 | */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 99 | static void BootpCopyNetParams(struct Bootp_t *bp) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 100 | { |
Anatolij Gustschin | c0fe04b | 2011-11-19 10:29:58 +0000 | [diff] [blame] | 101 | __maybe_unused IPaddr_t tmp_ip; |
wdenk | 3d3befa | 2004-03-14 15:06:13 +0000 | [diff] [blame] | 102 | |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 103 | NetCopyIP(&NetOurIP, &bp->bp_yiaddr); |
Wilson Callan | 5d110f0 | 2007-07-28 10:56:13 -0400 | [diff] [blame] | 104 | #if !defined(CONFIG_BOOTP_SERVERIP) |
wdenk | 3d3befa | 2004-03-14 15:06:13 +0000 | [diff] [blame] | 105 | NetCopyIP(&tmp_ip, &bp->bp_siaddr); |
| 106 | if (tmp_ip != 0) |
| 107 | NetCopyIP(&NetServerIP, &bp->bp_siaddr); |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 108 | memcpy(NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6); |
Wilson Callan | 5d110f0 | 2007-07-28 10:56:13 -0400 | [diff] [blame] | 109 | #endif |
wdenk | 3d3befa | 2004-03-14 15:06:13 +0000 | [diff] [blame] | 110 | if (strlen(bp->bp_file) > 0) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 111 | copy_filename(BootFile, bp->bp_file, sizeof(BootFile)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 112 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 113 | debug("Bootfile: %s\n", BootFile); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 114 | |
| 115 | /* Propagate to environment: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 116 | * don't delete exising entry when BOOTP / DHCP reply does |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 117 | * not contain a new value |
| 118 | */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 119 | if (*BootFile) |
| 120 | setenv("bootfile", BootFile); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 121 | } |
| 122 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 123 | static int truncate_sz(const char *name, int maxlen, int curlen) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 124 | { |
| 125 | if (curlen >= maxlen) { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 126 | printf("*** WARNING: %s is too long (%d - max: %d)" |
| 127 | " - truncated\n", name, curlen, maxlen); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 128 | curlen = maxlen - 1; |
| 129 | } |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 130 | return curlen; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 133 | #if !defined(CONFIG_CMD_DHCP) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 134 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 135 | static void BootpVendorFieldProcess(u8 *ext) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 136 | { |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 137 | int size = *(ext + 1); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 138 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 139 | debug("[BOOTP] Processing extension %d... (%d bytes)\n", *ext, |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 140 | *(ext + 1)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 141 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 142 | NetBootFileSize = 0; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 143 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 144 | switch (*ext) { |
| 145 | /* Fixed length fields */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 146 | case 1: /* Subnet mask */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 147 | if (NetOurSubnetMask == 0) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 148 | NetCopyIP(&NetOurSubnetMask, (IPaddr_t *) (ext + 2)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 149 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 150 | case 2: /* Time offset - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 151 | break; |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 152 | /* Variable length fields */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 153 | case 3: /* Gateways list */ |
| 154 | if (NetOurGatewayIP == 0) |
| 155 | NetCopyIP(&NetOurGatewayIP, (IPaddr_t *) (ext + 2)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 156 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 157 | case 4: /* Time server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 158 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 159 | case 5: /* IEN-116 name server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 160 | break; |
| 161 | case 6: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 162 | if (NetOurDNSIP == 0) |
| 163 | NetCopyIP(&NetOurDNSIP, (IPaddr_t *) (ext + 2)); |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 164 | #if defined(CONFIG_BOOTP_DNS2) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 165 | if ((NetOurDNS2IP == 0) && (size > 4)) |
| 166 | NetCopyIP(&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4)); |
stroese | fe389a8 | 2003-08-28 14:17:32 +0000 | [diff] [blame] | 167 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 168 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 169 | case 7: /* Log server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 170 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 171 | case 8: /* Cookie/Quote server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 172 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 173 | case 9: /* LPR server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 174 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 175 | case 10: /* Impress server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 176 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 177 | case 11: /* RPL server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 178 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 179 | case 12: /* Host name */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 180 | if (NetOurHostName[0] == 0) { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 181 | size = truncate_sz("Host Name", |
| 182 | sizeof(NetOurHostName), size); |
| 183 | memcpy(&NetOurHostName, ext + 2, size); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 184 | NetOurHostName[size] = 0; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 185 | } |
| 186 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 187 | case 13: /* Boot file size */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 188 | if (size == 2) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 189 | NetBootFileSize = ntohs(*(ushort *) (ext + 2)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 190 | else if (size == 4) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 191 | NetBootFileSize = ntohl(*(ulong *) (ext + 2)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 192 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 193 | case 14: /* Merit dump file - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 194 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 195 | case 15: /* Domain name - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 196 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 197 | case 16: /* Swap server - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 198 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 199 | case 17: /* Root path */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 200 | if (NetOurRootPath[0] == 0) { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 201 | size = truncate_sz("Root Path", |
| 202 | sizeof(NetOurRootPath), size); |
| 203 | memcpy(&NetOurRootPath, ext + 2, size); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 204 | NetOurRootPath[size] = 0; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 205 | } |
| 206 | break; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 207 | case 18: /* Extension path - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 208 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 209 | * This can be used to send the information of the |
| 210 | * vendor area in another file that the client can |
| 211 | * access via TFTP. |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 212 | */ |
| 213 | break; |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 214 | /* IP host layer fields */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 215 | case 40: /* NIS Domain name */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 216 | if (NetOurNISDomain[0] == 0) { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 217 | size = truncate_sz("NIS Domain Name", |
| 218 | sizeof(NetOurNISDomain), size); |
| 219 | memcpy(&NetOurNISDomain, ext + 2, size); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 220 | NetOurNISDomain[size] = 0; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 221 | } |
| 222 | break; |
Luuk Paulussen | 09e3a67 | 2011-05-16 18:29:19 +0000 | [diff] [blame] | 223 | #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER) |
| 224 | case 42: /* NTP server IP */ |
| 225 | NetCopyIP(&NetNtpServerIP, (IPaddr_t *) (ext + 2)); |
| 226 | break; |
| 227 | #endif |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 228 | /* Application layer fields */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 229 | case 43: /* Vendor specific info - Not yet supported */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 230 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 231 | * Binary information to exchange specific |
| 232 | * product information. |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 233 | */ |
| 234 | break; |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 235 | /* Reserved (custom) fields (128..254) */ |
| 236 | } |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 239 | static void BootpVendorProcess(u8 *ext, int size) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 240 | { |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 241 | u8 *end = ext + size; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 242 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 243 | debug("[BOOTP] Checking extension (%d bytes)...\n", size); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 244 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 245 | while ((ext < end) && (*ext != 0xff)) { |
| 246 | if (*ext == 0) { |
| 247 | ext++; |
| 248 | } else { |
| 249 | u8 *opt = ext; |
| 250 | |
| 251 | ext += ext[1] + 2; |
| 252 | if (ext <= end) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 253 | BootpVendorFieldProcess(opt); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 254 | } |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 255 | } |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 256 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 257 | debug("[BOOTP] Received fields:\n"); |
Mike Frysinger | b6446b6 | 2009-02-17 00:00:53 -0500 | [diff] [blame] | 258 | if (NetOurSubnetMask) |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 259 | debug("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 260 | |
Mike Frysinger | b6446b6 | 2009-02-17 00:00:53 -0500 | [diff] [blame] | 261 | if (NetOurGatewayIP) |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 262 | debug("NetOurGatewayIP : %pI4", &NetOurGatewayIP); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 263 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 264 | if (NetBootFileSize) |
| 265 | debug("NetBootFileSize : %d\n", NetBootFileSize); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 266 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 267 | if (NetOurHostName[0]) |
| 268 | debug("NetOurHostName : %s\n", NetOurHostName); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 269 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 270 | if (NetOurRootPath[0]) |
| 271 | debug("NetOurRootPath : %s\n", NetOurRootPath); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 272 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 273 | if (NetOurNISDomain[0]) |
| 274 | debug("NetOurNISDomain : %s\n", NetOurNISDomain); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 275 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 276 | if (NetBootFileSize) |
| 277 | debug("NetBootFileSize: %d\n", NetBootFileSize); |
Luuk Paulussen | 09e3a67 | 2011-05-16 18:29:19 +0000 | [diff] [blame] | 278 | |
| 279 | #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER) |
| 280 | if (NetNtpServerIP) |
| 281 | debug("NetNtpServerIP : %pI4\n", &NetNtpServerIP); |
| 282 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 283 | } |
Simon Glass | 0934986 | 2011-06-13 16:13:12 -0700 | [diff] [blame] | 284 | |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 285 | /* |
| 286 | * Handle a BOOTP received packet. |
| 287 | */ |
| 288 | static void |
Luca Ceresoli | 03eb129 | 2011-04-18 06:19:50 +0000 | [diff] [blame] | 289 | BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, |
| 290 | unsigned len) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 291 | { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 292 | struct Bootp_t *bp; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 293 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 294 | debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n", |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 295 | src, dest, len, sizeof(struct Bootp_t)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 296 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 297 | bp = (struct Bootp_t *)pkt; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 298 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 299 | /* Filter out pkts we don't want */ |
| 300 | if (BootpCheckPkt(pkt, dest, src, len)) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 301 | return; |
| 302 | |
| 303 | /* |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 304 | * Got a good BOOTP reply. Copy the data into our variables. |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 305 | */ |
| 306 | #ifdef CONFIG_STATUS_LED |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 307 | status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 308 | #endif |
| 309 | |
| 310 | BootpCopyNetParams(bp); /* Store net parameters from reply */ |
| 311 | |
| 312 | /* Retrieve extended information (we must parse the vendor area) */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 313 | if (NetReadLong((ulong *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 314 | BootpVendorProcess((uchar *)&bp->bp_vend[4], len); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 315 | |
| 316 | NetSetTimeout(0, (thand_f *)0); |
Simon Glass | 573f14f | 2011-12-10 11:08:06 +0000 | [diff] [blame] | 317 | bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, "bootp_stop"); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 318 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 319 | debug("Got good BOOTP\n"); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 320 | |
Simon Glass | e4a3d57 | 2011-10-27 06:24:32 +0000 | [diff] [blame] | 321 | net_auto_load(); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 322 | } |
Jon Loeliger | 610f2e9 | 2007-07-10 11:05:02 -0500 | [diff] [blame] | 323 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 324 | |
| 325 | /* |
| 326 | * Timeout on BOOTP/DHCP request. |
| 327 | */ |
| 328 | static void |
| 329 | BootpTimeout(void) |
| 330 | { |
| 331 | if (BootpTry >= TIMEOUT_COUNT) { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 332 | puts("\nRetry count exceeded; starting again\n"); |
| 333 | NetStartAgain(); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 334 | } else { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 335 | NetSetTimeout(TIMEOUT, BootpTimeout); |
| 336 | BootpRequest(); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 337 | } |
| 338 | } |
| 339 | |
| 340 | /* |
| 341 | * Initialize BOOTP extension fields in the request. |
| 342 | */ |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 343 | #if defined(CONFIG_CMD_DHCP) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 344 | static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, |
| 345 | IPaddr_t RequestedIP) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 346 | { |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 347 | u8 *start = e; |
| 348 | u8 *cnt; |
Jason Hobbs | d2b5d5c | 2011-08-31 05:37:31 +0000 | [diff] [blame] | 349 | #if defined(CONFIG_BOOTP_PXE) |
| 350 | char *uuid; |
| 351 | size_t vci_strlen; |
| 352 | u16 clientarch; |
| 353 | #endif |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 354 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 355 | #if defined(CONFIG_BOOTP_VENDOREX) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 356 | u8 *x; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 357 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 358 | #if defined(CONFIG_BOOTP_SEND_HOSTNAME) |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 359 | char *hostname; |
stroese | fe389a8 | 2003-08-28 14:17:32 +0000 | [diff] [blame] | 360 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 361 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 362 | *e++ = 99; /* RFC1048 Magic Cookie */ |
| 363 | *e++ = 130; |
| 364 | *e++ = 83; |
| 365 | *e++ = 99; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 366 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 367 | *e++ = 53; /* DHCP Message Type */ |
| 368 | *e++ = 1; |
| 369 | *e++ = message_type; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 370 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 371 | *e++ = 57; /* Maximum DHCP Message Size */ |
| 372 | *e++ = 2; |
| 373 | *e++ = (576 - 312 + OPT_SIZE) >> 8; |
| 374 | *e++ = (576 - 312 + OPT_SIZE) & 0xff; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 375 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 376 | if (ServerID) { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 377 | int tmp = ntohl(ServerID); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 378 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 379 | *e++ = 54; /* ServerID */ |
| 380 | *e++ = 4; |
| 381 | *e++ = tmp >> 24; |
| 382 | *e++ = tmp >> 16; |
| 383 | *e++ = tmp >> 8; |
| 384 | *e++ = tmp & 0xff; |
| 385 | } |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 386 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 387 | if (RequestedIP) { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 388 | int tmp = ntohl(RequestedIP); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 389 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 390 | *e++ = 50; /* Requested IP */ |
| 391 | *e++ = 4; |
| 392 | *e++ = tmp >> 24; |
| 393 | *e++ = tmp >> 16; |
| 394 | *e++ = tmp >> 8; |
| 395 | *e++ = tmp & 0xff; |
| 396 | } |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 397 | #if defined(CONFIG_BOOTP_SEND_HOSTNAME) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 398 | hostname = getenv("hostname"); |
| 399 | if (hostname) { |
| 400 | int hostnamelen = strlen(hostname); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 401 | |
| 402 | *e++ = 12; /* Hostname */ |
| 403 | *e++ = hostnamelen; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 404 | memcpy(e, hostname, hostnamelen); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 405 | e += hostnamelen; |
| 406 | } |
stroese | fe389a8 | 2003-08-28 14:17:32 +0000 | [diff] [blame] | 407 | #endif |
| 408 | |
Jason Hobbs | d2b5d5c | 2011-08-31 05:37:31 +0000 | [diff] [blame] | 409 | #if defined(CONFIG_BOOTP_PXE) |
| 410 | clientarch = CONFIG_BOOTP_PXE_CLIENTARCH; |
| 411 | *e++ = 93; /* Client System Architecture */ |
| 412 | *e++ = 2; |
| 413 | *e++ = (clientarch >> 8) & 0xff; |
| 414 | *e++ = clientarch & 0xff; |
| 415 | |
| 416 | *e++ = 94; /* Client Network Interface Identifier */ |
| 417 | *e++ = 3; |
| 418 | *e++ = 1; /* type field for UNDI */ |
| 419 | *e++ = 0; /* major revision */ |
| 420 | *e++ = 0; /* minor revision */ |
| 421 | |
| 422 | uuid = getenv("pxeuuid"); |
| 423 | |
| 424 | if (uuid) { |
| 425 | if (uuid_str_valid(uuid)) { |
| 426 | *e++ = 97; /* Client Machine Identifier */ |
| 427 | *e++ = 17; |
| 428 | *e++ = 0; /* type 0 - UUID */ |
| 429 | |
| 430 | uuid_str_to_bin(uuid, e); |
| 431 | e += 16; |
| 432 | } else { |
| 433 | printf("Invalid pxeuuid: %s\n", uuid); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | *e++ = 60; /* Vendor Class Identifier */ |
| 438 | vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING); |
| 439 | *e++ = vci_strlen; |
| 440 | memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen); |
| 441 | e += vci_strlen; |
| 442 | #endif |
| 443 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 444 | #if defined(CONFIG_BOOTP_VENDOREX) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 445 | x = dhcp_vendorex_prep(e); |
| 446 | if (x) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 447 | return x - start; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 448 | #endif |
| 449 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 450 | *e++ = 55; /* Parameter Request List */ |
| 451 | cnt = e++; /* Pointer to count of requested items */ |
| 452 | *cnt = 0; |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 453 | #if defined(CONFIG_BOOTP_SUBNETMASK) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 454 | *e++ = 1; /* Subnet Mask */ |
| 455 | *cnt += 1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 456 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 457 | #if defined(CONFIG_BOOTP_TIMEOFFSET) |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 458 | *e++ = 2; |
| 459 | *cnt += 1; |
| 460 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 461 | #if defined(CONFIG_BOOTP_GATEWAY) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 462 | *e++ = 3; /* Router Option */ |
| 463 | *cnt += 1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 464 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 465 | #if defined(CONFIG_BOOTP_DNS) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 466 | *e++ = 6; /* DNS Server(s) */ |
| 467 | *cnt += 1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 468 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 469 | #if defined(CONFIG_BOOTP_HOSTNAME) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 470 | *e++ = 12; /* Hostname */ |
| 471 | *cnt += 1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 472 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 473 | #if defined(CONFIG_BOOTP_BOOTFILESIZE) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 474 | *e++ = 13; /* Boot File Size */ |
| 475 | *cnt += 1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 476 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 477 | #if defined(CONFIG_BOOTP_BOOTPATH) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 478 | *e++ = 17; /* Boot path */ |
| 479 | *cnt += 1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 480 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 481 | #if defined(CONFIG_BOOTP_NISDOMAIN) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 482 | *e++ = 40; /* NIS Domain name request */ |
| 483 | *cnt += 1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 484 | #endif |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 485 | #if defined(CONFIG_BOOTP_NTPSERVER) |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 486 | *e++ = 42; |
| 487 | *cnt += 1; |
| 488 | #endif |
Jason Liu | 258ccd6 | 2010-11-14 12:23:09 +0800 | [diff] [blame] | 489 | /* no options, so back up to avoid sending an empty request list */ |
| 490 | if (*cnt == 0) |
| 491 | e -= 2; |
| 492 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 493 | *e++ = 255; /* End of the list */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 494 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 495 | /* Pad to minimal length */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 496 | #ifdef CONFIG_DHCP_MIN_EXT_LEN |
Simon Glass | 21076f6 | 2011-02-02 15:03:28 -0800 | [diff] [blame] | 497 | while ((e - start) < CONFIG_DHCP_MIN_EXT_LEN) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 498 | *e++ = 0; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 499 | #endif |
| 500 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 501 | return e - start; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 502 | } |
| 503 | |
Jon Loeliger | 610f2e9 | 2007-07-10 11:05:02 -0500 | [diff] [blame] | 504 | #else |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 505 | /* |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 506 | * Warning: no field size check - change CONFIG_BOOTP_* at your own risk! |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 507 | */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 508 | static int BootpExtended(u8 *e) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 509 | { |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 510 | u8 *start = e; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 511 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 512 | *e++ = 99; /* RFC1048 Magic Cookie */ |
| 513 | *e++ = 130; |
| 514 | *e++ = 83; |
| 515 | *e++ = 99; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 516 | |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 517 | #if defined(CONFIG_CMD_DHCP) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 518 | *e++ = 53; /* DHCP Message Type */ |
| 519 | *e++ = 1; |
| 520 | *e++ = DHCP_DISCOVER; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 521 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 522 | *e++ = 57; /* Maximum DHCP Message Size */ |
| 523 | *e++ = 2; |
| 524 | *e++ = (576 - 312 + OPT_SIZE) >> 16; |
| 525 | *e++ = (576 - 312 + OPT_SIZE) & 0xff; |
Jon Loeliger | 610f2e9 | 2007-07-10 11:05:02 -0500 | [diff] [blame] | 526 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 527 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 528 | #if defined(CONFIG_BOOTP_SUBNETMASK) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 529 | *e++ = 1; /* Subnet mask request */ |
| 530 | *e++ = 4; |
| 531 | e += 4; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 532 | #endif |
| 533 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 534 | #if defined(CONFIG_BOOTP_GATEWAY) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 535 | *e++ = 3; /* Default gateway request */ |
| 536 | *e++ = 4; |
| 537 | e += 4; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 538 | #endif |
| 539 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 540 | #if defined(CONFIG_BOOTP_DNS) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 541 | *e++ = 6; /* Domain Name Server */ |
| 542 | *e++ = 4; |
| 543 | e += 4; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 544 | #endif |
| 545 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 546 | #if defined(CONFIG_BOOTP_HOSTNAME) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 547 | *e++ = 12; /* Host name request */ |
| 548 | *e++ = 32; |
| 549 | e += 32; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 550 | #endif |
| 551 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 552 | #if defined(CONFIG_BOOTP_BOOTFILESIZE) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 553 | *e++ = 13; /* Boot file size */ |
| 554 | *e++ = 2; |
| 555 | e += 2; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 556 | #endif |
| 557 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 558 | #if defined(CONFIG_BOOTP_BOOTPATH) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 559 | *e++ = 17; /* Boot path */ |
| 560 | *e++ = 32; |
| 561 | e += 32; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 562 | #endif |
| 563 | |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 564 | #if defined(CONFIG_BOOTP_NISDOMAIN) |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 565 | *e++ = 40; /* NIS Domain name request */ |
| 566 | *e++ = 32; |
| 567 | e += 32; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 568 | #endif |
Luuk Paulussen | 09e3a67 | 2011-05-16 18:29:19 +0000 | [diff] [blame] | 569 | #if defined(CONFIG_BOOTP_NTPSERVER) |
| 570 | *e++ = 42; |
| 571 | *e++ = 4; |
| 572 | e += 4; |
| 573 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 574 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 575 | *e++ = 255; /* End of the list */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 576 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 577 | return e - start; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 578 | } |
Jon Loeliger | 610f2e9 | 2007-07-10 11:05:02 -0500 | [diff] [blame] | 579 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 580 | |
| 581 | void |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 582 | BootpRequest(void) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 583 | { |
Joe Hershberger | db288a9 | 2012-05-15 08:59:04 +0000 | [diff] [blame] | 584 | uchar *pkt, *iphdr; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 585 | struct Bootp_t *bp; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 586 | int ext_len, pktlen, iplen; |
| 587 | |
Simon Glass | 573f14f | 2011-12-10 11:08:06 +0000 | [diff] [blame] | 588 | bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start"); |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 589 | #if defined(CONFIG_CMD_DHCP) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 590 | dhcp_state = INIT; |
| 591 | #endif |
| 592 | |
| 593 | #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */ |
| 594 | unsigned char bi_enetaddr[6]; |
| 595 | int reg; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 596 | ulong tst1, tst2, sum, m_mask, m_value = 0; |
| 597 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 598 | if (BootpTry == 0) { |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 599 | /* get our mac */ |
Mike Frysinger | 95823ca | 2009-02-11 18:23:48 -0500 | [diff] [blame] | 600 | eth_getenv_enetaddr("ethaddr", bi_enetaddr); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 601 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 602 | debug("BootpRequest => Our Mac: "); |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 603 | for (reg = 0; reg < 6; reg++) |
| 604 | debug("%x%c", bi_enetaddr[reg], reg == 5 ? '\n' : ':'); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 605 | |
| 606 | /* Mac-Manipulation 2 get seed1 */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 607 | tst1 = 0; |
| 608 | tst2 = 0; |
| 609 | for (reg = 2; reg < 6; reg++) { |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 610 | tst1 = tst1 << 8; |
| 611 | tst1 = tst1 | bi_enetaddr[reg]; |
| 612 | } |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 613 | for (reg = 0; reg < 2; reg++) { |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 614 | tst2 = tst2 | bi_enetaddr[reg]; |
| 615 | tst2 = tst2 << 8; |
| 616 | } |
| 617 | |
| 618 | seed1 = tst1^tst2; |
| 619 | |
| 620 | /* Mirror seed1*/ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 621 | m_mask = 0x1; |
| 622 | for (reg = 1; reg <= 32; reg++) { |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 623 | m_value |= (m_mask & seed1); |
| 624 | seed1 = seed1 >> 1; |
| 625 | m_value = m_value << 1; |
| 626 | } |
| 627 | seed1 = m_value; |
| 628 | seed2 = 0xB78D0945; |
| 629 | } |
| 630 | |
| 631 | /* Random Number Generator */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 632 | for (reg = 0; reg <= 0; reg++) { |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 633 | sum = seed1 + seed2; |
| 634 | if (sum < seed1 || sum < seed2) |
| 635 | sum++; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 636 | seed2 = seed1; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 637 | seed1 = sum; |
| 638 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 639 | if (BootpTry <= 2) { /* Start with max 1024 * 1ms */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 640 | sum = sum >> (22-BootpTry); |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 641 | } else { /*After 3rd BOOTP request max 8192 * 1ms */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 642 | sum = sum >> 19; |
| 643 | } |
| 644 | } |
| 645 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 646 | printf("Random delay: %ld ms...\n", sum); |
| 647 | for (reg = 0; reg < sum; reg++) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 648 | udelay(1000); /*Wait 1ms*/ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 649 | |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 650 | #endif /* CONFIG_BOOTP_RANDOM_DELAY */ |
| 651 | |
| 652 | printf("BOOTP broadcast %d\n", ++BootpTry); |
| 653 | pkt = NetTxPacket; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 654 | memset((void *)pkt, 0, PKTSIZE); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 655 | |
wdenk | a3d991b | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 656 | pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 657 | |
| 658 | /* |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 659 | * Next line results in incorrect packet size being transmitted, |
| 660 | * resulting in errors in some DHCP servers, reporting missing bytes. |
| 661 | * Size must be set in packet header after extension length has been |
| 662 | * determined. |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 663 | * C. Hallinan, DS4.COM, Inc. |
| 664 | */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 665 | /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, |
| 666 | sizeof (struct Bootp_t)); */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 667 | iphdr = pkt; /* We need this later for NetSetIP() */ |
| 668 | pkt += IP_HDR_SIZE; |
| 669 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 670 | bp = (struct Bootp_t *)pkt; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 671 | bp->bp_op = OP_BOOTREQUEST; |
| 672 | bp->bp_htype = HWT_ETHER; |
| 673 | bp->bp_hlen = HWL_ETHER; |
| 674 | bp->bp_hops = 0; |
Bartlomiej Sieka | 49f3bdb | 2008-10-01 15:26:28 +0200 | [diff] [blame] | 675 | bp->bp_secs = htons(get_timer(0) / 1000); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 676 | NetWriteIP(&bp->bp_ciaddr, 0); |
| 677 | NetWriteIP(&bp->bp_yiaddr, 0); |
| 678 | NetWriteIP(&bp->bp_siaddr, 0); |
| 679 | NetWriteIP(&bp->bp_giaddr, 0); |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 680 | memcpy(bp->bp_chaddr, NetOurEther, 6); |
| 681 | copy_filename(bp->bp_file, BootFile, sizeof(bp->bp_file)); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 682 | |
| 683 | /* Request additional information from the BOOTP/DHCP server */ |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 684 | #if defined(CONFIG_CMD_DHCP) |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 685 | ext_len = DhcpExtended((u8 *)bp->bp_vend, DHCP_DISCOVER, 0, 0); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 686 | #else |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 687 | ext_len = BootpExtended((u8 *)bp->bp_vend); |
Jon Loeliger | 610f2e9 | 2007-07-10 11:05:02 -0500 | [diff] [blame] | 688 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 689 | |
| 690 | /* |
| 691 | * Bootp ID is the lower 4 bytes of our ethernet address |
Bartlomiej Sieka | 49f3bdb | 2008-10-01 15:26:28 +0200 | [diff] [blame] | 692 | * plus the current time in ms. |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 693 | */ |
| 694 | BootpID = ((ulong)NetOurEther[2] << 24) |
| 695 | | ((ulong)NetOurEther[3] << 16) |
| 696 | | ((ulong)NetOurEther[4] << 8) |
| 697 | | (ulong)NetOurEther[5]; |
| 698 | BootpID += get_timer(0); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 699 | BootpID = htonl(BootpID); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 700 | NetCopyLong(&bp->bp_id, &BootpID); |
| 701 | |
| 702 | /* |
| 703 | * Calculate proper packet lengths taking into account the |
| 704 | * variable size of the options field |
| 705 | */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 706 | pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - |
| 707 | sizeof(bp->bp_vend) + ext_len; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 708 | iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len; |
| 709 | NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen); |
Bartlomiej Sieka | 49f3bdb | 2008-10-01 15:26:28 +0200 | [diff] [blame] | 710 | NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 711 | |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 712 | #if defined(CONFIG_CMD_DHCP) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 713 | dhcp_state = SELECTING; |
| 714 | NetSetHandler(DhcpHandler); |
| 715 | #else |
| 716 | NetSetHandler(BootpHandler); |
Jon Loeliger | 610f2e9 | 2007-07-10 11:05:02 -0500 | [diff] [blame] | 717 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 718 | NetSendPacket(NetTxPacket, pktlen); |
| 719 | } |
| 720 | |
Jon Loeliger | 643d1ab | 2007-07-09 17:45:14 -0500 | [diff] [blame] | 721 | #if defined(CONFIG_CMD_DHCP) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 722 | static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 723 | { |
wdenk | 3e38691 | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 724 | uchar *end = popt + BOOTP_HDR_SIZE; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 725 | int oplen, size; |
Wolfgang Denk | d8d8724 | 2009-09-11 09:05:32 +0200 | [diff] [blame] | 726 | #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) |
| 727 | int *to_ptr; |
| 728 | #endif |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 729 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 730 | while (popt < end && *popt != 0xff) { |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 731 | oplen = *(popt + 1); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 732 | switch (*popt) { |
| 733 | case 1: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 734 | NetCopyIP(&NetOurSubnetMask, (popt + 2)); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 735 | break; |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 736 | #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 737 | case 2: /* Time offset */ |
Wolfgang Denk | d8d8724 | 2009-09-11 09:05:32 +0200 | [diff] [blame] | 738 | to_ptr = &NetTimeOffset; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 739 | NetCopyLong((ulong *)to_ptr, (ulong *)(popt + 2)); |
| 740 | NetTimeOffset = ntohl(NetTimeOffset); |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 741 | break; |
| 742 | #endif |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 743 | case 3: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 744 | NetCopyIP(&NetOurGatewayIP, (popt + 2)); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 745 | break; |
| 746 | case 6: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 747 | NetCopyIP(&NetOurDNSIP, (popt + 2)); |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 748 | #if defined(CONFIG_BOOTP_DNS2) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 749 | if (*(popt + 1) > 4) |
| 750 | NetCopyIP(&NetOurDNS2IP, (popt + 2 + 4)); |
stroese | fe389a8 | 2003-08-28 14:17:32 +0000 | [diff] [blame] | 751 | #endif |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 752 | break; |
| 753 | case 12: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 754 | size = truncate_sz("Host Name", |
| 755 | sizeof(NetOurHostName), oplen); |
| 756 | memcpy(&NetOurHostName, popt + 2, size); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 757 | NetOurHostName[size] = 0; |
| 758 | break; |
| 759 | case 15: /* Ignore Domain Name Option */ |
| 760 | break; |
| 761 | case 17: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 762 | size = truncate_sz("Root Path", |
| 763 | sizeof(NetOurRootPath), oplen); |
| 764 | memcpy(&NetOurRootPath, popt + 2, size); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 765 | NetOurRootPath[size] = 0; |
| 766 | break; |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 767 | #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER) |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 768 | case 42: /* NTP server IP */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 769 | NetCopyIP(&NetNtpServerIP, (popt + 2)); |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 770 | break; |
| 771 | #endif |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 772 | case 51: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 773 | NetCopyLong(&dhcp_leasetime, (ulong *) (popt + 2)); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 774 | break; |
| 775 | case 53: /* Ignore Message Type Option */ |
| 776 | break; |
| 777 | case 54: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 778 | NetCopyIP(&NetDHCPServerIP, (popt + 2)); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 779 | break; |
| 780 | case 58: /* Ignore Renewal Time Option */ |
| 781 | break; |
| 782 | case 59: /* Ignore Rebinding Time Option */ |
| 783 | break; |
Wolfgang Denk | 3b2e4fd | 2006-03-12 18:26:46 +0100 | [diff] [blame] | 784 | case 66: /* Ignore TFTP server name */ |
| 785 | break; |
| 786 | case 67: /* vendor opt bootfile */ |
| 787 | /* |
| 788 | * I can't use dhcp_vendorex_proc here because I need |
| 789 | * to write into the bootp packet - even then I had to |
| 790 | * pass the bootp packet pointer into here as the |
| 791 | * second arg |
| 792 | */ |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 793 | size = truncate_sz("Opt Boot File", |
Wolfgang Denk | 3b2e4fd | 2006-03-12 18:26:46 +0100 | [diff] [blame] | 794 | sizeof(bp->bp_file), |
| 795 | oplen); |
| 796 | if (bp->bp_file[0] == '\0' && size > 0) { |
| 797 | /* |
| 798 | * only use vendor boot file if we didn't |
| 799 | * receive a boot file in the main non-vendor |
| 800 | * part of the packet - god only knows why |
| 801 | * some vendors chose not to use this perfectly |
| 802 | * good spot to store the boot file (join on |
| 803 | * Tru64 Unix) it seems mind bogglingly crazy |
| 804 | * to me |
| 805 | */ |
| 806 | printf("*** WARNING: using vendor " |
| 807 | "optional boot file\n"); |
| 808 | memcpy(bp->bp_file, popt + 2, size); |
| 809 | bp->bp_file[size] = '\0'; |
| 810 | } |
| 811 | break; |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 812 | default: |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 813 | #if defined(CONFIG_BOOTP_VENDOREX) |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 814 | if (dhcp_vendorex_proc(popt)) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 815 | break; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 816 | #endif |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 817 | printf("*** Unhandled DHCP Option in OFFER/ACK:" |
| 818 | " %d\n", *popt); |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 819 | break; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 820 | } |
| 821 | popt += oplen + 2; /* Process next option */ |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | static int DhcpMessageType(unsigned char *popt) |
| 826 | { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 827 | if (NetReadLong((ulong *)popt) != htonl(BOOTP_VENDOR_MAGIC)) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 828 | return -1; |
| 829 | |
| 830 | popt += 4; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 831 | while (*popt != 0xff) { |
| 832 | if (*popt == 53) /* DHCP Message Type */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 833 | return *(popt + 2); |
| 834 | popt += *(popt + 1) + 2; /* Scan through all options */ |
| 835 | } |
| 836 | return -1; |
| 837 | } |
| 838 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 839 | static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 840 | { |
Joe Hershberger | db288a9 | 2012-05-15 08:59:04 +0000 | [diff] [blame] | 841 | uchar *pkt, *iphdr; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 842 | struct Bootp_t *bp; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 843 | int pktlen, iplen, extlen; |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 844 | IPaddr_t OfferedIP; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 845 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 846 | debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n"); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 847 | pkt = NetTxPacket; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 848 | memset((void *)pkt, 0, PKTSIZE); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 849 | |
wdenk | a3d991b | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 850 | pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 851 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 852 | iphdr = pkt; /* We'll need this later to set proper pkt size */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 853 | pkt += IP_HDR_SIZE; |
| 854 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 855 | bp = (struct Bootp_t *)pkt; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 856 | bp->bp_op = OP_BOOTREQUEST; |
| 857 | bp->bp_htype = HWT_ETHER; |
| 858 | bp->bp_hlen = HWL_ETHER; |
| 859 | bp->bp_hops = 0; |
Bartlomiej Sieka | 49f3bdb | 2008-10-01 15:26:28 +0200 | [diff] [blame] | 860 | bp->bp_secs = htons(get_timer(0) / 1000); |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 861 | /* Do not set the client IP, your IP, or server IP yet, since it |
| 862 | * hasn't been ACK'ed by the server yet */ |
Justin Flammia | e5c794e | 2007-10-29 17:40:35 -0400 | [diff] [blame] | 863 | |
Wolfgang Denk | c668670 | 2006-10-12 00:01:08 +0200 | [diff] [blame] | 864 | /* |
Wolfgang Denk | d82718f | 2006-10-09 01:26:14 +0200 | [diff] [blame] | 865 | * RFC3046 requires Relay Agents to discard packets with |
| 866 | * nonzero and offered giaddr |
| 867 | */ |
| 868 | NetWriteIP(&bp->bp_giaddr, 0); |
| 869 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 870 | memcpy(bp->bp_chaddr, NetOurEther, 6); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 871 | |
| 872 | /* |
| 873 | * ID is the id of the OFFER packet |
| 874 | */ |
| 875 | |
| 876 | NetCopyLong(&bp->bp_id, &bp_offer->bp_id); |
| 877 | |
| 878 | /* |
| 879 | * Copy options from OFFER packet if present |
| 880 | */ |
Justin Flammia | e5c794e | 2007-10-29 17:40:35 -0400 | [diff] [blame] | 881 | |
| 882 | /* Copy offered IP into the parameters request list */ |
| 883 | NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr); |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 884 | extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, |
| 885 | NetDHCPServerIP, OfferedIP); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 886 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 887 | pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - |
| 888 | sizeof(bp->bp_vend) + extlen; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 889 | iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen; |
| 890 | NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen); |
| 891 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 892 | debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen); |
Aras Vaichas | d9a2f41 | 2008-03-26 09:43:57 +1100 | [diff] [blame] | 893 | #ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY |
| 894 | udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY); |
| 895 | #endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 896 | NetSendPacket(NetTxPacket, pktlen); |
| 897 | } |
| 898 | |
| 899 | /* |
| 900 | * Handle DHCP received packets. |
| 901 | */ |
| 902 | static void |
Luca Ceresoli | 03eb129 | 2011-04-18 06:19:50 +0000 | [diff] [blame] | 903 | DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, |
| 904 | unsigned len) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 905 | { |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 906 | struct Bootp_t *bp = (struct Bootp_t *)pkt; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 907 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 908 | debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n", |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 909 | src, dest, len, dhcp_state); |
| 910 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 911 | /* Filter out pkts we don't want */ |
| 912 | if (BootpCheckPkt(pkt, dest, src, len)) |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 913 | return; |
| 914 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 915 | debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state:" |
| 916 | " %d\n", src, dest, len, dhcp_state); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 917 | |
| 918 | switch (dhcp_state) { |
| 919 | case SELECTING: |
| 920 | /* |
| 921 | * Wait an appropriate time for any potential DHCPOFFER packets |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 922 | * to arrive. Then select one, and generate DHCPREQUEST |
| 923 | * response. If filename is in format we recognize, assume it |
| 924 | * is a valid OFFER from a server we want. |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 925 | */ |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 926 | debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 927 | #ifdef CONFIG_SYS_BOOTFILE_PREFIX |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 928 | if (strncmp(bp->bp_file, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 929 | CONFIG_SYS_BOOTFILE_PREFIX, |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 930 | strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 931 | #endif /* CONFIG_SYS_BOOTFILE_PREFIX */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 932 | |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 933 | debug("TRANSITIONING TO REQUESTING STATE\n"); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 934 | dhcp_state = REQUESTING; |
stroese | 759a51b | 2003-04-10 13:26:44 +0000 | [diff] [blame] | 935 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 936 | if (NetReadLong((ulong *)&bp->bp_vend[0]) == |
| 937 | htonl(BOOTP_VENDOR_MAGIC)) |
Wolfgang Denk | 3b2e4fd | 2006-03-12 18:26:46 +0100 | [diff] [blame] | 938 | DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 939 | |
Bartlomiej Sieka | 49f3bdb | 2008-10-01 15:26:28 +0200 | [diff] [blame] | 940 | NetSetTimeout(TIMEOUT, BootpTimeout); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 941 | DhcpSendRequestPkt(bp); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 942 | #ifdef CONFIG_SYS_BOOTFILE_PREFIX |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 943 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 944 | #endif /* CONFIG_SYS_BOOTFILE_PREFIX */ |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 945 | |
| 946 | return; |
| 947 | break; |
| 948 | case REQUESTING: |
Robin Getz | 0ebf04c | 2009-07-23 03:01:03 -0400 | [diff] [blame] | 949 | debug("DHCP State: REQUESTING\n"); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 950 | |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 951 | if (DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK) { |
| 952 | if (NetReadLong((ulong *)&bp->bp_vend[0]) == |
| 953 | htonl(BOOTP_VENDOR_MAGIC)) |
Wolfgang Denk | 3b2e4fd | 2006-03-12 18:26:46 +0100 | [diff] [blame] | 954 | DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp); |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 955 | /* Store net params from reply */ |
| 956 | BootpCopyNetParams(bp); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 957 | dhcp_state = BOUND; |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 958 | printf("DHCP client bound to address %pI4\n", |
| 959 | &NetOurIP); |
Simon Glass | 573f14f | 2011-12-10 11:08:06 +0000 | [diff] [blame] | 960 | bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 961 | "bootp_stop"); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 962 | |
Simon Glass | e4a3d57 | 2011-10-27 06:24:32 +0000 | [diff] [blame] | 963 | net_auto_load(); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 964 | return; |
| 965 | } |
| 966 | break; |
Remy Bohmer | 51dfe13 | 2008-08-20 11:30:28 +0200 | [diff] [blame] | 967 | case BOUND: |
| 968 | /* DHCP client bound to address */ |
| 969 | break; |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 970 | default: |
Joe Hershberger | 3090b7e3 | 2012-05-15 08:59:06 +0000 | [diff] [blame] | 971 | puts("DHCP: INVALID STATE\n"); |
wdenk | 3861aa5 | 2002-09-27 23:19:37 +0000 | [diff] [blame] | 972 | break; |
| 973 | } |
| 974 | |
| 975 | } |
| 976 | |
| 977 | void DhcpRequest(void) |
| 978 | { |
| 979 | BootpRequest(); |
| 980 | } |
Wolfgang Denk | 992742a | 2007-11-03 23:09:27 +0100 | [diff] [blame] | 981 | #endif /* CONFIG_CMD_DHCP */ |