Commit Graph

118 Commits

Author SHA1 Message Date
Joe Hershberger 4545f4e6db net: cosmetic: Alphabetize includes in net.c
Easier to find when alphabetized

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:17 -05:00
Joe Hershberger 0b4c5ff4ab net: cosmetic: Rename CDPHandler to cdp_receive
This is not called as a handler, so don't name it that way

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:16 -05:00
Joe Hershberger 8d353eb86d net: cosmetic: Rename "x" to "eth_proto"
x is a poor variable name

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:46:16 -05:00
Joe Hershberger da5ebe2c9a net: cosmetic: Add a more explicit comment about 802.2
Make the comment more accurate about the header including SNAP

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:46:16 -05:00
Joe Hershberger 206d07fd7c net: cosmetic: Rename parameter len to payload_len
This name more explicitly claims that it does not include the
header size

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-23 17:46:15 -05:00
Joe Hershberger e0a630795b net: cosmetic: Un-typedef ICMP_t
Remove typedef and lower-case name

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:15 -05:00
Joe Hershberger c68cca35b3 net: cosmetic: Un-typedef VLAN_Ethernet_t
Eliminate the typedef and remove capital letters

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:14 -05:00
Joe Hershberger cb487f5664 net: cosmetic: Un-typedef Ethernet_t
Separate the Ethernet header from the 802 header.
Base the size constants on the structs.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:14 -05:00
Joe Hershberger c5c59df04d net: cosmetic: Split struct ip_udp_hdr into ip_hdr
Add a structure that only contains IP header fields to be used by
functions that don't need UDP
Rename IP_HDR_SIZE_NO_UDP to IP_HDR_SIZE

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 17:46:14 -05:00
Joe Hershberger 594c26f8a7 net: cosmetic: Un-typedef IP_t
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>
2012-05-23 17:46:00 -05:00
Joe Hershberger 8b9c53221f net: Move RARP receive logic out of net.c
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>
2012-05-23 14:19:24 -05:00
Joe Hershberger a36b12f95a net: Move PING out of net.c
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>
2012-05-23 14:19:23 -05:00
Joe Hershberger d280d3f430 net: Move ARP out of net.c
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>
2012-05-23 14:19:23 -05:00
Joe Hershberger 1735188329 net: Encapsulate CDP packet identification
Checking for CDP packets should be encapsulated, not copied code.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 14:19:23 -05:00
Joe Hershberger f575ae1f7d net: Move CDP out of net.c
Separate this functionality out of the net.c behemoth

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-05-23 14:19:22 -05:00
Mike Frysinger 50a47d0523 net: punt bd->bi_ip_addr
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>
2012-05-15 17:32:05 -05:00
Joe Hershberger 48522bb503 net: cosmetic: net.c checkpatch compliance
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:16:19 -05:00
Joe Hershberger db288a9602 net: Remove volatile from net API
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
2012-05-15 17:10:04 -05:00
Simon Glass 573f14fe4e bootstage: Plumb in bootstage calls for basic operations
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>
2012-03-18 21:42:56 +01:00
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