source: rtems/c/src/lib/libbsp/sparc/shared/net/network_interface_add.c @ 5823bae8

4.11
Last change on this file since 5823bae8 was 5823bae8, checked in by Daniel Hellstrom <daniel@…>, on Feb 27, 2015 at 1:03:15 PM

LEON: move driver headers to bsp/ directory

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*  Network interface register help function
2 *
3 *  COPYRIGHT (c) 2008.
4 *  Cobham Gaisler AB.
5 *
6 *  This function adds a network interface to the
7 *  rtems_bsdnet_config.ifconfig linked list of interfaces.
8 *  The interface configuration is taken from the user defined
9 *  array interface_configs. This function is useful for PnP
10 *  systems when an unknown number of interfaces are available.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#include <rtems/rtems_bsdnet.h>
18#include <stdio.h>
19
20#include <bsp/network_interface_add.h>
21
22extern struct rtems_bsdnet_config rtems_bsdnet_config;
23
24/* Number of interfaces taken */
25int network_interface_cnt = 0;
26
27int network_interface_add(struct rtems_bsdnet_ifconfig *interface)
28{
29        struct ethernet_config *cfg = NULL;
30        int i, last_entry = 1;
31
32        /* Init interface description */
33        interface->next = NULL;
34
35        cfg = &interface_configs[network_interface_cnt];
36        for(i=0; i<6; i++) {
37                if ( cfg->eth_adr[i] != 0 ) {
38                        last_entry = 0;
39                        break;
40                }
41        }
42        /* Do we have a valid configuration? */
43        if ( last_entry == 0 ) {
44                cfg = &interface_configs[network_interface_cnt];
45
46                interface->ip_address = cfg->ip_addr;
47                interface->ip_netmask = cfg->ip_netmask;
48                interface->hardware_address = cfg->eth_adr;
49
50                network_interface_cnt++;
51        } else {
52                interface->ip_address = NULL;
53                interface->ip_netmask = NULL;
54                interface->hardware_address = NULL;
55        }
56
57        /* Insert interface first into list */
58        interface->next = rtems_bsdnet_config.ifconfig;
59        rtems_bsdnet_config.ifconfig = interface;
60
61        return 0;
62}
Note: See TracBrowser for help on using the repository browser.