Browse Source

Reserve space for link-layer header in pxenv_undi_transmit() when not

handed a P_UNKNOWN packet.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
5f92f0bd82
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      src/interface/pxe/pxe_undi.c

+ 10
- 2
src/interface/pxe/pxe_undi.c View File

179
 	struct net_protocol *net_protocol;
179
 	struct net_protocol *net_protocol;
180
 	char destaddr[MAX_LL_ADDR_LEN];
180
 	char destaddr[MAX_LL_ADDR_LEN];
181
 	const void *ll_dest;
181
 	const void *ll_dest;
182
+	size_t ll_hlen = pxe_netdev->ll_protocol->ll_header_len;
182
 	size_t len;
183
 	size_t len;
183
 	unsigned int i;
184
 	unsigned int i;
184
 	int rc;
185
 	int rc;
190
 	case P_IP:	net_protocol = &ipv4_protocol;	break;
191
 	case P_IP:	net_protocol = &ipv4_protocol;	break;
191
 	case P_ARP:	net_protocol = &arp_protocol;	break;
192
 	case P_ARP:	net_protocol = &arp_protocol;	break;
192
 	case P_RARP:	net_protocol = &rarp_protocol;	break;
193
 	case P_RARP:	net_protocol = &rarp_protocol;	break;
193
-	case P_UNKNOWN:	net_protocol = NULL;		break;
194
+	case P_UNKNOWN:
195
+		net_protocol = NULL;
196
+		ll_hlen = 0;
197
+		break;
194
 	default:
198
 	default:
195
 		undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_PARAMETER;
199
 		undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_PARAMETER;
196
 		return PXENV_EXIT_FAILURE;
200
 		return PXENV_EXIT_FAILURE;
197
 	}
201
 	}
202
+	DBG ( " %s", ( net_protocol ? net_protocol->name : "UNKNOWN" ) );
198
 
203
 
199
 	/* Calculate total packet length */
204
 	/* Calculate total packet length */
200
 	copy_from_real ( &tbd, undi_transmit->TBD.segment,
205
 	copy_from_real ( &tbd, undi_transmit->TBD.segment,
201
 			 undi_transmit->TBD.offset, sizeof ( tbd ) );
206
 			 undi_transmit->TBD.offset, sizeof ( tbd ) );
202
 	len = tbd.ImmedLength;
207
 	len = tbd.ImmedLength;
208
+	DBG ( " %zd", tbd.ImmedLength );
203
 	for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
209
 	for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
204
 		datablk = &tbd.DataBlock[i];
210
 		datablk = &tbd.DataBlock[i];
205
 		len += datablk->TDDataLen;
211
 		len += datablk->TDDataLen;
212
+		DBG ( "+%zd", datablk->TDDataLen );
206
 	}
213
 	}
207
 
214
 
208
 	/* Allocate and fill I/O buffer */
215
 	/* Allocate and fill I/O buffer */
209
-	iobuf = alloc_iob ( len );
216
+	iobuf = alloc_iob ( ll_hlen + len );
210
 	if ( ! iobuf ) {
217
 	if ( ! iobuf ) {
211
 		undi_transmit->Status = PXENV_STATUS_OUT_OF_RESOURCES;
218
 		undi_transmit->Status = PXENV_STATUS_OUT_OF_RESOURCES;
212
 		return PXENV_EXIT_FAILURE;
219
 		return PXENV_EXIT_FAILURE;
213
 	}
220
 	}
221
+	iob_reserve ( iobuf, ll_hlen );
214
 	copy_from_real ( iob_put ( iobuf, tbd.ImmedLength ), tbd.Xmit.segment,
222
 	copy_from_real ( iob_put ( iobuf, tbd.ImmedLength ), tbd.Xmit.segment,
215
 			 tbd.Xmit.offset, tbd.ImmedLength );
223
 			 tbd.Xmit.offset, tbd.ImmedLength );
216
 	for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
224
 	for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {

Loading…
Cancel
Save