Browse Source

[fc] Include port IDs in metadata for received Fibre Channel frames

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
1775a6f25e
3 changed files with 28 additions and 9 deletions
  1. 2
    0
      src/include/ipxe/fc.h
  2. 24
    0
      src/net/fc.c
  3. 2
    9
      src/net/fcels.c

+ 2
- 0
src/include/ipxe/fc.h View File

@@ -71,6 +71,8 @@ extern const char * fc_id_ntoa ( const struct fc_port_id *id );
71 71
 extern int fc_id_aton ( const char *id_text, struct fc_port_id *id );
72 72
 extern const char * fc_ntoa ( const struct fc_name *wwn );
73 73
 extern int fc_aton ( const char *wwn_text, struct fc_name *wwn );
74
+extern struct sockaddr * fc_fill_sockaddr ( struct sockaddr_fc *sa_fc,
75
+					    struct fc_port_id *id );
74 76
 
75 77
 /******************************************************************************
76 78
  *

+ 24
- 0
src/net/fc.c View File

@@ -146,6 +146,26 @@ int fc_aton ( const char *wwn_text, struct fc_name *wwn ) {
146 146
 	}
147 147
 }
148 148
 
149
+/**
150
+ * Fill Fibre Channel socket address
151
+ *
152
+ * @v sa_fc		Fibre Channel socket address to fill in
153
+ * @v id		Fibre Channel port ID
154
+ * @ret sa		Socket address
155
+ */
156
+struct sockaddr * fc_fill_sockaddr ( struct sockaddr_fc *sa_fc,
157
+				     struct fc_port_id *id ) {
158
+	union {
159
+		struct sockaddr sa;
160
+		struct sockaddr_fc fc;
161
+	} *u = container_of ( sa_fc, typeof ( *u ), fc );
162
+
163
+	memset ( sa_fc, 0, sizeof ( *sa_fc ) );
164
+	sa_fc->sfc_family = AF_FC;
165
+	memcpy ( &sa_fc->sfc_port_id, id, sizeof ( sa_fc->sfc_port_id ) );
166
+	return &u->sa;
167
+}
168
+
149 169
 /******************************************************************************
150 170
  *
151 171
  * Fibre Channel link state
@@ -549,6 +569,8 @@ static int fc_xchg_rx ( struct fc_exchange *xchg, struct io_buffer *iobuf,
549 569
 	struct fc_port *port = xchg->port;
550 570
 	struct fc_frame_header *fchdr = iobuf->data;
551 571
 	struct xfer_metadata fc_meta;
572
+	struct sockaddr_fc src;
573
+	struct sockaddr_fc dest;
552 574
 	int rc;
553 575
 
554 576
 	/* Record peer exchange ID */
@@ -605,6 +627,8 @@ static int fc_xchg_rx ( struct fc_exchange *xchg, struct io_buffer *iobuf,
605 627
 		fc_meta.flags |= XFER_FL_ABS_OFFSET;
606 628
 		fc_meta.offset = ntohl ( fchdr->parameter );
607 629
 	}
630
+	fc_meta.src = fc_fill_sockaddr ( &src, &fchdr->s_id );
631
+	fc_meta.dest = fc_fill_sockaddr ( &dest, &fchdr->d_id );
608 632
 
609 633
 	/* Reset timeout */
610 634
 	start_timer_fixed ( &xchg->timer, FC_TIMEOUT );

+ 2
- 9
src/net/fcels.c View File

@@ -119,25 +119,18 @@ static struct fc_els_handler * fc_els_detect ( struct fc_els *els,
119 119
  * @ret rc		Return status code
120 120
  */
121 121
 int fc_els_tx ( struct fc_els *els, const void *data, size_t len ) {
122
-	union {
123
-		struct sockaddr sa;
124
-		struct sockaddr_fc fc;
125
-	} dest;
126 122
 	struct xfer_metadata meta;
123
+	struct sockaddr_fc dest;
127 124
 	int rc;
128 125
 
129 126
 	DBGC2 ( els, FCELS_FMT " transmitting:\n", FCELS_ARGS ( els ) );
130 127
 	DBGC2_HDA ( els, 0, data, len );
131 128
 
132 129
 	/* Construct metadata */
133
-	memset ( &dest, 0, sizeof ( dest ) );
134
-	dest.fc.sfc_family = AF_FC;
135
-	memcpy ( &dest.fc.sfc_port_id, &els->peer_port_id,
136
-		 sizeof ( dest.fc.sfc_port_id ) );
137 130
 	memset ( &meta, 0, sizeof ( meta ) );
138 131
 	meta.flags = ( fc_els_is_request ( els ) ?
139 132
 		       XFER_FL_OVER : ( XFER_FL_RESPONSE | XFER_FL_OUT ) );
140
-	meta.dest = &dest.sa;
133
+	meta.dest = fc_fill_sockaddr ( &dest, &els->peer_port_id );
141 134
 
142 135
 	/* Transmit frame */
143 136
 	if ( ( rc = xfer_deliver_raw_meta ( &els->xchg, data, len,

Loading…
Cancel
Save