Commit Graph

99 Commits

Author SHA1 Message Date
Matthias Weisser ea45cb0adc net: Make sure IPaddr_t is 32 bits in size
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>
2011-12-06 22:15:32 +01:00
Wolfgang Denk 5c10419cea net/net.c: Fix GCC 4.6 build warning
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>
2011-11-07 22:14:29 +01:00
Simon Glass e4a3d57dc7 net: Export auto_load, use it in rarp
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>
2011-10-27 23:53:58 +02:00
Simon Glass ed1ada712a net: Change for loop to memset()
This is intended purely as a code size reduction.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-27 23:53:58 +02:00
Simon Glass 39bccd21d0 net: Hide more code behind CONFIG_CMD_TFTPPUT
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>
2011-10-27 23:53:57 +02:00
Simon Glass 1fb7cd498e net: tftpput: implement tftp logic
This adds logic to tftp.c to implement the tftp 'put' command, and
updates the README.

Signed-off-by: Simon Glass <sjg@chromium.org>
2011-10-26 21:36:22 +02:00
Simon Glass e4bf0c5cfe net: tftpput: Rename TFTP to TFTPGET
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>
2011-10-26 21:33:42 +02:00
Simon Glass 4793ee6522 net: tftpput: Add support for receiving ICMP packets
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>
2011-10-26 21:33:25 +02:00
Simon Glass 8f79bb17a4 net: tftpput: Move ICMP code into its own function
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>
2011-10-26 21:32:59 +02:00
Mike Frysinger e2a53458a7 net: drop !NET_MULTI code
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>
2011-10-05 22:22:16 +02:00
Enric Balletbo i Serra 23a70bf9c3 net/net.c: Update ipaddr if the environment has changed
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🇩🇪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>
2011-06-01 22:17:49 +02:00
Luca Ceresoli 7a83af07ae TFTP: add tftpsrv command
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-05-19 21:38:32 +02:00
Luca Ceresoli ccb9ebefbe net/net.c: cosmetic: do not use assignment in if condition
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>
2011-05-12 22:07:41 +02:00
Luca Ceresoli c819abeef7 net/net.c: cosmetic: fix indentation
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>
2011-05-12 22:07:31 +02:00
Luca Ceresoli 92895de978 net/net.c: cosmetic: parentheses not required for return
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>
2011-05-12 22:06:04 +02:00
Luca Ceresoli 6b147d1139 net/net.c: cosmetic: fix pointer syntax issues
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>
2011-05-12 22:03:47 +02:00
Luca Ceresoli d3c65b015a net/net.c: cosmetic: fix brace issues
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>
2011-05-12 22:01:34 +02:00
Luca Ceresoli 4f63acd062 net/net.c: cosmetic: fix whitespace issues
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>
2011-05-12 22:01:05 +02:00
Luca Ceresoli c586ce6e01 net/net.c: cosmetic: variable initializations
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>
2011-05-12 21:49:56 +02:00
Luca Ceresoli 3e38e429ff net/net.c: cosmetic: fix lines over 80 characters
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>
2011-05-12 21:49:49 +02:00
Luca Ceresoli 03eb129f8a NET: pass source IP address to packet handlers
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>
2011-05-12 19:38:19 +02:00
Simon Guinot 8b6bbe104f netconsole: remove `serverip' check
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>
2011-05-12 19:11:51 +02:00
Gray Remlin 9030a55ef3 NET: Correct potential missing goto label in case statement.
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>
2011-04-28 00:46:49 +02:00
Mike Frysinger 2e3ef6e4e4 string_to_VLAN: constify "var" arg
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-11-28 21:56:12 +01:00
Mike Frysinger b920ee9db2 copy_filename: constify "src" arg
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-11-28 21:55:15 +01:00
Peter Tyser bf6cb247a5 rarp: Condtionally compile rarp support
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>
2010-10-11 23:00:29 -07:00
Fillod Stephane e397e59e86 ip/defrag: fix processing of last short fragment
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>
2010-06-20 22:11:32 -07:00
Robin Getz 9739946cc5 ./net/net.c - make Microsoft dns servers happy with random_port() numbers
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>
2010-05-03 14:52:48 -07:00
Dirk Behme 6a45e38495 Make getenv_IPaddr() global
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>
2010-01-17 20:14:47 +01:00
Mike Frysinger 6ac59c5518 net: pull CONFIG checks out of source and into makefile
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2009-12-13 21:31:26 -08:00
Remy Bohmer 67b96e87da Repair the 'netretry=once' option.
'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>
2009-11-24 14:04:11 -08:00
Alessandro Rubini 5cfaa4e54d net: defragment IP packets
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>
2009-08-25 13:35:54 -07:00
Robin Getz 0ebf04c607 minor debug cleanups in ./net
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>
2009-08-07 17:32:16 -07:00
Robin Getz 97cfe86163 Save server's MAC address in environment
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>
2009-07-22 23:17:01 -07:00
Michael Zaidman 09133f8580 DHCP regression on 2009-06
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>
2009-07-22 22:53:45 -07:00
Robin Getz 1a32bf4188 Add DNS support
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>
2009-07-22 22:53:44 -07:00
Mike Frysinger d9bec9f42a net: rename NetRxPkt to NetRxPacket
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>
2009-07-22 22:53:43 -07:00
Heiko Schocher da95427ce4 netloop: updates for NetLoop
Fix some issues introduced from commit:
2f70c49e5b
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>
2009-05-15 21:19:02 +02:00
Michael Zaidman 3c172c4fdb NetLoop initialization bug
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>
2009-04-19 23:24:16 -07:00
Mike Frysinger 95823ca077 net: get mac address from environment and use eth util funcs
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
2009-03-20 22:39:09 +01:00
Mike Frysinger b6446b6775 convert print_IPaddr() to %pI4
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>
2009-03-20 22:39:09 +01:00
Heiko Schocher 2f70c49e5b netloop: speed up NetLoop
NetLoop polls every cycle with getenv some environment variables.
This is horribly slow, especially when the environment is big.

This patch reads only the environment variables in NetLoop,
when they were changed.

Also moved the init part of the NetLoop function in a seperate
function.

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2009-02-22 23:49:33 -08:00
Olav Morken af8626e0c0 Fix IP alignment problem
This patch removes volatile from:
volatile IP_t *ip = (IP_t *)xip;

Due to a bug, avr32-gcc will assume that ip is aligned on a word boundary when
using volatile, which causes an exception since xip isn't aligned on a word
boundary.

Signed-off-by: Gunnar Rangoy <gunnar@rangoy.com>
Signed-off-by: Paul Driveklepp <pauldriveklepp@gmail.com>
Signed-off-by: Olav Morken <olavmrk@gmail.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2009-01-28 23:59:28 -08:00
Wolfgang Denk c645b181a9 Merge branch 'master' of git://git.denx.de/u-boot-net 2008-12-09 01:00:24 +01:00
Peter Tyser 561858ee7d Update U-Boot's build timestamp on every compile
Use the GNU 'date' command to auto-generate a new U-Boot
timestamp on every compile.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
2008-12-06 23:36:43 +01:00
Peter Tyser d32c5be50b net: Add additional IP fragmentation check
Ignore IP packets which have the "more fragments" flag bit
set.  This flag indicates the IP packet is fragmented and
must be ignored by U-Boot.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2008-12-04 22:51:54 -08:00
Peter Tyser e0c07b868c net: Define IP flag field values
These defines were pulled from the "Add simple
IP/UDP fragmentation support" patch from Frank
Haverkamp <haver@vnet.ibm.com>.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2008-12-04 22:51:54 -08:00
Jean-Christophe PLAGNIOL-VILLARD 6d0f6bcf33 rename CFG_ macros to CONFIG_SYS
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-10-18 21:54:03 +02:00
Bartlomiej Sieka 49f3bdbba8 net: express the first argument to NetSetTimeout() in milliseconds
Enforce millisecond semantics of the first argument to NetSetTimeout() --
the change is transparent for well-behaving boards (CFG_HZ == 1000 and
get_timer() countiing in milliseconds).

Rationale for this patch is to enable millisecond granularity for
network-related timeouts, which is needed for the upcoming automatic
software update feature.

Summary of changes:
- do not scale the first argument to NetSetTimeout() by CFG_HZ
- change timeout values used in the networking code to milliseconds

Signed-off-by: Rafal Czubak <rcz@semihalf.com>
Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2008-10-18 21:54:00 +02:00
Wolfgang Denk 25dbe98abb Fix some more printf() format issues.
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-07-13 23:07:35 +02:00