aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Brown <mcb30@etherboot.org>2010-03-23 00:46:23 +0000
committerMichael Brown <mcb30@etherboot.org>2010-03-23 00:46:35 +0000
commit88e436376cbdedee73483a9b57203c60a34316ac (patch)
tree4b23f51f32be9190621b44e497ef392510f1fd69 /src
parentb3533dd2bb3de6682ebd6c6b523c49fa6c406e92 (diff)
downloadipxe-88e436376cbdedee73483a9b57203c60a34316ac.zip
ipxe-88e436376cbdedee73483a9b57203c60a34316ac.tar.gz
ipxe-88e436376cbdedee73483a9b57203c60a34316ac.tar.bz2
[netdevice] Add netdev_is_open() wrapper function
Signed-off-by: Michael Brown <mcb30@etherboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/arch/i386/hci/commands/pxe_cmd.c2
-rw-r--r--src/arch/i386/interface/pxe/pxe_undi.c2
-rw-r--r--src/include/gpxe/netdevice.h11
-rw-r--r--src/interface/efi/efi_snp.c4
-rw-r--r--src/net/80211/net80211.c12
-rw-r--r--src/net/ipv4.c2
-rw-r--r--src/net/netdevice.c6
-rw-r--r--src/usr/ifmgmt.c2
-rw-r--r--src/usr/iwmgmt.c2
-rw-r--r--src/usr/route.c2
10 files changed, 28 insertions, 17 deletions
diff --git a/src/arch/i386/hci/commands/pxe_cmd.c b/src/arch/i386/hci/commands/pxe_cmd.c
index b5df2d1..76c49bb 100644
--- a/src/arch/i386/hci/commands/pxe_cmd.c
+++ b/src/arch/i386/hci/commands/pxe_cmd.c
@@ -6,7 +6,7 @@
FILE_LICENCE ( GPL2_OR_LATER );
static int startpxe_payload ( struct net_device *netdev ) {
- if ( netdev->state & NETDEV_OPEN )
+ if ( netdev_is_open ( netdev ) )
pxe_activate ( netdev );
return 0;
}
diff --git a/src/arch/i386/interface/pxe/pxe_undi.c b/src/arch/i386/interface/pxe/pxe_undi.c
index c9b67c0..2f66c77 100644
--- a/src/arch/i386/interface/pxe/pxe_undi.c
+++ b/src/arch/i386/interface/pxe/pxe_undi.c
@@ -366,7 +366,7 @@ pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
/* If adapter is open, the change will have no effect; return
* an error
*/
- if ( pxe_netdev->state & NETDEV_OPEN ) {
+ if ( netdev_is_open ( pxe_netdev ) ) {
DBG ( " failed: netdev is open\n" );
undi_set_station_address->Status =
PXENV_STATUS_UNDI_INVALID_STATE;
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h
index 858d8e9..4f469e6 100644
--- a/src/include/gpxe/netdevice.h
+++ b/src/include/gpxe/netdevice.h
@@ -480,6 +480,17 @@ netdev_link_ok ( struct net_device *netdev ) {
return ( netdev->link_rc == 0 );
}
+/**
+ * Check whether or not network device is open
+ *
+ * @v netdev Network device
+ * @v is_open Network device is open
+ */
+static inline __attribute__ (( always_inline )) int
+netdev_is_open ( struct net_device *netdev ) {
+ return ( netdev->state & NETDEV_OPEN );
+}
+
extern void netdev_link_down ( struct net_device *netdev );
extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
extern void netdev_tx_complete_err ( struct net_device *netdev,
diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c
index b5241e5..e57d8db 100644
--- a/src/interface/efi/efi_snp.c
+++ b/src/interface/efi/efi_snp.c
@@ -328,7 +328,7 @@ efi_snp_station_address ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset,
memcpy ( snpdev->netdev->ll_addr, new, ll_protocol->ll_addr_len );
/* MAC address changes take effect only on netdev_open() */
- if ( snpdev->netdev->state & NETDEV_OPEN ) {
+ if ( netdev_is_open ( snpdev->netdev ) ) {
DBGC ( snpdev, "SNPDEV %p MAC address changed while net "
"devive open\n", snpdev );
}
@@ -713,7 +713,7 @@ static VOID EFIAPI efi_snp_wait_for_packet ( EFI_EVENT event,
DBGCP ( snpdev, "SNPDEV %p WAIT_FOR_PACKET\n", snpdev );
/* Do nothing unless the net device is open */
- if ( ! ( snpdev->netdev->state & NETDEV_OPEN ) )
+ if ( ! netdev_is_open ( snpdev->netdev ) )
return;
/* Poll the network device */
diff --git a/src/net/80211/net80211.c b/src/net/80211/net80211.c
index 1c54597..40f7ba2 100644
--- a/src/net/80211/net80211.c
+++ b/src/net/80211/net80211.c
@@ -1304,7 +1304,7 @@ struct net80211_probe_ctx * net80211_probe_start ( struct net80211_device *dev,
if ( ! ctx )
return NULL;
- assert ( dev->netdev->state & NETDEV_OPEN );
+ assert ( netdev_is_open ( dev->netdev ) );
ctx->dev = dev;
ctx->old_keep_mgmt = net80211_keep_mgmt ( dev, 1 );
@@ -1908,7 +1908,7 @@ static int net80211_check_settings_update ( void )
int key_reassoc;
list_for_each_entry ( dev, &net80211_devices, list ) {
- if ( ! ( dev->netdev->state & NETDEV_OPEN ) )
+ if ( ! netdev_is_open ( dev->netdev ) )
continue;
key_reassoc = 0;
@@ -2012,7 +2012,7 @@ static void net80211_set_rtscts_rate ( struct net80211_device *dev )
*/
void net80211_set_rate_idx ( struct net80211_device *dev, int rate )
{
- assert ( dev->netdev->state & NETDEV_OPEN );
+ assert ( netdev_is_open ( dev->netdev ) );
if ( rate >= 0 && rate < dev->nr_rates && rate != dev->rate ) {
DBGC2 ( dev, "802.11 %p changing rate from %d->%d Mbps\n",
@@ -2035,7 +2035,7 @@ int net80211_change_channel ( struct net80211_device *dev, int channel )
{
int i, oldchan = dev->channel;
- assert ( dev->netdev->state & NETDEV_OPEN );
+ assert ( netdev_is_open ( dev->netdev ) );
for ( i = 0; i < dev->nr_channels; i++ ) {
if ( dev->channels[i].channel_nr == channel ) {
@@ -2064,7 +2064,7 @@ int net80211_change_channel ( struct net80211_device *dev, int channel )
int net80211_prepare_probe ( struct net80211_device *dev, int band,
int active )
{
- assert ( dev->netdev->state & NETDEV_OPEN );
+ assert ( netdev_is_open ( dev->netdev ) );
if ( active && ( band & NET80211_BAND_BIT_5GHZ ) ) {
DBGC ( dev, "802.11 %p cannot perform active scanning on "
@@ -2124,7 +2124,7 @@ int net80211_prepare_assoc ( struct net80211_device *dev,
struct net80211_handshaker *handshaker;
int rc;
- assert ( dev->netdev->state & NETDEV_OPEN );
+ assert ( netdev_is_open ( dev->netdev ) );
net80211_set_state ( dev, NET80211_ASSOCIATED, 0, 0 );
memcpy ( dev->bssid, wlan->bssid, ETH_ALEN );
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index 4c1393f..7a8ddd3 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -118,7 +118,7 @@ static struct ipv4_miniroute * ipv4_route ( struct in_addr *dest ) {
/* Find first usable route in routing table */
list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
- if ( ! ( miniroute->netdev->state & NETDEV_OPEN ) )
+ if ( ! netdev_is_open ( miniroute->netdev ) )
continue;
local = ( ( ( dest->s_addr ^ miniroute->address.s_addr )
& miniroute->netmask.s_addr ) == 0 );
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index ee0d0b7..2e781d7 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -130,7 +130,7 @@ int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ) {
list_add_tail ( &iobuf->list, &netdev->tx_queue );
- if ( ! ( netdev->state & NETDEV_OPEN ) ) {
+ if ( ! netdev_is_open ( netdev ) ) {
rc = -ENETUNREACH;
goto err;
}
@@ -263,7 +263,7 @@ void netdev_rx_err ( struct net_device *netdev,
*/
void netdev_poll ( struct net_device *netdev ) {
- if ( netdev->state & NETDEV_OPEN )
+ if ( netdev_is_open ( netdev ) )
netdev->op->poll ( netdev );
}
@@ -509,7 +509,7 @@ struct net_device * last_opened_netdev ( void ) {
struct net_device *netdev;
list_for_each_entry ( netdev, &open_net_devices, open_list ) {
- assert ( netdev->state & NETDEV_OPEN );
+ assert ( netdev_is_open ( netdev ) );
return netdev;
}
diff --git a/src/usr/ifmgmt.c b/src/usr/ifmgmt.c
index d4cc5a5..95505fc 100644
--- a/src/usr/ifmgmt.c
+++ b/src/usr/ifmgmt.c
@@ -90,7 +90,7 @@ void ifstat ( struct net_device *netdev ) {
printf ( "%s: %s on %s (%s)\n"
" [Link:%s, TX:%d TXE:%d RX:%d RXE:%d]\n",
netdev->name, netdev_addr ( netdev ), netdev->dev->name,
- ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ),
+ ( netdev_is_open ( netdev ) ? "open" : "closed" ),
( netdev_link_ok ( netdev ) ? "up" : "down" ),
netdev->tx_stats.good, netdev->tx_stats.bad,
netdev->rx_stats.good, netdev->rx_stats.bad );
diff --git a/src/usr/iwmgmt.c b/src/usr/iwmgmt.c
index 59ba103..dd45662 100644
--- a/src/usr/iwmgmt.c
+++ b/src/usr/iwmgmt.c
@@ -125,7 +125,7 @@ int iwlist ( struct net80211_device *dev ) {
char ssid_buf[22];
int rc;
unsigned i;
- int was_opened = dev->netdev->state & NETDEV_OPEN;
+ int was_opened = netdev_is_open ( dev->netdev );
int was_channel = dev->channels[dev->channel].channel_nr;
if ( ! was_opened ) {
diff --git a/src/usr/route.c b/src/usr/route.c
index 1875741..101d170 100644
--- a/src/usr/route.c
+++ b/src/usr/route.c
@@ -38,7 +38,7 @@ void route ( void ) {
printf ( "%s", inet_ntoa ( miniroute->netmask ) );
if ( miniroute->gateway.s_addr )
printf ( " gw %s", inet_ntoa ( miniroute->gateway ) );
- if ( ! ( miniroute->netdev->state & NETDEV_OPEN ) )
+ if ( ! netdev_is_open ( miniroute->netdev ) )
printf ( " (inaccessible)" );
printf ( "\n" );
}