Просмотр исходного кода

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 лет назад
Родитель
Сommit
f6d20bb0f4
1 измененных файлов: 17 добавлений и 6 удалений
  1. 17
    6
      src/net/aoe.c

+ 17
- 6
src/net/aoe.c Просмотреть файл

@@ -188,6 +188,7 @@ static int aoe_rx_response ( struct aoe_session *aoe, struct aoehdr *aoehdr,
188 188
 static int aoe_rx ( struct pk_buff *pkb ) {
189 189
 	struct aoehdr *aoehdr = pkb->data;
190 190
 	unsigned int len = pkb_len ( pkb );
191
+	struct ethhdr *ethhdr = pkb_push ( pkb, sizeof ( *ethhdr ) );
191 192
 	struct aoe_session *aoe;
192 193
 	int rc = 0;
193 194
 
@@ -213,9 +214,8 @@ static int aoe_rx ( struct pk_buff *pkb ) {
213 214
 			continue;
214 215
 		if ( ntohl ( aoehdr->tag ) != aoe->tag )
215 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 219
 		rc = aoe_rx_response ( aoe, aoehdr, len );
220 220
 		break;
221 221
 	}
@@ -235,10 +235,20 @@ static int aoe_rx ( struct pk_buff *pkb ) {
235 235
  */
236 236
 static int aoe_route ( const struct pk_buff *pkb __unused,
237 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 254
 /** AoE protocol */
@@ -257,6 +267,7 @@ NET_PROTOCOL ( aoe_protocol );
257 267
  * @v aoe		AoE session
258 268
  */
259 269
 void aoe_open ( struct aoe_session *aoe ) {
270
+	memset ( aoe->target, 0xff, sizeof ( aoe->target ) );
260 271
 	list_add ( &aoe->list, &aoe_sessions );
261 272
 }
262 273
 

Загрузка…
Отмена
Сохранить