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

Loading…
Cancel
Save