summaryrefslogtreecommitdiffstats
path: root/net/net.c
Commit message (Collapse)AuthorAgeFilesLines
* net: Pick network device based on IP settingsSascha Hauer2017-12-141-2/+28
| | | | | | | | | 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-9/+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-12/+20
| | | | | | | | 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-4/+9
| | | | | | | | | | | | | | 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/+8
| | | | | | | | | | | | | 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-6/+5
| | | | | | | | | | | | 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/+24
| | | | | | | | | 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: Make domainname and nameserver globalvarsSascha Hauer2017-12-011-15/+10
| | | | | | | | | Register domainname and nameserver as globalvars rather than attaching them to a dedicated net device. the global device already exists and already contains much of the barebox configuration, so no need to add an extra device for network config. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add and use IP_BROADCASTSascha Hauer2017-12-011-3/+3
| | | | | | | 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: use pr_* functions for messagesSascha Hauer2017-12-011-12/+14
| | | | | | | | Use pr_* functions in the networking code rather than printf() and debug(). Also Add a "net: " prefix to messages to give them some more context. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: use dev_add_param_stringSascha Hauer2017-04-111-2/+9
| | | | | | | dev_add_param_string allows to pass a priv * so that the device_d * argument is not needed and can be removed later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* convert users to %pI4Sascha Hauer2016-09-221-2/+2
| | | | | | | 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: Pass network device to net_answer_arp()Sascha Hauer2016-07-141-3/+2
| | | | | | | | | 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>
* treewide: fix 'new blank line at EOF' formatting errorAntony Pavlov2015-07-021-1/+0
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Move library functions to net/lib.cSascha Hauer2015-07-021-78/+0
| | | | | | | 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>
* net: eth: Do not rely on CONFIG_PARAMETER to be enabledSascha Hauer2015-06-261-1/+1
| | | | | | | | | 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>
* Merge branch 'for-next/net'Sascha Hauer2014-06-041-11/+10
|\ | | | | | | | | Conflicts: drivers/net/dm9k.c
| * net: Allow to use multiple network interfaces at onceSascha Hauer2014-05-151-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: show enetaddr in lowercaseHolger Schurig2014-06-021-1/+1
|/ | | | | | | | | "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>
* net: Fix error return value for string_to_ethaddrSascha Hauer2014-01-201-2/+2
| | | | | | Return a proper error code instead of -1 which would be -EPERM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* barebox: remove double semicolonsAlexander Aring2013-11-181-1/+1
| | | | | Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: fix checksum verificationBaruch Siach2013-08-121-1/+1
| | | | | | | | | Checksum calculation on data including its own checksum (as is the case with IP headers) should give 0xffff before bit flipping. Current code works well for the correct checksum case, but fails to identify errors. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: store ethernet device parameters in deviceSascha Hauer2013-04-111-48/+32
| | | | | | | | 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>
* mem: add the swab (swap bytes) option to memory_display()Antony Pavlov2012-11-261-1/+1
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/remove-fsf-address'Sascha Hauer2012-10-031-3/+0
|\ | | | | | | | | | | Conflicts: drivers/net/miidev.c include/miidev.h
| * Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-3/+0
| | | | | | | | | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: catch error on eth_sendJean-Christophe PLAGNIOL-VILLARD2012-09-161-7/+11
|/ | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* eth: eth MAC addresses are six bytesJohannes Stezenbach2012-06-301-2/+2
| | | | | | | | 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>
* Merge branch 'work/dns' into nextSascha Hauer2012-04-161-12/+16
|\
| * net: remove unused getenv_ip_dnsSascha Hauer2012-04-151-4/+1
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: register a 'net' device to store network specific variablesSascha Hauer2012-04-151-0/+9
| | | | | | | | | | | | | | 'nameserver' and 'domainname' should be globally available variables specific to networking. Register a 'net' device to store these variables. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: use static string in string_to_ipSascha Hauer2012-04-151-8/+6
| | | | | | | | | | | | Simplify usage of ip_to_string by using a static string. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: use net_alloc_packet to allocate packetJean-Christophe PLAGNIOL-VILLARD2012-04-151-2/+2
|/ | | | | | | Was missing in net_init and net_new. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: arp_request: do not retry endlesslyWolfram Sang2012-04-051-0/+5
| | | | | 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-3/+6
| | | | | | | 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: set enetaddr to invalid address when an invalid string is passedSascha Hauer2012-02-141-2/+4
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove unused watchdog headerSascha Hauer2011-12-151-1/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: getenv_ip: check return value of string_to_ipWolfram Sang2011-09-261-1/+2
| | | | | | | Return 0 if we encounter an error. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: string_to_ip: add sanity check for > 255Wolfram Sang2011-09-261-2/+4
| | | | | Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: add a context to the packet handlerSascha Hauer2011-04-121-7/+10
| | | | | | | 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-2/+2
| | | | | | | | | | | | | | 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>
* LED: Add LED trigger supportSascha Hauer2010-12-201-5/+15
| | | | | | | This patch allows to associate LEDs with certain triggers, such as heartbeat or network activity. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: make locally used functions staticSascha Hauer2010-10-211-2/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: use a random mac address if the current device does not have a valid ↵Sascha Hauer2010-06-221-1/+10
| | | | | | address Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove old network stackSascha Hauer2010-06-171-897/+47
| | | | | | All network commands now use the new stack, so remove the old one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Implement a new network stackSascha Hauer2010-06-171-4/+536
| | | | | | | | | | | | | | | | | The old network stack has some bad limitations: - network commands are required to call NetLoop() which only returns when the network layer wants to. Instead we now use a net_poll() function which returns after handling one packet (or immediately if no packet is available). - There can be only one packet handler which makes it impossible to handle multiple connections - CamelCaseMakesItHardToRead The new network stack is implemented as a parallel universe. Currently all commands still use the old stack. They are converted in subsequent patches. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove need for eth_halt/eth_openSascha Hauer2010-06-171-8/+13
| | | | | | | | | | | We used to eth_open/eth_halt the network devices during NetLoopInit which is called whenever the user enters a network command. Change this behaviour so that the current network device gets opened when making it the current one. With this change it's always possible to send packages and we are able to implement a new network stack in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* put only once used function inlineSascha Hauer2010-02-011-13/+6
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* replace ET_DEBUG with pr_debugSascha Hauer2010-02-011-45/+24
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>