summaryrefslogtreecommitdiffstats
path: root/net/net.c
Commit message (Collapse)AuthorAgeFilesLines
* net: cosmetic: Un-typedef IP_tJoe Hershberger2012-05-231-30/+32
| | | | | | | | 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 RARP receive logic out of net.cJoe Hershberger2012-05-231-26/+1
| | | | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: Move PING out of net.cJoe Hershberger2012-05-231-129/+4
| | | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Move ARP out of net.cJoe Hershberger2012-05-231-196/+13
| | | | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net: Encapsulate CDP packet identificationJoe Hershberger2012-05-231-1/+1
| | | | | | Checking for CDP packets should be encapsulated, not copied code. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: Move CDP out of net.cJoe Hershberger2012-05-231-365/+1
| | | | | | Separate this functionality out of the net.c behemoth Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* net: punt bd->bi_ip_addrMike Frysinger2012-05-151-2/+0
| | | | | | | | | This field gets read in one place (by "bdinfo"), and we can replace that with getenv("ipaddr"). After all, the bi_ip_addr field is kept up-to-date implicitly with the value of the ipaddr env var. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
* net: cosmetic: net.c checkpatch complianceJoe Hershberger2012-05-151-14/+8
| | | | | Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
* net: Remove volatile from net APIJoe Hershberger2012-05-151-17/+17
| | | | | 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-181-0/+1
| | | | | | | | 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: Make sure IPaddr_t is 32 bits in sizeMatthias Weisser2011-12-061-3/+3
| | | | | | | | | | | When building u-boot as 64 bit application (e.g. sandbox) ulong might be 64 bits in size. This breaks network code as IPaddr_t is 64 bytes in size then and an IPv4 address is 32 bits in size. This patch makes sure that IPaddr_t is always 32 bits in size. Also some warnings introduced by this patch are fixed. Signed-off-by: Matthias Weisser <weisserm@arcor.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* net/net.c: Fix GCC 4.6 build warningWolfgang Denk2011-11-071-3/+1
| | | | | | | | | Fix: net.c: In function 'CDPHandler': net.c:1083:8: warning: variable 'applid' set but not used [-Wunused-but-set-variable] Signed-off-by: Wolfgang Denk <wd@denx.de>
* net: Export auto_load, use it in rarpSimon Glass2011-10-271-0/+30
| | | | | | | | | | | 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: Change for loop to memset()Simon Glass2011-10-271-6/+2
| | | | | | This is intended purely as a code size reduction. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: Hide more code behind CONFIG_CMD_TFTPPUTSimon Glass2011-10-271-0/+8
| | | | | | | | This commit reduces code size a little by making the ICMP handler only available to tftpput. This is reasonable since it is the only user at present (ping just uses the normal handler). Signed-off-by: Simon Glass <sjg@chromium.org>
* net: tftpput: implement tftp logicSimon Glass2011-10-261-0/+4
| | | | | | | This adds logic to tftp.c to implement the tftp 'put' command, and updates the README. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: tftpput: Rename TFTP to TFTPGETSimon Glass2011-10-261-10/+8
| | | | | | | | This is a better name for this protocol. Also remove the typedef to keep checkpatch happy, and move zeroing of NetBootFileXferSize a little earlier since TFTPPUT will need to change this. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: tftpput: Add support for receiving ICMP packetsSimon Glass2011-10-261-3/+24
| | | | | | | | | | ICMP packets can tell you when there is no server at the other end. It is useful for tftp to figure this out, so that a quick error can be displayed, rather than pointlessly retrying. This adds an ICMP packet handler to the net interface. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: tftpput: Move ICMP code into its own functionSimon Glass2011-10-261-43/+58
| | | | | | | NetReceive() is a very long function with a lot of indent. Before adding code to the ICMP bit, split it out. Signed-off-by: Simon Glass <sjg@chromium.org>
* net: drop !NET_MULTI codeMike Frysinger2011-10-051-30/+0
| | | | | | | | | | | This is long over due. All but two net drivers have been converted, but those have now been dropped. The only thing left to do is actually delete all references to NET_MULTI and code that is compiled when that is not defined. So here we scrub the core code. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* net/net.c: Update ipaddr if the environment has changedEnric Balletbo i Serra2011-06-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At least on ARM the ipaddr is only set in board_init_r function. The problem is if ipaddr is not defined in environment importing another environment defined don't update the ipaddr value. For example, suppose we've a default environment without net variables defined and we want to import an uEnv.txt environment from SD-card like this: ipaddr=192.168.2.240 netmask=255.255.255.0 gatewayip=192.168.2.1 serverip=192.168.2.114 Then if you try boot from NFS results in: Importing environment from mmc ... Running uenvcmd ... smc911x: detected LAN9221 controller smc911x: phy initialized smc911x: MAC ac:de:48:00:00:00 *** ERROR: `ipaddr' not set The ipaddr at this point is NULL beacause is only set at board_init_r function. This patch updates the ipaddr value if the environment has changed. Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
* TFTP: add tftpsrv commandLuca Ceresoli2011-05-191-1/+6
| | | | | | Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Detlev Zundel <dzu@denx.de>
* net/net.c: cosmetic: do not use assignment in if conditionLuca Ceresoli2011-05-121-1/+2
| | | | | | | | | This removes the following checkpatch issue: - ERROR: do not use assignment in if condition Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com>
* net/net.c: cosmetic: fix indentationLuca Ceresoli2011-05-121-42/+41
| | | | | | | | | | | This removes the following checkpatch issues: - ERROR: switch and case should be at the same indent - WARNING: suspect code indent for conditional statements - WARNING: labels should not be indented Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com>
* net/net.c: cosmetic: parentheses not required for returnLuca Ceresoli2011-05-121-15/+15
| | | | | | | | | This removes the following checkpatch issue: - ERROR: return is not a function, parentheses are not required Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com>
* net/net.c: cosmetic: fix pointer syntax issuesLuca Ceresoli2011-05-121-15/+15
| | | | | | | | | | This removes the following checkpatch issues: - ERROR: "foo * bar" should be "foo *bar" - ERROR: "(foo*)" should be "(foo *)" Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com>
* net/net.c: cosmetic: fix brace issuesLuca Ceresoli2011-05-121-25/+13
| | | | | | | | | | This removes the following checkpatch issues: - WARNING: braces {} are not necessary for single statement blocks - WARNING: braces {} are not necessary for any arm of this statement Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com>
* net/net.c: cosmetic: fix whitespace issuesLuca Ceresoli2011-05-121-93/+93
| | | | | | | | | | | | | | | | | | | | | This removes the following checkpatch issues: - ERROR: space prohibited after that open parenthesis '(' - ERROR: space prohibited before that close parenthesis ')' - ERROR: space prohibited after that open square bracket '[' - ERROR: space prohibited after that '&' (ctx:WxW) - ERROR: spaces required around that '=' (ctx:VxW) - ERROR: space required before the open parenthesis '(' - ERROR: space required after that ',' (ctx:VxV) - ERROR: need consistent spacing around '+' (ctx:WxV) - WARNING: unnecessary whitespace before a quoted newline - WARNING: please, no spaces at the start of a line - WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com> Cc: Mike Frysinger <vapier@gentoo.org>
* net/net.c: cosmetic: variable initializationsLuca Ceresoli2011-05-121-22/+18
| | | | | | | | | | | | This removes the following checkpatch errors: - ERROR: do not initialise globals to 0 or NULL - ERROR: spaces required around that '=' (ctx:VxV) - ERROR: that open brace { should be on the previous line Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com> Cc: Mike Frysinger <vapier@gentoo.org>
* net/net.c: cosmetic: fix lines over 80 charactersLuca Ceresoli2011-05-121-77/+155
| | | | | | | | | | | | | | | | | | | | | This removes the following checkpatch warning: - WARNING: line over 80 characters There are three such warnings left. The first is hard to fix with cosmetic-only changes without compromising code readability, so I'm leaving it as it is for now: WARNING: line over 80 characters #1537: FILE: net.c:1537: + [4 tabs] memcpy(((Ethernet_t *)NetArpWaitTxPacket)->et_dest, ... The other two cannot be fixed without splitting string literals, so it is preferred to keep them longer than 80 characters. Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com> Cc: Mike Frysinger <vapier@gentoo.org>
* NET: pass source IP address to packet handlersLuca Ceresoli2011-05-121-13/+17
| | | | | | | | | | 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>
* netconsole: remove `serverip' checkSimon Guinot2011-05-121-1/+2
| | | | | | | Netconsole use the environment variable `ncip' to configure the destination IP. `serverip' don't need to be defined. Signed-off-by: Simon Guinot <sguinot@lacie.com>
* NET: Correct potential missing goto label in case statement.Gray Remlin2011-04-281-1/+2
| | | | | | | | If neither CONFIG_CMD_PING or CONFIG_CMD_SNTP are defined but CONFIG_CMD_DNS is, a compile-time error will occur due to the absence of a goto label. Signed-off-by: Gray Remlin <gryrmln@gmail.com>
* string_to_VLAN: constify "var" argMike Frysinger2010-11-281-1/+1
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* copy_filename: constify "src" argMike Frysinger2010-11-281-1/+1
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* rarp: Condtionally compile rarp supportPeter Tyser2010-10-111-2/+9
| | | | | | | | Most people don't use the 'rarpboot' command, so only enable it when CONFIG_CMD_RARP is defined. Signed-off-by: Peter Tyser <ptyser@xes-inc.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* ip/defrag: fix processing of last short fragmentFillod Stephane2010-06-201-1/+2
| | | | | | | | | | | TFTP'ing a file of size 1747851 bytes with CONFIG_IP_DEFRAG and CONFIG_TFTP_BLOCKSIZE set to 4096 fails with a timeout, because the last fragment is not taken into account. This patch fixes IP fragments having less than 8 bytes of payload. Signed-off-by: Stephane Fillod <stephane.fillod@grassvalley.com> Acked-by: Alessandro Rubini <rubini@gnudd.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* ./net/net.c - make Microsoft dns servers happy with random_port() numbersRobin Getz2010-05-031-2/+4
| | | | | | | | | | | | For some reason, (which I can't find any documentation on), if U-Boot gives a port number higher than 17500 to a Microsoft DNS server, the server will reply to port 17500, and U-Boot will ignore things (since that isn't the port it asked the DNS server to reply to). This fixes that by ensuring the random port number is less than 17500. Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* Make getenv_IPaddr() globalDirk Behme2010-01-171-26/+0
| | | | | | | | | | | | | | | | | | | There are boards out there that do not have network support in U-Boot (CONFIG_CMD_NET not set), but they do so in Linux. This makes it desirable to be able to port network configuration (like the IP address) to the Linux kernel. We should not make the passing of the IP configuration to Linux dependent on U-Boot features / settings. For this, make getenv_IPaddr() global. This fixes build error u-boot/lib_xxx/board.c:360: undefined reference to `getenv_IPaddr' on various architectures. Signed-off-by: Dirk Behme <dirk.behme@googlemail.com> Acked-by: Ben Warren <biggerbadderben@gmail.com>
* net: pull CONFIG checks out of source and into makefileMike Frysinger2009-12-131-4/+0
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* Repair the 'netretry=once' option.Remy Bohmer2009-11-241-8/+24
| | | | | | | | 'netretry = once' does the same as 'netretry = yes', because it is not stored when it was tried once. Signed-off-by: Remy Bohmer <linux@bohmer.net> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* net: defragment IP packetsAlessandro Rubini2009-08-251-5/+183
| | | | | | | | | | | | | | | | | The defragmenting code is enabled by CONFIG_IP_DEFRAG; the code is useful for TFTP and NFS transfers. The user can specify the maximum defragmented payload as CONFIG_NET_MAXDEFRAG (default 16k). Since NFS has a bigger per-packet overhead than TFTP, the static reassembly buffer can hold CONFIG_NET_MAXDEFRAG + the NFS overhead. The packet buffer is used as an array of "hole" structures, acting as a double-linked list. Each new fragment can split a hole in two, reduce a hole or fill a hole. No support is there for a fragment overlapping two diffrent holes (i.e., thre new fragment is across an already-received fragment). Signed-off-by: Alessandro Rubini <rubini@gnudd.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* minor debug cleanups in ./netRobin Getz2009-08-071-56/+24
| | | | | | | | | | | | | | | 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>
* Save server's MAC address in environmentRobin Getz2009-07-221-0/+9
| | | | | | | | | | | | | | | Linux's netconsole works much better when you can pass it the MAC address of the server. (otherwise it just uses broadcast, which everyone else on my network complains about :) This sets the env var "serveraddr" (to match ethaddr), so that you can pass it to linux with whatever bootargs you want to.... addnetconsole=set bootargs $(bootargs) netconsole=@$(ipaddr)/eth0,@$(serverip)/$(serveraddr) Signed-of-by: Robin Getz <rgetz@blackfin.uclinux.org> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* DHCP regression on 2009-06Michael Zaidman2009-07-221-0/+3
| | | | | | | | | | Fixed the DHCP/BOOTP/RARP regression introduced in u-boot-2009.06 by initializing our IP addr to 0 in order to accept any IP addr assigned to us by the DHCP/BOOTP/RARP server. Ack-by: Robin Getz <rgetz@blackfin.uclinux.org> Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* Add DNS supportRobin Getz2009-07-221-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 04 Oct 2008 Pieter posted a dns implementation for U-Boot. http://www.mail-archive.com/u-boot-users@lists.sourceforge.net/msg10216.html > > DNS can be enabled by setting CFG_CMD_DNS. After performing a query, > the serverip environment var is updated. > > Probably there are some cosmetic issues with the patch. Unfortunatly I > do not have the time to correct these. So if anybody else likes DNS > support in U-Boot and has the time, feel free to patch it in the main tree. Here it is again - slightly modified & smaller: - update to 2009-06 (Pieter's patch was for U-Boot 1.2.0) - README.dns is added - syntax is changed (now takes a third option, the env var to store the result in) - add a random port() function in net.c - sort Makefile in ./net/Makefile - dns just returns unless a env var is given - run through checkpatch, and clean up style issues - remove packet from stack - cleaned up some comments - failure returns much faster (if server responds, don't wait for timeout) - use built in functions (memcpy) rather than byte copy. Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org> Signed-off-by: Pieter Voorthuijsen <pieter.voorthuijsen@prodrive.nl> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* net: rename NetRxPkt to NetRxPacketMike Frysinger2009-07-221-4/+4
| | | | | | | | 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>
* netloop: updates for NetLoopHeiko Schocher2009-05-151-4/+3
| | | | | | | | | | | | | Fix some issues introduced from commit: 2f70c49e5b9813635ad73666aa30f304c7fdeda9 suggested by Mike Frysinger. - added some comment for the env_id variable in common_cmd_nvedit.c - moved some variables in fn scope instead of file scope - NetInitLoop now static void Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Ben Warren <biggerbadderben@gmail.com>
* NetLoop initialization bugMichael Zaidman2009-04-191-59/+4
| | | | | | | | | | | | | | | | | | | | The patch fixes the bug of partial initialization of global network parameters. Upon u-boot's start up the first ping command causes a failure of the consequent TFTP command. It happens in the recently added mechanism of the NetLoop initialization where initialization of global network parameters is separated in the NetInitLoop routine which is called per env_id change. Thus, ping request will initialize the network parameters necessary for ping operation only, afterwards the env_changed_id will be set to the env_id that will prevent all following initialization requests from other protocols. The problem is that the initialized by ping subset of network parameters is not sufficient for other protocols and particularly for TFTP which requires the NetServerIp also. Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* net: get mac address from environment and use eth util funcsMike Frysinger2009-03-201-12/+5
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> CC: Ben Warren <biggerbadderben@gmail.com>
OpenPOWER on IntegriCloud