Adding debian version 3.70~pre8+dfsg-1.
[syslinux-debian/hramrach.git] / gpxe / src / usr / ifmgmt.c
blob5f4323de8402d61d28f985ed50545e443d1727c4
1 /*
2 * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <string.h>
20 #include <stdio.h>
21 #include <gpxe/netdevice.h>
22 #include <gpxe/device.h>
23 #include <usr/ifmgmt.h>
25 /** @file
27 * Network interface management
31 /**
32 * Open network device
34 * @v netdev Network device
35 * @ret rc Return status code
37 int ifopen ( struct net_device *netdev ) {
38 int rc;
40 if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
41 printf ( "Could not open %s: %s\n",
42 netdev->name, strerror ( rc ) );
43 return rc;
46 return 0;
49 /**
50 * Close network device
52 * @v netdev Network device
54 void ifclose ( struct net_device *netdev ) {
55 netdev_close ( netdev );
58 /**
59 * Print status of network device
61 * @v netdev Network device
63 void ifstat ( struct net_device *netdev ) {
64 printf ( "%s: %s on %s (%s) TX:%d TXE:%d RX:%d RXE:%d\n",
65 netdev->name, netdev_hwaddr ( netdev ), netdev->dev->name,
66 ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ),
67 netdev->stats.tx_ok, netdev->stats.tx_err,
68 netdev->stats.rx_ok, netdev->stats.rx_err );