summaryrefslogtreecommitdiffstats
path: root/include/net.h
Commit message (Collapse)AuthorAgeFilesLines
* net: dns: return error codesSascha Hauer2018-11-291-5/+3
| | | | | | | | | | | | | | The resolv() function used to return the IP address. When net_udp_new() fails we return an error code though which the callers of resolv() take as an IP address. This is wrong of course and we could return 0 in this case. Instead we return an error code and pass the resolved IP as a pointer which allows us to return proper error codes. This patch also adds error messages and error returns to the various callers of resolv() which used to just continue with a zero IP and let the user figure out what went wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add linuxdevname propertySascha Hauer2017-12-151-0/+1
| | | | | | | | | | | | | | | | | When you have a static network environment but more than one network device on your machine it is necessary to provide the <device> parameter to the ip parameter at kernel cmd line. The device name assigned by Linux cannot in general be predicted as it depends on driver bind order. This patch introduces a new property linux.devname to eth devices. The value is added to bootargs per interface and can be changed in env/network/INTF Based on patch by Gavin Schenk <g.schenk@eckelmann.de>. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Provide new way to configure network devicesSascha Hauer2017-12-141-0/+7
| | | | | | | | | | | | | | | | | | | This provides a new way to configure network interfaces based on nvvars. A network interface can now be configured with variables in the nv.dev.<ethname>.* namespace. There is a new network device parameter "mode" which specifies the mode used to obtain IP settings. The mode can be "dhcp", "static" or "disabled": nv.dev.eth0.mode=dhcp (ipaddr, netmask are ignored in this setting) nv.dev.eth0.mode=static nv.dev.eth0.ipaddr=192.168.0.17 nv.dev.eth0.netmask=255.255.0.0 nv.dev.eth0.mode=disabled Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove "current" network deviceSascha Hauer2017-12-141-2/+0
| | | | | | | Now that we can do routing we no longer need a "current" network device. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Pick network device based on IP settingsSascha Hauer2017-12-141-0/+1
| | | | | | | | | The IP/netmask/gateway settings contain all informations needed to pick the correct network device. This patch adds support for that and makes specifying the "current" network interface using the ethact command unnecessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: Allow to specify network deviceSascha Hauer2017-12-141-3/+3
| | | | | | | | | Instead of allowing to DHCP only on the "current" network device, allow to specify the desired network device. This is a first step to get rid of the concept of a "current" network device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: allow udp connections on specified network deviceSascha Hauer2017-12-011-0/+4
| | | | | | | | This allows the DHCP code to configure specific network devices so that DHCP no longer depends on any "current" network device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Use a single gatewaySascha Hauer2017-12-011-1/+1
| | | | | | | | | | | | | | There is not much point in having a network device specific gateway. If barebox really is part of such a complicated network in which it needs multiple gateways, then we probably need a real routing table. Until this happens, a single gateway should be enough. This introduces global.net.gateway which holds the gateway ip. The previously used device specific <ethx>.gateway variables still exist, but are only aliases for the single gateway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: Do not overwrite serverip if it is validSascha Hauer2017-12-011-0/+1
| | | | | | | | | | | | | Some DHCP servers provide the wrong serverip in which case it is desired to specify it manually and won't let the dhcp command overwrite it. This has previously been done by setting the serverip again to the desired value after dhcp has been executed. With this patch we do not overwrite it in the first place if it is valid already. This is necessary when the serverip is not set via /env/network/eth* but via nv.net.server. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: introduce global.net.serverSascha Hauer2017-12-011-1/+0
| | | | | | | | | | | | The server to use is independent of the network device, there is not much point to make the server specific to a network device. This introduces global.net.server as the serverip which is used as standard NFS/tftp server. The previously used eth device specific parameters still exist, but are only aliases for the global single variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add functions to get/set nameserver and domainnameSascha Hauer2017-12-011-0/+4
| | | | | | | | | It's more convenient to have getter/setter functions for variables rather than using the detour around global vars which use string matching and all kinds of overhead in the background. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add and use IP_BROADCASTSascha Hauer2017-12-011-0/+2
| | | | | | | Rather than using the hardcoded value 0xffffffff in several places add a define for the broadcast IP. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: add linux.bootarg parameter from ifup callEnrico Jorns2016-09-221-0/+1
| | | | | | | | | | | | | 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>
* convert users to %pI4Sascha Hauer2016-09-221-6/+0
| | | | | | | 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>
* net: eth: add name to struct eth_deviceSascha Hauer2016-07-141-0/+6
| | | | | | | | | 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>
* net: introduce for_each_netdev iteratorSascha Hauer2016-07-141-0/+4
| | | | | | | | 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>
* net: resolv: Make argument constSascha Hauer2015-12-141-2/+2
| | | | | | resolv() is not allowed to change the hostname argument, make it const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Remove ethaddr_paramJan Remmet2015-11-201-1/+0
| | | | | | | | 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>
* net_udp_bind(): use uint16_t type for source portAntony Pavlov2015-07-201-1/+1
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Do not rely on CONFIG_PARAMETER to be enabledSascha Hauer2015-06-261-0/+2
| | | | | | | | | 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>
* net: Make set_ethaddr argument constSascha Hauer2015-06-261-1/+1
| | | | | | | The set_ethaddr callback should not modify the MAC address passed to it, so make it const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net.h: add ETH_ALEN constant; fix whitespacesAntony Pavlov2014-07-021-3/+5
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Allow to use multiple network interfaces at onceSascha Hauer2014-05-151-1/+2
| | | | | | | | | | | | | | | | 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>
* net: Pass eth_device to net_receiveSascha Hauer2014-05-151-1/+1
| | | | | | | So that barebox has the information which interface a packet came from. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add ifup supportSascha Hauer2014-03-071-0/+5
| | | | | | | | The defaultenv-2 has ifup support as a shell script. This patch replaces it with a command which is more robust, can be called from C and now can also bring up all configured interfaces. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: constify eth_get_byname argumentSascha Hauer2014-03-071-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: new function net_read_uint64Uwe Kleine-König2014-02-101-0/+7
| | | | | | | | This is needed for nfs3 support as some types became bigger compared to nfs2. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: net_read_uint32: assert that only 32 bit are readUwe Kleine-König2014-02-101-4/+4
| | | | | | | | | | | | | | | On some architectures (e.g. alpha, amd64, arm64, ia64, s390x, mips64) sizeof(ulong) is 8 which made net_read_uint32 actually read too much and even returned the wrong value on big endian machines. (Note the second issue isn't that critical though, because the only architecture from the list above that uses big endian byte order is s390x ...) Also change the argument to void * because the pointer is not necessarily properly aligned. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Set mac-address propertySascha Hauer2013-06-051-0/+1
| | | | | | | | | | Linux normally has no idea how to retrieve MAC Addresses, but instead expects the MAC address in the devicetree. This patch adds the MAC address to the devicetree for Linux if we find a valid one in barebox. This mechanism is limited of course to devices barebox has a driver for and which are probed themselves from the devicetree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx-oftree'Sascha Hauer2013-06-021-0/+5
|\ | | | | | | | | Conflicts: arch/arm/boards/freescale-mx51-pdk/board.c
| * net: Add of_register_ethaddrSascha Hauer2013-05-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | We already have a possibility to register a MAC address provider based on a ethernet device id. This adds a similar functionality for devices probed from devicetree. Code can register itself to be a MAC address provider for a certain devicetree node. This helps on i.MX to let the IIM unit provide a MAC address for the FEC. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide include/: Add missing includesSascha Hauer2013-05-311-0/+2
|/ | | | | | | This adds several missing includes to files under include/ which we relied on being included implicitly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: store ethernet device parameters in deviceSascha Hauer2013-04-111-1/+6
| | | | | | | | Rather than storing the parameters globally and trying to keep them in sync with the device parameters, store the parameters in the ethernet device directly. Also, update to dev_add_param_ip(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove unused prototypes for eth_[open|halt]Sascha Hauer2012-09-271-2/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: introduce phylibJean-Christophe PLAGNIOL-VILLARD2012-09-251-0/+4
| | | | | | | | | | | | | | | | Adapt phylib from linux switch all the driver to it reimplement mii bus This will allow to have - phy drivers - to only connect the phy at then opening of the device - if the phy is not ready or not up fail on open Same behaviour as in linux and will allow to share code and simplify porting. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* eth: eth MAC addresses are six bytesJohannes Stezenbach2012-06-301-4/+4
| | | | | | | | Reduce confusion by making clear six bytes are passed, not a string. Signed-off-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* iim: fix compilation when NET is not selectedEric Bénard2012-05-181-1/+6
| | | | | Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove unused getenv_ip_dnsSascha Hauer2012-04-151-5/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: use static string in string_to_ipSascha Hauer2012-04-151-1/+1
| | | | | | Simplify usage of ip_to_string by using a static string. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: arp_request: do not retry endlesslyWolfram Sang2012-04-051-0/+2
| | | | | Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: env: getenv_ip use resolvJean-Christophe PLAGNIOL-VILLARD2012-04-031-1/+5
| | | | | | | Introduce getenv_ip_dns to be able to do not do the resolv when using it in resolv for the nameserver (Do not loop). Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* net: use container_of instead of dev->type_dataSascha Hauer2012-02-251-0/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: let net_udp_get_payload return void *Sascha Hauer2012-02-191-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: make the ethernet device a child of the hardware deviceSascha Hauer2011-08-151-0/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add a possibility for boards to give network devices a MAC addressSascha Hauer2011-07-291-0/+6
| | | | | | | | | MAC addresses are sometimes stored at unusual places. This patch makes it possible to give a MAC address to a ethernet device id. This is independent of the device actually being present. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove unused fields from struct eth_deviceSascha Hauer2011-07-291-2/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: add a context to the packet handlerSascha Hauer2011-04-121-3/+5
| | | | | | | This is not yet used, but with this the different network commands can get rid of their global data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Fix error handling with malloc, memalign etc. Introduce xmemalign().Krzysztof Halasa2011-01-071-1/+1
| | | | | | | | | | | | | | The idea is to panic() when there is no memory available for normal operation. Exception: code which can consume arbitrary amount of RAM (example: files allocated in ramfs) must report error instead of panic(). This patch also fixes code which didn't check for NULL from malloc() etc. Usage: malloc(), memalign() return NULL when out of RAM. xmalloc(), xmemalign() always return non-NULL or panic(). Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Remove unused eth_get_name() prototype.Krzysztof Halasa2010-12-211-1/+0
| | | | | Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* LED: Add LED trigger supportSascha Hauer2010-12-201-0/+3
| | | | | | | This patch allows to associate LEDs with certain triggers, such as heartbeat or network activity. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>