ifmgmt.h File Reference

Network interface management. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
int ifopen (struct net_device *netdev)
 Open network device.
void ifclose (struct net_device *netdev)
 Close network device.
void ifstat (struct net_device *netdev)
 Print status of network device.
int iflinkwait (struct net_device *netdev, unsigned int max_wait_ms)
 Wait for link-up, with status indication.


Detailed Description

Network interface management.

Definition in file ifmgmt.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

int ifopen ( struct net_device netdev  ) 

Open network device.

Parameters:
netdev Network device
Return values:
rc Return status code

Definition at line 44 of file ifmgmt.c.

References net_device::name, netdev_open(), printf(), and strerror().

Referenced by dhcp(), ifopen_payload(), and netboot().

00044                                          {
00045         int rc;
00046 
00047         if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
00048                 printf ( "Could not open %s: %s\n",
00049                          netdev->name, strerror ( rc ) );
00050                 return rc;
00051         }
00052 
00053         return 0;
00054 }

void ifclose ( struct net_device netdev  ) 

Close network device.

Parameters:
netdev Network device

Definition at line 61 of file ifmgmt.c.

References netdev_close().

Referenced by close_all_netdevs(), and ifclose_payload().

00061                                            {
00062         netdev_close ( netdev );
00063 }

void ifstat ( struct net_device netdev  ) 

Print status of network device.

Parameters:
netdev Network device

Definition at line 89 of file ifmgmt.c.

References net_device_stats::bad, net_device::dev, net_device_stats::good, ifstat_errors(), net_device::link_rc, device::name, net_device::name, netdev_addr(), netdev_is_open(), netdev_link_ok(), printf(), net_device::rx_stats, strerror(), and net_device::tx_stats.

Referenced by ifstat_payload(), iwstat(), and netboot().

00089                                           {
00090         printf ( "%s: %s on %s (%s)\n"
00091                  "  [Link:%s, TX:%d TXE:%d RX:%d RXE:%d]\n",
00092                  netdev->name, netdev_addr ( netdev ), netdev->dev->name,
00093                  ( netdev_is_open ( netdev ) ? "open" : "closed" ),
00094                  ( netdev_link_ok ( netdev ) ? "up" : "down" ),
00095                  netdev->tx_stats.good, netdev->tx_stats.bad,
00096                  netdev->rx_stats.good, netdev->rx_stats.bad );
00097         if ( ! netdev_link_ok ( netdev ) ) {
00098                 printf ( "  [Link status: %s]\n",
00099                          strerror ( netdev->link_rc ) );
00100         }
00101         ifstat_errors ( &netdev->tx_stats, "TXE" );
00102         ifstat_errors ( &netdev->rx_stats, "RXE" );
00103 }

int iflinkwait ( struct net_device netdev,
unsigned int  max_wait_ms 
)

Wait for link-up, with status indication.

Parameters:
netdev Network device
max_wait_ms Maximum time to wait, in ms

Definition at line 111 of file ifmgmt.c.

References CTRL_C, ECANCELED, getchar(), iskey(), net_device::link_rc, mdelay(), net_device::name, netdev_link_ok(), printf(), step(), and strerror().

Referenced by dhcp().

00111                                                                        {
00112         int key;
00113         int rc;
00114 
00115         if ( netdev_link_ok ( netdev ) )
00116                 return 0;
00117 
00118         printf ( "Waiting for link-up on %s...", netdev->name );
00119 
00120         while ( 1 ) {
00121                 if ( netdev_link_ok ( netdev ) ) {
00122                         rc = 0;
00123                         break;
00124                 }
00125                 if ( max_wait_ms-- == 0 ) {
00126                         rc = netdev->link_rc;
00127                         break;
00128                 }
00129                 step();
00130                 if ( iskey() ) {
00131                         key = getchar();
00132                         if ( key == CTRL_C ) {
00133                                 rc = -ECANCELED;
00134                                 break;
00135                         }
00136                 }
00137                 mdelay ( 1 );
00138         }
00139 
00140         if ( rc == 0 ) {
00141                 printf ( " ok\n" );
00142         } else {
00143                 printf ( " failed: %s\n", strerror ( rc ) );
00144         }
00145 
00146         return rc;
00147 }


Generated on Tue Apr 6 20:01:53 2010 for gPXE by  doxygen 1.5.7.1