소스 검색

[netdevice] Add netdev_is_open() wrapper function

Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v1.20.1
Michael Brown 14 년 전
부모
커밋
88e436376c

+ 1
- 1
src/arch/i386/hci/commands/pxe_cmd.c 파일 보기

@@ -6,7 +6,7 @@
6 6
 FILE_LICENCE ( GPL2_OR_LATER );
7 7
 
8 8
 static int startpxe_payload ( struct net_device *netdev ) {
9
-	if ( netdev->state & NETDEV_OPEN )
9
+	if ( netdev_is_open ( netdev ) )
10 10
 		pxe_activate ( netdev );
11 11
 	return 0;
12 12
 }

+ 1
- 1
src/arch/i386/interface/pxe/pxe_undi.c 파일 보기

@@ -366,7 +366,7 @@ pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
366 366
 	/* If adapter is open, the change will have no effect; return
367 367
 	 * an error
368 368
 	 */
369
-	if ( pxe_netdev->state & NETDEV_OPEN ) {
369
+	if ( netdev_is_open ( pxe_netdev ) ) {
370 370
 		DBG ( " failed: netdev is open\n" );
371 371
 		undi_set_station_address->Status =
372 372
 			PXENV_STATUS_UNDI_INVALID_STATE;

+ 11
- 0
src/include/gpxe/netdevice.h 파일 보기

@@ -480,6 +480,17 @@ netdev_link_ok ( struct net_device *netdev ) {
480 480
 	return ( netdev->link_rc == 0 );
481 481
 }
482 482
 
483
+/**
484
+ * Check whether or not network device is open
485
+ *
486
+ * @v netdev		Network device
487
+ * @v is_open		Network device is open
488
+ */
489
+static inline __attribute__ (( always_inline )) int
490
+netdev_is_open ( struct net_device *netdev ) {
491
+	return ( netdev->state & NETDEV_OPEN );
492
+}
493
+
483 494
 extern void netdev_link_down ( struct net_device *netdev );
484 495
 extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
485 496
 extern void netdev_tx_complete_err ( struct net_device *netdev,

+ 2
- 2
src/interface/efi/efi_snp.c 파일 보기

@@ -328,7 +328,7 @@ efi_snp_station_address ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN reset,
328 328
 	memcpy ( snpdev->netdev->ll_addr, new, ll_protocol->ll_addr_len );
329 329
 
330 330
 	/* MAC address changes take effect only on netdev_open() */
331
-	if ( snpdev->netdev->state & NETDEV_OPEN ) {
331
+	if ( netdev_is_open ( snpdev->netdev ) ) {
332 332
 		DBGC ( snpdev, "SNPDEV %p MAC address changed while net "
333 333
 		       "devive open\n", snpdev );
334 334
 	}
@@ -713,7 +713,7 @@ static VOID EFIAPI efi_snp_wait_for_packet ( EFI_EVENT event,
713 713
 	DBGCP ( snpdev, "SNPDEV %p WAIT_FOR_PACKET\n", snpdev );
714 714
 
715 715
 	/* Do nothing unless the net device is open */
716
-	if ( ! ( snpdev->netdev->state & NETDEV_OPEN ) )
716
+	if ( ! netdev_is_open ( snpdev->netdev ) )
717 717
 		return;
718 718
 
719 719
 	/* Poll the network device */

+ 6
- 6
src/net/80211/net80211.c 파일 보기

@@ -1304,7 +1304,7 @@ struct net80211_probe_ctx * net80211_probe_start ( struct net80211_device *dev,
1304 1304
 	if ( ! ctx )
1305 1305
 		return NULL;
1306 1306
 
1307
-	assert ( dev->netdev->state & NETDEV_OPEN );
1307
+	assert ( netdev_is_open ( dev->netdev ) );
1308 1308
 
1309 1309
 	ctx->dev = dev;
1310 1310
 	ctx->old_keep_mgmt = net80211_keep_mgmt ( dev, 1 );
@@ -1908,7 +1908,7 @@ static int net80211_check_settings_update ( void )
1908 1908
 	int key_reassoc;
1909 1909
 
1910 1910
 	list_for_each_entry ( dev, &net80211_devices, list ) {
1911
-		if ( ! ( dev->netdev->state & NETDEV_OPEN ) )
1911
+		if ( ! netdev_is_open ( dev->netdev ) )
1912 1912
 			continue;
1913 1913
 
1914 1914
 		key_reassoc = 0;
@@ -2012,7 +2012,7 @@ static void net80211_set_rtscts_rate ( struct net80211_device *dev )
2012 2012
  */
2013 2013
 void net80211_set_rate_idx ( struct net80211_device *dev, int rate )
2014 2014
 {
2015
-	assert ( dev->netdev->state & NETDEV_OPEN );
2015
+	assert ( netdev_is_open ( dev->netdev ) );
2016 2016
 
2017 2017
 	if ( rate >= 0 && rate < dev->nr_rates && rate != dev->rate ) {
2018 2018
 		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 )
2035 2035
 {
2036 2036
 	int i, oldchan = dev->channel;
2037 2037
 
2038
-	assert ( dev->netdev->state & NETDEV_OPEN );
2038
+	assert ( netdev_is_open ( dev->netdev ) );
2039 2039
 
2040 2040
 	for ( i = 0; i < dev->nr_channels; i++ ) {
2041 2041
 		if ( dev->channels[i].channel_nr == channel ) {
@@ -2064,7 +2064,7 @@ int net80211_change_channel ( struct net80211_device *dev, int channel )
2064 2064
 int net80211_prepare_probe ( struct net80211_device *dev, int band,
2065 2065
 			     int active )
2066 2066
 {
2067
-	assert ( dev->netdev->state & NETDEV_OPEN );
2067
+	assert ( netdev_is_open ( dev->netdev ) );
2068 2068
 
2069 2069
 	if ( active && ( band & NET80211_BAND_BIT_5GHZ ) ) {
2070 2070
 		DBGC ( dev, "802.11 %p cannot perform active scanning on "
@@ -2124,7 +2124,7 @@ int net80211_prepare_assoc ( struct net80211_device *dev,
2124 2124
 	struct net80211_handshaker *handshaker;
2125 2125
 	int rc;
2126 2126
 
2127
-	assert ( dev->netdev->state & NETDEV_OPEN );
2127
+	assert ( netdev_is_open ( dev->netdev ) );
2128 2128
 
2129 2129
 	net80211_set_state ( dev, NET80211_ASSOCIATED, 0, 0 );
2130 2130
 	memcpy ( dev->bssid, wlan->bssid, ETH_ALEN );

+ 1
- 1
src/net/ipv4.c 파일 보기

@@ -118,7 +118,7 @@ static struct ipv4_miniroute * ipv4_route ( struct in_addr *dest ) {
118 118
 
119 119
 	/* Find first usable route in routing table */
120 120
 	list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
121
-		if ( ! ( miniroute->netdev->state & NETDEV_OPEN ) )
121
+		if ( ! netdev_is_open ( miniroute->netdev ) )
122 122
 			continue;
123 123
 		local = ( ( ( dest->s_addr ^ miniroute->address.s_addr )
124 124
 			    & miniroute->netmask.s_addr ) == 0 );

+ 3
- 3
src/net/netdevice.c 파일 보기

@@ -130,7 +130,7 @@ int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ) {
130 130
 
131 131
 	list_add_tail ( &iobuf->list, &netdev->tx_queue );
132 132
 
133
-	if ( ! ( netdev->state & NETDEV_OPEN ) ) {
133
+	if ( ! netdev_is_open ( netdev ) ) {
134 134
 		rc = -ENETUNREACH;
135 135
 		goto err;
136 136
 	}
@@ -263,7 +263,7 @@ void netdev_rx_err ( struct net_device *netdev,
263 263
  */
264 264
 void netdev_poll ( struct net_device *netdev ) {
265 265
 
266
-	if ( netdev->state & NETDEV_OPEN )
266
+	if ( netdev_is_open ( netdev ) )
267 267
 		netdev->op->poll ( netdev );
268 268
 }
269 269
 
@@ -509,7 +509,7 @@ struct net_device * last_opened_netdev ( void ) {
509 509
 	struct net_device *netdev;
510 510
 
511 511
 	list_for_each_entry ( netdev, &open_net_devices, open_list ) {
512
-		assert ( netdev->state & NETDEV_OPEN );
512
+		assert ( netdev_is_open ( netdev ) );
513 513
 		return netdev;
514 514
 	}
515 515
 

+ 1
- 1
src/usr/ifmgmt.c 파일 보기

@@ -90,7 +90,7 @@ void ifstat ( struct net_device *netdev ) {
90 90
 	printf ( "%s: %s on %s (%s)\n"
91 91
 		 "  [Link:%s, TX:%d TXE:%d RX:%d RXE:%d]\n",
92 92
 		 netdev->name, netdev_addr ( netdev ), netdev->dev->name,
93
-		 ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ),
93
+		 ( netdev_is_open ( netdev ) ? "open" : "closed" ),
94 94
 		 ( netdev_link_ok ( netdev ) ? "up" : "down" ),
95 95
 		 netdev->tx_stats.good, netdev->tx_stats.bad,
96 96
 		 netdev->rx_stats.good, netdev->rx_stats.bad );

+ 1
- 1
src/usr/iwmgmt.c 파일 보기

@@ -125,7 +125,7 @@ int iwlist ( struct net80211_device *dev ) {
125 125
 	char ssid_buf[22];
126 126
 	int rc;
127 127
 	unsigned i;
128
-	int was_opened = dev->netdev->state & NETDEV_OPEN;
128
+	int was_opened = netdev_is_open ( dev->netdev );
129 129
 	int was_channel = dev->channels[dev->channel].channel_nr;
130 130
 
131 131
 	if ( ! was_opened ) {

+ 1
- 1
src/usr/route.c 파일 보기

@@ -38,7 +38,7 @@ void route ( void ) {
38 38
 		printf ( "%s", inet_ntoa ( miniroute->netmask ) );
39 39
 		if ( miniroute->gateway.s_addr )
40 40
 			printf ( " gw %s", inet_ntoa ( miniroute->gateway ) );
41
-		if ( ! ( miniroute->netdev->state & NETDEV_OPEN ) )
41
+		if ( ! netdev_is_open ( miniroute->netdev ) )
42 42
 			printf ( " (inaccessible)" );
43 43
 		printf ( "\n" );
44 44
 	}

Loading…
취소
저장