summaryrefslogtreecommitdiff
path: root/net/bootp.c
Commit message (Collapse)AuthorAgeLines
* net: Fix incorrect DHCP/BOOTP packets on 64-bit systemsSergey Temerkhanov2015-04-18-17/+16
| | | | | | | | | | | | This commit fixes incorrect DHCP/BOOTP packet layout caused by 'ulong' type size difference on 64 and 32-bit architectures. It also renames NetReadLong()/NetCopyLong() to net_read_u32/net_copy_u32() accordingly. Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com> Signed-off-by: Sergey Temerkhanov <s.temerkhanov@gmail.com> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Fix checkpatch.pl failures in net.cJoe Hershberger2015-04-18-16/+17
| | | | | | | Finish eliminating CamelCase from net.c and other failures Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Clean up DHCP variables and functionsJoe Hershberger2015-04-18-61/+58
| | | | | | | | Make a thorough pass through all variables and function names contained within bootp.c and remove CamelCase and improve naming. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Cleanup internal packet buffer namesJoe Hershberger2015-04-18-8/+8
| | | | | | | This patch cleans up the names of internal packet buffer names that are used within the network stack and the functions that use them. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Name ethaddr variables consistentlyJoe Hershberger2015-04-18-9/+10
| | | | | | | | Use "_ethaddr" at the end of variables and drop CamelCase. Make constant values actually 'const'. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Fixup var names for DHCP stringsJoe Hershberger2015-04-18-24/+27
| | | | | | | | Remove CamelCase variable naming. Move the definition to the same compilation unit as the primary use. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Fixup var names related to boot fileJoe Hershberger2015-04-18-13/+14
| | | | | | | | The variables around the bootfile were inconsistent and used CamelCase. Update them to make the code more readable. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: Change IPaddr_t to struct in_addrJoe Hershberger2015-04-18-58/+67
| | | | | | | | | This patch is simply clean-up to make the IPv4 type that is used match what Linux uses. It also attempts to move all variables that are IP addresses use good naming instead of CamelCase. No functional change. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: bootp: as CONFIG_BOOTP_SERVERIP is defined, keep bootfile not changedWu, Josh2014-12-08-2/+2
| | | | | | | | | | | | | | Currenly when CONFIG_BOOTP_SERVERIP is defined, the SERVERIP is not changed when receive the BOOTP packet. But BOOTFILE is changed via BOOTP packet. As we will load the BOOTFILE from SERVERIP, if the BOOTFILE is modified by bootp packet but SERVERIP is not, that is not make sense. This patch make SERVERIP and BOOTFILE be consistent. If we define the CONFIG_BOOTP_SERVERIP, then SERVERIP and BOOTFILE will not changed by BOOTP packet. Only IP address is changed. Signed-off-by: Josh Wu <josh.wu@atmel.com>
* net: More BOOTP retry timeout improvementsThierry Reding2014-08-21-8/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's not unusual for DHCP servers to take a couple hundred milliseconds to respond to DHCP discover messages. One possible reason for the delay can be that the server checks (typically using an ARP request) that the IP it's about to hand out isn't in use yet. To make matters worse, some servers may also queue up requests and process them sequentially, which can cause excessively long delays if clients retry too fast. Commit f59be6e850b3 ("net: BOOTP retry timeout improvements") shortened the retry timeouts significantly, but the BOOTP/DHCP implementation in U-Boot doesn't handle that well because it will ignore incoming replies to earlier requests. In one particular setup this increases the time it takes to obtain a DHCP lease from 630 ms to 8313 ms. This commit attempts to fix this in two ways. First it increases the initial retry timeout from 10 ms to 250 ms to give DHCP servers some more time to respond. At the same time a cache of outstanding DHCP request IDs is kept so that the implementation will know to continue transactions even after a retransmission of the DISCOVER message. The maximum retry timeout is also increased from 1 second to 2 seconds. An ID cache of size 4 will keep DHCP requests around for 8 seconds (once the maximum retry timeout has been reached) before dropping them. This should give servers plenty of time to respond. If it ever turns out that this isn't enough, the size of the cache can easily be increased. With this commit the DHCP lease on the above-mentioned setup still takes longer (1230 ms) than originally, but that's an acceptable compromise to improve DHCP lease acquisition time for a broader range of setups. To make it easier to benchmark DHCP in the future, this commit also adds the time it took to obtain a lease to the final "DHCP client bound to address x.x.x.x" message. Tested-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
* net: BOOTP retry timeout improvementsStephen Warren2014-08-09-7/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the BOOTP code sends out its initial request as soon as the Ethernet driver indicates "link up". If this packet is lost or not replied to for some reason, the code waits for a 1s timeout before retrying. For some reason, such early packets are often lost on my system, so this causes an annoying delay. To optimize this, modify the BOOTP code to have very short timeouts for the first packet transmitted, but gradually increase the timeout each time a timeout occurs. This way, if the first packet is lost, the second packet is transmitted quite quickly and hence the overall delay is low. However, if there's still no response, we don't keep spewing out packets at an insane speed. It's arguably more correct to try and find out why the first packet is lost. However, it seems to disappear inside my Ethenet chip; the TX chip indicates no error during TX (not that it has much in the way of reporting...), yet wireshark on the RX side doesn't see any packet. FWIW, I'm using an ASIX USB Ethernet adapter. Perhaps "link up" is reported too early or based on the wrong condition in HW, and we should add some fixed extra delay into the driver. However, this would slow down every link up event even if it ends up not being needed in some cases. Having BOOTP retry quickly applies the fix/WAR to every possible Ethernet device, and is quite simple to implement, so seems a better solution. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* bootp can use mdelayPavel Machek2014-07-22-3/+2
| | | | | | | Cleanup bootp code by using mdelay. Signed-off-by: Pavel Machek <pavel@denx.de> Acked-by: Marek Vasut <marex@denx.de>
* lib: uuid: code refactor for proper maintain between uuid bin and stringPrzemyslaw Marczak2014-04-02-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Changes in lib/uuid.c to: - uuid_str_to_bin() - uuid_bin_to_str() New parameter is added to specify input/output string format in listed functions This change allows easy recognize which UUID type is or should be stored in given string array. Binary data of UUID and GUID is always stored in big endian, only string representations are different as follows. String byte: 0 36 String char: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx string UUID: be be be be be string GUID: le le le be be This patch also updates functions calls and declarations in a whole code. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: trini@ti.com
* net/: sparse fixesKim Phillips2012-11-04-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | bootp.c:44:14: warning: symbol 'dhcp_state' was not declared. Should it be static? bootp.c:45:15: warning: symbol 'dhcp_leasetime' was not declared. Should it be static? bootp.c:46:10: warning: symbol 'NetDHCPServerIP' was not declared. Should it be static? arp.c:30:17: warning: symbol 'NetArpWaitReplyIP' was not declared. Should it be static? arp.c:37:16: warning: symbol 'NetArpTxPacket' was not declared. Should it be static? arp.c:38:17: warning: symbol 'NetArpPacketBuf' was not declared. Should it be static? atheros.c:33:19: warning: symbol 'AR8021_driver' was not declared. Should it be static? net.c:183:7: warning: symbol 'PktBuf' was not declared. Should it be static? net.c:159:21: warning: symbol 'net_state' was not declared. Should it be static? ping.c:73:6: warning: symbol 'ping_start' was not declared. Should it be static? ping.c:82:13: warning: symbol 'ping_receive' was not declared. Should it be static? tftp.c:53:7: warning: symbol 'TftpRRQTimeoutMSecs' was not declared. Should it be static? tftp.c:54:5: warning: symbol 'TftpRRQTimeoutCountMax' was not declared. Should it be static? eth.c:125:19: warning: symbol 'eth_current' was not declared. Should it be static? Note: in the ping.c fix, commit a36b12f95a29647a06b5459198684fc142482020 "net: Move PING out of net.c" mistakenly carried the ifdef CMD_PING clause from when it was necessary to avoid warnings when it was embedded in net.c. Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
* OMAP: networking support for SPLIlya Yanok2012-10-01-1/+6
| | | | | | | | | | | | | | This patch adds support for networking in SPL. Some devices are capable of loading SPL via network so it makes sense to load the main U-Boot binary via network too. This patch tries to use existing network code as much as possible. Unfortunately, it depends on environment which in turn depends on other code so SPL size is increased significantly. No effort was done to decouple network code and environment so far. Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Tom Rini <trini@ti.com>
* net/bootp: add VCI support for BOOTP alsoIlya Yanok2012-10-01-6/+16
| | | | | | | | | Vendor Class Identifier option is common to BOOTP and DHCP and can be useful without PXE. So send VCI in both BOOTP and DHCP requests if CONFIG_BOOTP_VCI_STRING is defined. Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com> Signed-off-by: Tom Rini <trini@ti.com>
* net: Quietly ignore DHCP Option 28 (Broadcast Address)Brian Rzycki2012-09-27-0/+2
| | | | | | | | | | | | | | Some DHCP servers (notably dnsmasq) always transmit DHCP Option 28, Broadcast Address as specified in RFC 2132. Without this patch u-boot displays the warning: *** Unhandled DHCP Option in OFFER/ACK: 28 The patch suppresses the warning and ignores DHCP Option 28. There is no environment variable to set the broadcast address into and if for some reason u-boot needs the broadcast it can be calculated from ipaddr and netmask. Signed-off-by: Brian Rzycki <bmr@freescale.com>
* net: bootp: fix buildbenoit.thebaudeau@advans2012-07-19-1/+1
| | | | | | | Fix NetSetState function name used with CONFIG_BOOTP_MAY_FAIL. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Cc: Joe Hershberger <joe.hershberger@gmail.com>
* net: make net_rand.h inclusion depend on BOOTP_RANDOM_DELAYKim Phillips2012-07-08-1/+3
| | | | | | | | | | | | | | | | | | | | commit "net: use common rand()/srand() functions" introduced the following build warning on the current u-boot-arm tree: $ ./MAKEALL MPC8313ERDB_66 Configuring for MPC8313ERDB_66 - Board: MPC8313ERDB, Options: SYS_66MHZ text data bss dec hex filename 271988 13976 41768 327732 50034 ./u-boot In file included from bootp.c:15:0: net_rand.h: In function 'srand_mac': net_rand.h:40:2: warning: implicit declaration of function 'srand' [-Wimplicit-function-declaration] adding this dependency fixes it. Cc: Michael Walle <michael@walle.cc> Cc: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Acked-by: Michael Walle <michael@walle.cc>
* net: Add option CONFIG_BOOTP_MAY_FAILJoe Hershberger2012-05-23-0/+5
| | | | | | | | This is useful if you want to look for a DHCP server, but try some other settings if not available. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Fix unused variable compile warningJoe Hershberger2012-05-23-4/+3
| | | | | | | | | | If CONFIG_BOOTP_SERVERIP is not defined, unused variable warning is reported. This was fixed upstream using a compiler feature instead of a simple reorder of the statements. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: Refactor to separate the UDP handler from the ARP handlerJoe Hershberger2012-05-23-2/+2
| | | | | | | | | | | Call a built-in dummy if none is registered... don't require protocols to register a handler (eliminating dummies) NetConsole now uses the ARP handler when waiting on arp (instead of needing a #define hack in arp.c) Clear handlers at the end of net loop Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Move debug trace to point of actionJoe Hershberger2012-05-23-1/+1
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Refactor bootp packet length computationsJoe Hershberger2012-05-23-11/+13
| | | | | | | Eliminate pointer subtraction that recovers values computed earlier Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Refactor IP, UPD, and ICMP header writing functionsJoe Hershberger2012-05-23-4/+4
| | | | | | | | ICMP (ping) was reimplementing IP header code... it now shares code. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: cosmetic: Rename OPT_SIZE to OPT_FIELD_SIZEJoe Hershberger2012-05-23-5/+5
| | | | | | | | Clearer constant name. Also remove related BOOTP_SIZE which was unused and doesn't take into account VLAN packets. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Un-typedef Ethernet_tJoe Hershberger2012-05-23-1/+1
| | | | | | | Separate the Ethernet header from the 802 header. Base the size constants on the structs. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: Un-typedef IP_tJoe Hershberger2012-05-23-2/+2
| | | | | | | | Rename IP header related things to IP_UDP. The existing definition of IP_t includes UDP header, so name it to accurately describe the structure. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Move MAC-seeded rand out of bootp.cJoe Hershberger2012-05-23-55/+12
| | | | | | | | | Make the MAC-seeded random number generator available to /net in general. MAC-seeded rand will be needed by link-local as well, so give it an interface. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: cosmetic: bootp.* checkpatch complianceJoe Hershberger2012-05-15-167/+173
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Remove volatile from net APIJoe Hershberger2012-05-15-2/+2
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* bootstage: Plumb in bootstage calls for basic operationsSimon Glass2012-03-18-0/+4
| | | | | | | | This inserts bootstage calls into tftp, usb start and bootm. We could go further, but this is a reasonable start to illustrate the concept. Signed-off-by: Simon Glass <sjg@chromium.org>
* net/bootp.c: Fix GCC 4.6 warningAnatolij Gustschin2011-11-23-1/+2
| | | | | | | | Fix: bootp.c: In function 'BootpCopyNetParams': bootp.c:108:11: warning: unused variable 'tmp_ip' [-Wunused-variable] Signed-off-by: Anatolij Gustschin <agust@denx.de>
* net: Export auto_load, use it in rarpSimon Glass2011-10-27-32/+2
| | | | | | | | | | | The rarp code includes another instance of the auto_load logic, so call what is now net_auto_load() instead. This also fixes an incorrect call to TftpStart() which was never seen since apparently no boards enable rarp. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: tftpput: Support selecting get/put for tftpSimon Glass2011-10-26-1/+1
| | | | | | TftpStart should support starting either a get or a put. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: bootp: add PXE/RFC 4578 DHCP options supportJason Hobbs2011-10-17-0/+40
| | | | | | | | | | These options are required to be present in RFC 4578 compliant DHCP requests. They give more information to DHCP servers to allow serving different DHCP responses to different systems based on client architecture, client capabilities, UUID, or vendor. Signed-off-by: Jason Hobbs <jason.hobbs@calxeda.com>
* net/bootp.c: fix tftp load if autoload environment var isn't setPeter Korsgaard2011-09-19-1/+1
| | | | | | | | | | | | | Commit 093498669 (Put common autoload code into auto_load() function) broke handling of autoload environment variable not being set. The bootp/dhcp code will just keep on requesting IP address forever and never start TFTP download. Fix it by moving TftpStart() outside the conditional like it was before. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk> Tested-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Simon Glass <sjg@chromium.org>
* Put common autoload code into auto_load() functionSimon Glass2011-08-08-43/+33
| | | | | | | This is a small clean-up patch. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Eric Bénard <eric@eukrea.com>
* bootp: add ntpserver option to bootp requestLuuk Paulussen2011-07-27-0/+15
| | | | | | Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz> Acked-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Cc: Ben Warren <biggerbadderben@gmail.com>
* NET: pass source IP address to packet handlersLuca Ceresoli2011-05-12-3/+6
| | | | | | | | | | This is needed for the upcoming TFTP server implementation. This also simplifies PingHandler() and fixes rxhand_f documentation. Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Detlev Zundel <dzu@denx.de>
* Fix bad padding of bootp request packetSimon Glass2011-04-13-1/+1
| | | | | | This seems to pad to one byte longer than required Signed-off-by: Simon Glass <sjg@chromium.org>
* net: Fix potential empty DHCP Parameter Request ListJason Liu2010-11-14-0/+4
| | | | | | | | | | Can't get IP address with dhcp due to the dhcp server not allow the empty param list request under some network env This patch is based on Gray Remlin's initial patch. Signed-off-by: Jason Liu <r64343@freescale.com> Signed-off-by: Gray Remlin <g_remlin@rocketmail.com>
* net: pull CONFIG checks out of source and into makefileMike Frysinger2009-12-13-4/+0
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* net/bootp.c: fix compile warningWolfgang Denk2009-09-11-1/+5
| | | | | | | | Fix warning: bootp.c:695: warning: dereferencing type-punned pointer will break strict-aliasing rules Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com>
* minor debug cleanups in ./netRobin Getz2009-08-07-52/+29
| | | | | | | | | | | | | | | Minor ./net cleanups - no functional changes - change #ifdef DEBUG printf(); #endif to just debug() - changed __FUNCTION__ to __func__ - got rid of extra whitespace between function and opening brace - removed unnecessary braces on if statements gcc dead code elimination should make this functionally/size equivalent when DEBUG is not defined. (confirmed on Blackfin, with gcc 4.3.3). Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* net: rename NetRxPkt to NetRxPacketMike Frysinger2009-07-22-1/+1
| | | | | | | | The net code is mostly consistent in using 'Packet' rather than 'Pkt', so rename the minor detractor to follow suite. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* A VLAN tagged DHCP request/discover is 4 bytes shortNorbert van Bolhuis2009-06-15-2/+2
| | | | | | | | | The problem is that BOOTP_SIZE uses ETHER_HDR_SIZE which is 14 bytes. If sending a VLAN tagged frame (when env variable vlan is set) this should be VLAN_ETHER_HDR_SIZE=18 which is what NetSetEther returns. Signed-off-by: Norbert van Bolhuis <nvbolhuis@aimvalley.nl> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* net: get mac address from environment and use eth util funcsMike Frysinger2009-03-20-10/+1
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> CC: Ben Warren <biggerbadderben@gmail.com>
* convert print_IPaddr() to %pI4Mike Frysinger2009-03-20-13/+5
| | | | | | | | | Now that our printf functions support the %pI4 modifier like the kernel, let's drop the inflexible print_IPaddr() function and covert over to the %pI4 modifier. Signed-off-by: Mike Frysinger <vapier@gentoo.org> CC: Ben Warren <biggerbadderben@gmail.com>
* rename CFG_ macros to CONFIG_SYSJean-Christophe PLAGNIOL-VILLARD2008-10-18-6/+6
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>