Browse Source

Put in a method to get the MAC address for the AoE target. (It's not

elegant, but it works).
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
f6d20bb0f4
1 changed files with 17 additions and 6 deletions
  1. 17
    6
      src/net/aoe.c

+ 17
- 6
src/net/aoe.c View File

188
 static int aoe_rx ( struct pk_buff *pkb ) {
188
 static int aoe_rx ( struct pk_buff *pkb ) {
189
 	struct aoehdr *aoehdr = pkb->data;
189
 	struct aoehdr *aoehdr = pkb->data;
190
 	unsigned int len = pkb_len ( pkb );
190
 	unsigned int len = pkb_len ( pkb );
191
+	struct ethhdr *ethhdr = pkb_push ( pkb, sizeof ( *ethhdr ) );
191
 	struct aoe_session *aoe;
192
 	struct aoe_session *aoe;
192
 	int rc = 0;
193
 	int rc = 0;
193
 
194
 
213
 			continue;
214
 			continue;
214
 		if ( ntohl ( aoehdr->tag ) != aoe->tag )
215
 		if ( ntohl ( aoehdr->tag ) != aoe->tag )
215
 			continue;
216
 			continue;
216
-
217
-#warning "Need a way to get the MAC address for future reference"
218
-
217
+		memcpy ( aoe->target, ethhdr->h_source,
218
+			 sizeof ( aoe->target ) );
219
 		rc = aoe_rx_response ( aoe, aoehdr, len );
219
 		rc = aoe_rx_response ( aoe, aoehdr, len );
220
 		break;
220
 		break;
221
 	}
221
 	}
235
  */
235
  */
236
 static int aoe_route ( const struct pk_buff *pkb __unused,
236
 static int aoe_route ( const struct pk_buff *pkb __unused,
237
 		       struct net_header *nethdr ) {
237
 		       struct net_header *nethdr ) {
238
+	struct aoehdr *aoehdr = pkb->data;
239
+	struct aoe_session *aoe;
238
 
240
 
239
-#warning "Need a way to find out the MAC address"
240
-	nethdr->flags = PKT_FL_BROADCAST;
241
-	return 0;
241
+	list_for_each_entry ( aoe, &aoe_sessions, list ) {
242
+		if ( ( ntohs ( aoehdr->major ) == aoe->major ) &&
243
+		     ( aoehdr->minor == aoe->minor ) ) {
244
+			nethdr->flags = PKT_FL_RAW_ADDR;
245
+			memcpy ( nethdr->dest_net_addr, aoe->target,
246
+				 sizeof ( aoe->target ) );
247
+			return 0;
248
+		}
249
+	}
250
+		
251
+	return -EHOSTUNREACH;
242
 }
252
 }
243
 
253
 
244
 /** AoE protocol */
254
 /** AoE protocol */
257
  * @v aoe		AoE session
267
  * @v aoe		AoE session
258
  */
268
  */
259
 void aoe_open ( struct aoe_session *aoe ) {
269
 void aoe_open ( struct aoe_session *aoe ) {
270
+	memset ( aoe->target, 0xff, sizeof ( aoe->target ) );
260
 	list_add ( &aoe->list, &aoe_sessions );
271
 	list_add ( &aoe->list, &aoe_sessions );
261
 }
272
 }
262
 
273
 

Loading…
Cancel
Save