9
0
Fork 0
Commit Graph

439 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 1c738631f2 net: Initial frame to be able to send LLDP frames from barebox
Fixes: SYS#488
2017-03-30 20:23:47 +02:00
Bastian Stender 1233570798 console: replace set_active by open/close
Opening and closing consoles should be independent from setting them
active. This way it is possible to open e.g. a framebuffer console and
display text on it without showing stdout/stderr.

Signed-off-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2017-02-28 15:52:35 +01:00
Enrico Jorns 841d83ff0a net: add linux.bootarg parameter from ifup call
This sets a `ip=dhcp` or
`ip=<clientip>:<serverip>:<gatewayip>:<netmaskip>::<iface>:` bootarg for
the network device upon execution of 'ifup'. This is the only point
where we can distinguish between a static ip and a dhcp-based network
setup and thus set a valid bootarg options as it will be required for
nfs boot, for example.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-22 11:30:38 +02:00
Sascha Hauer d60230bded convert users to %pI4
Convert users of ip_to_string() and print_IPaddr() to %pI4 and
remove the now unused functions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-22 11:30:38 +02:00
Sascha Hauer a622565d06 net: Pass network device to net_answer_arp()
The caller already has the correct network device, so pass it
to net_answer_arp() rather than using eth_get_current() there.
This is a step towards making a global current network device
unnecessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-14 22:32:35 +02:00
Sascha Hauer 5ed70d2fa2 net: eth: add name to struct eth_device
Using dev_name often is not a good idea since it's a statically
allocated string which gets overwritten by later calls to dev_name.
Add a devname string to struct eth_device to have the name available
for later use.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-14 22:24:53 +02:00
Sascha Hauer 8b3244d3a8 net: introduce for_each_netdev iterator
for_each_netdev is nicer to read. Also export the list of network
devices since it will be used by code outside of net/eth.c in later
patches.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-14 22:24:19 +02:00
Sascha Hauer 048864571f net: eth: open correct edev in eth_check_open
eth_check_open gets the network device to check as parameter, so
use it rather than using eth_current. Currently both are the same,
so this currently does not fix anything.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-14 22:22:57 +02:00
Alexander Aring b0e1847f13 ifup: fix handling when ip env is not given
This patch handles the ip env to "" if no ip env is given. Otherwise
we get a NULL pointer derefence.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-15 07:43:01 +02:00
Sascha Hauer 947fb5adf8 string: Fix (v)asprintf prototypes
Our asprintf and vasprintf have different prototypes than the glibc
functions. This causes trouble when we want to share barebox code
with userspace code. Change the prototypes for (v)asprintf to match
the glibc prototypes. Since the current (v)asprintf are convenient
to use change the existing functions to b(v)asprintf.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer 1b59b573e4 Merge branch 'for-next/rtc' 2016-01-11 13:11:08 +01:00
Sascha Hauer f98b02365f net: Add SNTP support
This adds support for retrieving the time via Simple Network Time
Protocol (SNTP). No fancy features are supported, only plainly getting
the current time.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-07 08:46:09 +01:00
Sascha Hauer 39698df6f7 net: resolv: Make argument const
resolv() is not allowed to change the hostname argument, make it const.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-14 11:40:50 +01:00
Sascha Hauer 7065fa32ca net: dhcp: make unmodified variable const
'str' in dhcp_set_string_options is never modified, so make it const.
With this we no longer have to cast away the const returned from getenv.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-14 11:40:45 +01:00
Sascha Hauer 802d8fdfbe net: dhcp: simplify dhcp_options_process
dhcp_options_handle returns the index into the dhcp_options array.
This is only to be able in the caller to print a debug message when
the index returned from dhcp_options_handle is out of bounds.
Simplify this by printing the debug message in dhcp_options_handle
and not in the caller.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-14 11:40:40 +01:00
Sascha Hauer d917c04972 net: dhcp: unify options and params
The dhcp code distinguishes between options and params. If sent to the
server they are params, if received from the server they are options.
Unify them all to be options. If it has a handle_param callback it's
a param, if it has a handle callback it's an option.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-14 11:40:36 +01:00
Jan Remmet b9170a1bde net: eth: Remove ethaddr_param
commit d00db554 introduce ethaddr_param. But it is not initialized, so
devinfo fails to show the mac. Remove it and use edev->ethaddr.

Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-11-20 08:23:07 +01:00
Trent Piepho a5c51acab4 net: eth: Fixup OF tree with registered MAC addresses too
The eth code registers an OF tree fixup that looks for any nodes in
the Linux oftree that match eth devices loaded in barebox and sets the
mac-address property in those nodes.  The purpose is to pass MAC
addresses to the Linux kernel for drivers that expect the MAC address
to be in the device tree.

If barebox does not have a driver for the network device, either
because it has been disabled or because one does not exist, then the
OF tree will not be fixed up to include a MAC address.

The eth code also has a list of MAC addresses which board code has
registered, usually done when it reads the address from an EEPROM or
on-chip memory.  If an eth device is created later in the boot, it
will look here for an address.

The registered MAC address list is not used for the OF tree fix up,
and this patch changes that.  This way barebox can place a MAC address
in the device-tree without needing a driver for the network device.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-22 09:07:52 +02:00
Trent Piepho cb32b33aaf net: eth: Refactor OF tree fixup of one node into new function
Code that fixes up one node with a new MAC address is refactored into
a new function that eth_of_fixup() calls in a loop.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-22 09:07:52 +02:00
Wadim Egorov 4a1379886f net: dhcp: Fix CONFIG variable name
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-29 09:34:17 +02:00
Sascha Hauer e188d2ec26 Merge branch 'for-next/net' 2015-08-06 12:33:15 +02:00
Sascha Hauer 65681ac201 net: make eth_register_ethaddr work on registered network devices
When eth_register_ethaddr is called after the device has been registered
it should work aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-07-28 08:00:03 +02:00
Antony Pavlov 06df5b2092 net: eth_send: Allow to use multiple network interfaces at once
The commit

commit be0404c21f
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Wed May 14 16:08:04 2014 +0200

    net: Allow to use multiple network interfaces at once

changes the eth_send() function:

-       return eth_current->send(eth_current, packet, length);
+       return edev->send(eth_current, packet, length);

But we have to change the both eth_current occurrences to edev here!

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-07-23 10:51:04 +02:00
Sascha Hauer c408a4ecbe Merge branch 'for-next/net' 2015-07-03 08:37:54 +02:00
Antony Pavlov 177cab00ce treewide: fix 'new blank line at EOF' formatting error
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-07-02 09:39:58 +02:00
Sascha Hauer 566cac17c3 net: Move library functions to net/lib.c
Some network related functions are also needed when networking
is disabled. Move these to a separate file which is always compiled.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-07-02 09:39:57 +02:00
Antony Pavlov 8bbc1064c7 dns: handle incoming packets in the separate dns_recv() function
The separation of incoming packets handling makes it much easier
to run barebox dns client on top of picotcp network stack in the future.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-07-01 07:34:26 +02:00
Sascha Hauer d00db5548a net: eth: Do not rely on CONFIG_PARAMETER to be enabled
register_preset_mac_address only works when CONFIG_PARAMETER
is enabled because otherwise dev_set_param is a no-op. Add a
function to set the MAC address explicitly without the need
of CONFIG_PARAMETER and use it where appropriate.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-26 11:56:22 +02:00
Sascha Hauer ee2ac17df0 Merge branch 'for-next/am33xx' 2015-06-09 09:26:43 +02:00
Wadim Egorov e9bd26c7a7 net: dhcp: Split dhcp funcionality & add dhcp command
dhcp/bootp was bound to the command functionality.
This patch splits the dhcp command.
We are now able to use bootp without a shell.

This patch adds also a check for environment variables and globalvar.
So only when ENVIRONMENT_VARIABLES and GLOBALVAR is set, all received
dhcp data will be stored.

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-05 13:32:39 +02:00
Sascha Hauer acd1d67ea2 eth: halt active ethernet device on unregister
When an active ethernet device is unregistered it should
be halted to quiesce the device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-04-28 12:41:45 +02:00
Mirko Damiani e44c9b04c4 net: ping: return an error exit code when connection fails
ping command does not always returns 1 as exit code when connection to
host fails. In particular it returns the exit code of the previous run.
This patch fixes this issue.

Signed-off-by: Mirko Damiani <mirko@develer.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-04-03 08:03:08 +02:00
Sascha Hauer 37052f6c9b Merge branch 'for-next/net' 2015-02-04 19:09:15 +01:00
Eric Bénard 223adf761b dhcp: fix request packet's seconds elapsed
it's done in the discover packet so let's do it also in the request packet.

Signed-off-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-29 08:39:04 +01:00
Eric Bénard ea0a3b7da8 dhcp: fix request packet
we are not supposed to fill ciaddr, yiaddr and siaddr in the request packet.

Signed-off-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-29 08:39:03 +01:00
Eric Bénard 1f9cf67ab0 dhcp: fix request packet's requested IP option
In the request packet, we are supposed to copy the IP that the DHCP server
provided in the offer packet so that dhcp_extended can fill the option 50.
There is actually an error in barebox as the pointer to the packet currently
built is used as the source instead of the pointer to the offer packet.
With this patch, barebox now sends a request packet which includes the right
requested IP in option 50.

Signed-off-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-29 08:39:03 +01:00
Jean-Christophe PLAGNIOL-VILLARD a1a582f4e0 console: allow to specify the device id
so we can use dynamic number id with specific devname

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-13 08:48:59 +01:00
Sascha Hauer 0ef2e3e315 netconsole: activate in set_active callback
Activate the netconsole in the set_active callback. Add proper
checks there for port and ip address, print an error when the network
hasn't been configured and finally print when the netconsole has
been enabled successfully. This makes using of the netconsole easier.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-12-17 15:09:35 +01:00
Sascha Hauer 5c0bd50319 net: Call edev->recv with correct eth_device
edev->recv has to be called with edev as argument, not eth_current.
This fixes networking when multiple network devices are used and the
current one is switched during runtime.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-09-17 12:27:42 +02:00
Sascha Hauer 8eacfa71ab netconsole: rename console to "netconsole"
So that it can be used without guessing the name first.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-07-11 09:58:47 +02:00
Sascha Hauer deef1e80f3 Do not use macros in command help
The help texts are parsed by sphinx which cannot handle macros, so
replace them with their values.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-07-08 07:52:36 +02:00
Sascha Hauer 98360be0fe Documentation: remove doxygen documentation
The doxygen documentation is long outdated. Remove it. It will
be replaced with sphinx based documentation later.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-26 10:09:52 +02:00
Sascha Hauer 40d89c4977 ifup: Add comment why xxx-discover files have to be skipped
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-23 10:05:40 +02:00
Sascha Hauer 096e5c856b net: ifup: skip *-discover files for ifup -a
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-23 09:14:31 +02:00
Sascha Hauer a3dfea9af8 Merge branch 'for-next/net'
Conflicts:
	drivers/net/dm9k.c
2014-06-04 21:03:45 +02:00
Holger Schurig 7158ac3f6e net: show enetaddr in lowercase
"ifconfig" and "ip" from normal Linux userspace shows ethernet addresses
normally in lowercase.  And the %pM format specifier in Linux does that,
too. Conform to this custom formatting.

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-02 09:07:12 +02:00
Sascha Hauer 0cf4630cd2 net: take eth id from devicetree alias
If the devicetree has an alias for the ethernet device, then use
it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-15 10:04:51 +02:00
Sascha Hauer be0404c21f net: Allow to use multiple network interfaces at once
In barebox network packets always go out at the current ethernet
device and are expected to be received from the current interface.
This has some side effects. When for example an NFS is mounted when
one interface is active and the interface is changed afterwards the
NFS packets leave the new interface, but the NFS server won't be
reachable there.

Instead of changing the whole network traffic to the current ethernet
interface we now initialize a network connection with the current
network interface, but then the connection will continue to use that
interface even when the current interface is changed.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-15 08:16:30 +02:00
Sascha Hauer 22b878d251 net: Pass eth_device to net_receive
So that barebox has the information which interface a packet
came from.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-15 08:15:21 +02:00
Sascha Hauer 75482a0663 net: ifup: Set current ethernet device when doing ifup
When doing an ifup set the current interface to the one just
brought up so that it is actually used.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-15 08:15:13 +02:00