iPXE
ifmgmt.h File Reference

Network interface management. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int ifopen (struct net_device *netdev)
 Open network device.
int ifconf (struct net_device *netdev, struct net_device_configurator *configurator, unsigned long timeout)
 Perform network device configuration.
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 long timeout, int verbose)
 Wait for link-up, with status indication.

Detailed Description

Network interface management.

Definition in file ifmgmt.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

References netdev, and timeout().

◆ ifopen()

int ifopen ( struct net_device * netdev)
extern

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 66 of file ifmgmt.c.

66 {
67 int rc;
68
69 if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
70 printf ( "Could not open %s: %s\n",
71 netdev->name, strerror ( rc ) );
72 return rc;
73 }
74
75 return 0;
76}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static struct net_device * netdev
Definition gdbudp.c:53
int netdev_open(struct net_device *netdev)
Open network device.
Definition netdevice.c:862
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References netdev, netdev_open(), printf(), rc, and strerror().

Referenced by COMMAND(), iflinkwait(), ifopen_payload(), loopback_test(), and netboot().

◆ ifconf()

int ifconf ( struct net_device * netdev,
struct net_device_configurator * configurator,
unsigned long timeout )
extern

Perform network device configuration.

Parameters
netdevNetwork device
configuratorNetwork device configurator, or NULL to use all
timeoutTimeout period, in ticks
Return values
rcReturn status code

Definition at line 275 of file ifmgmt.c.

277 {
278 int rc;
279
280 /* Ensure device is open and link is up */
281 if ( ( rc = iflinkwait ( netdev, LINK_WAIT_TIMEOUT, 0 ) ) != 0 )
282 return rc;
283
284 /* Start configuration */
285 if ( configurator ) {
286 if ( ( rc = netdev_configure ( netdev, configurator ) ) != 0 ) {
287 printf ( "Could not configure %s via %s: %s\n",
288 netdev->name, configurator->name,
289 strerror ( rc ) );
290 return rc;
291 }
292 } else {
293 if ( ( rc = netdev_configure_all ( netdev ) ) != 0 ) {
294 printf ( "Could not configure %s: %s\n",
295 netdev->name, strerror ( rc ) );
296 return rc;
297 }
298 }
299
300 /* Wait for configuration to complete */
301 printf ( "Configuring %s%s%s(%s %s)",
302 ( configurator ? "[" : "" ),
303 ( configurator ? configurator->name : "" ),
304 ( configurator ? "] " : "" ),
305 netdev->name, netdev->ll_protocol->ntoa ( netdev->ll_addr ) );
306 return ifpoller_wait ( netdev, configurator, timeout, ifconf_progress );
307}
void timeout(int)
#define LINK_WAIT_TIMEOUT
Default time to wait for link-up.
Definition ifmgmt.c:47
static int ifconf_progress(struct ifpoller *ifpoller)
Check configuration progress.
Definition ifmgmt.c:244
static int ifpoller_wait(struct net_device *netdev, struct net_device_configurator *configurator, unsigned long timeout, int(*progress)(struct ifpoller *ifpoller))
Poll network device until completion.
Definition ifmgmt.c:179
int iflinkwait(struct net_device *netdev, unsigned long timeout, int verbose)
Wait for link-up, with status indication.
Definition ifmgmt.c:220
int netdev_configure_all(struct net_device *netdev)
Start network device configuration via all supported configurators.
Definition netdevice.c:1336
int netdev_configure(struct net_device *netdev, struct net_device_configurator *configurator)
Start network device configuration.
Definition netdevice.c:1296
const char * name
Name.
Definition netdevice.h:316

References net_device_configuration::configurator, ifconf_progress(), iflinkwait(), ifpoller_wait(), LINK_WAIT_TIMEOUT, net_device_configurator::name, netdev, netdev_configure(), netdev_configure_all(), printf(), rc, strerror(), and timeout().

Referenced by COMMAND(), ifconf_payload(), and netboot().

◆ ifclose()

void ifclose ( struct net_device * netdev)
extern

Close network device.

Parameters
netdevNetwork device

Definition at line 83 of file ifmgmt.c.

83 {
85}
void netdev_close(struct net_device *netdev)
Close network device.
Definition netdevice.c:896

References netdev, and netdev_close().

Referenced by close_other_netdevs(), COMMAND(), and ifclose_payload().

◆ ifstat()

void ifstat ( struct net_device * netdev)
extern

Print status of network device.

Parameters
netdevNetwork device

Definition at line 111 of file ifmgmt.c.

111 {
112 printf ( "%s: %s using %s on %s (%s) [%s]\n"
113 " [Link:%s%s, TX:%d TXE:%d RX:%d RXE:%d]\n",
114 netdev->name, netdev_addr ( netdev ),
115 netdev->dev->driver_name, netdev->dev->name,
116 netdev->ll_protocol->name,
117 ( netdev_is_open ( netdev ) ? "open" : "closed" ),
118 ( netdev_link_ok ( netdev ) ? "up" : "down" ),
119 ( netdev_link_blocked ( netdev ) ? " (blocked)" : "" ),
120 netdev->tx_stats.good, netdev->tx_stats.bad,
121 netdev->rx_stats.good, netdev->rx_stats.bad );
122 if ( ! netdev_link_ok ( netdev ) ) {
123 printf ( " [Link status: %s]\n",
124 strerror ( netdev->link_rc ) );
125 }
126 ifstat_errors ( &netdev->tx_stats, "TXE" );
127 ifstat_errors ( &netdev->rx_stats, "RXE" );
128}
static void ifstat_errors(struct net_device_stats *stats, const char *prefix)
Print network device error breakdown.
Definition ifmgmt.c:93
static int netdev_link_blocked(struct net_device *netdev)
Check link block state of network device.
Definition netdevice.h:651
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition netdevice.h:662
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition netdevice.h:640
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
Definition netdevice.h:542

References ifstat_errors(), netdev, netdev_addr(), netdev_is_open(), netdev_link_blocked(), netdev_link_ok(), printf(), and strerror().

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

◆ iflinkwait()

int iflinkwait ( struct net_device * netdev,
unsigned long timeout,
int verbose )
extern

Wait for link-up, with status indication.

Parameters
netdevNetwork device
timeoutTimeout period, in ticks
verboseAlways display progress message
Return values
rcReturn status code

Definition at line 220 of file ifmgmt.c.

221 {
222 int rc;
223
224 /* Ensure device is open */
225 if ( ( rc = ifopen ( netdev ) ) != 0 )
226 return rc;
227
228 /* Return immediately if link is already up, unless being verbose */
230 if ( netdev_link_ok ( netdev ) && ( ! verbose ) )
231 return 0;
232
233 /* Wait for link-up */
234 printf ( "Waiting for link-up on %s", netdev->name );
236}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
int ifopen(struct net_device *netdev)
Open network device.
Definition ifmgmt.c:66
static int iflinkwait_progress(struct ifpoller *ifpoller)
Check link-up progress.
Definition ifmgmt.c:200
void netdev_poll(struct net_device *netdev)
Poll for completed and received packets on network device.
Definition netdevice.c:613

References iflinkwait_progress(), ifopen(), ifpoller_wait(), netdev, netdev_link_ok(), netdev_poll(), NULL, printf(), rc, and timeout().

Referenced by COMMAND(), ifconf(), iflinkwait_payload(), and loopback_test().