From fe1aa9c00201a7824e42b281e6fcaca821b0fd87 Mon Sep 17 00:00:00 2001 From: Daniel Hellstrom Date: Wed, 21 Dec 2011 13:21:49 +0100 Subject: LEON: added network device configuration helper function --- .../sparc/shared/net/network_interface_add.c | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 c/src/lib/libbsp/sparc/shared/net/network_interface_add.c (limited to 'c/src/lib/libbsp/sparc/shared/net/network_interface_add.c') diff --git a/c/src/lib/libbsp/sparc/shared/net/network_interface_add.c b/c/src/lib/libbsp/sparc/shared/net/network_interface_add.c new file mode 100644 index 0000000000..6e3a58a75c --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/net/network_interface_add.c @@ -0,0 +1,62 @@ +/* Network interface register help function + * + * COPYRIGHT (c) 2008. + * Cobham Gaisler AB. + * + * This function adds a network interface to the + * rtems_bsdnet_config.ifconfig linked list of interfaces. + * The interface configuration is taken from the user defined + * array interface_configs. This function is useful for PnP + * systems when an unknown number of interfaces are available. + * + * The license and distribution terms for this file may be + * found in found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include +#include + +#include + +extern struct rtems_bsdnet_config rtems_bsdnet_config; + +/* Number of interfaces taken */ +int network_interface_cnt = 0; + +int network_interface_add(struct rtems_bsdnet_ifconfig *interface) +{ + struct ethernet_config *cfg = NULL; + int i, last_entry = 1; + + /* Init interface description */ + interface->next = NULL; + + cfg = &interface_configs[network_interface_cnt]; + for(i=0; i<6; i++) { + if ( cfg->eth_adr[i] != 0 ) { + last_entry = 0; + break; + } + } + /* Do we have a valid configuration? */ + if ( last_entry == 0 ) { + cfg = &interface_configs[network_interface_cnt]; + + interface->ip_address = cfg->ip_addr; + interface->ip_netmask = cfg->ip_netmask; + interface->hardware_address = cfg->eth_adr; + + network_interface_cnt++; + } else { + interface->ip_address = NULL; + interface->ip_netmask = NULL; + interface->hardware_address = NULL; + } + + /* Insert interface first into list */ + interface->next = rtems_bsdnet_config.ifconfig; + rtems_bsdnet_config.ifconfig = interface; + + return 0; +} -- cgit v1.2.3