|
@@ -35,6 +35,16 @@
|
35
|
35
|
* Indent Options: indent -kr -i8
|
36
|
36
|
***************************************************************************/
|
37
|
37
|
|
|
38
|
+/*
|
|
39
|
+ * IMPORTANT
|
|
40
|
+ *
|
|
41
|
+ * This file should be rewritten to avoid the use of a bitmap. Our
|
|
42
|
+ * buffer routines can cope with being handed blocks in an arbitrary
|
|
43
|
+ * order, duplicate blocks, etc. This code could be substantially
|
|
44
|
+ * simplified by taking advantage of these features.
|
|
45
|
+ *
|
|
46
|
+ */
|
|
47
|
+
|
38
|
48
|
#include "etherboot.h"
|
39
|
49
|
#include "proto.h"
|
40
|
50
|
#include "nic.h"
|
|
@@ -43,9 +53,6 @@ struct tftm_info {
|
43
|
53
|
struct sockaddr_in server;
|
44
|
54
|
struct sockaddr_in local;
|
45
|
55
|
struct sockaddr_in multicast;
|
46
|
|
- int ( * process ) ( unsigned char *data,
|
47
|
|
- unsigned int blocknum,
|
48
|
|
- unsigned int len, int eof );
|
49
|
56
|
int sent_nack;
|
50
|
57
|
const char *name; /* Filename */
|
51
|
58
|
};
|
|
@@ -56,6 +63,7 @@ struct tftm_state {
|
56
|
63
|
unsigned long total_packets;
|
57
|
64
|
char ismaster;
|
58
|
65
|
unsigned long received_packets;
|
|
66
|
+ struct buffer *buffer;
|
59
|
67
|
unsigned char *image;
|
60
|
68
|
unsigned char *bitmap;
|
61
|
69
|
char recvd_oack;
|
|
@@ -221,17 +229,11 @@ static int proto_tftm(struct tftm_info *info)
|
221
|
229
|
bitmap_len =
|
222
|
230
|
(state.total_packets + 7) / 8;
|
223
|
231
|
if (!state.image) {
|
224
|
|
- state.bitmap =
|
225
|
|
- allot(bitmap_len);
|
226
|
|
- state.image =
|
227
|
|
- allot(filesize);
|
228
|
|
-
|
229
|
|
- if ((unsigned long) state.
|
230
|
|
- image < 1024 * 1024) {
|
231
|
|
- printf
|
232
|
|
- ("ALERT: tftp filesize to large for available memory\n");
|
233
|
|
- return 0;
|
234
|
|
- }
|
|
232
|
+ state.image = phys_to_virt ( state.buffer->start );
|
|
233
|
+ state.bitmap = state.image + filesize;
|
|
234
|
+ /* We don't yet use the buffer routines; fake it */
|
|
235
|
+ state.buffer->fill = filesize;
|
|
236
|
+
|
235
|
237
|
memset(state.bitmap, 0,
|
236
|
238
|
bitmap_len);
|
237
|
239
|
}
|
|
@@ -360,7 +362,6 @@ static int proto_tftm(struct tftm_info *info)
|
360
|
362
|
TFTP_MIN_PACKET, &tp); /* ack */
|
361
|
363
|
}
|
362
|
364
|
/* We are done get out */
|
363
|
|
- forget(state.bitmap);
|
364
|
365
|
break;
|
365
|
366
|
}
|
366
|
367
|
|
|
@@ -376,15 +377,11 @@ static int proto_tftm(struct tftm_info *info)
|
376
|
377
|
}
|
377
|
378
|
/* Leave the multicast group */
|
378
|
379
|
leave_group(IGMP_SERVER);
|
379
|
|
- return info->process(state.image, 1, filesize, 1);
|
|
380
|
+ return 1;
|
380
|
381
|
}
|
381
|
382
|
|
382
|
|
-static int url_tftm ( char *url __unused,
|
383
|
|
- struct sockaddr_in *server,
|
384
|
|
- char *file,
|
385
|
|
- int ( * process ) ( unsigned char *data,
|
386
|
|
- unsigned int blocknum,
|
387
|
|
- unsigned int len, int eof ) ) {
|
|
383
|
+static int url_tftm ( char *url __unused, struct sockaddr_in *server,
|
|
384
|
+ char *file, struct buffer *buffer ) {
|
388
|
385
|
|
389
|
386
|
int ret;
|
390
|
387
|
struct tftm_info info;
|
|
@@ -394,7 +391,6 @@ static int url_tftm ( char *url __unused,
|
394
|
391
|
info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
|
395
|
392
|
info.local.sin_port = TFTM_PORT; /* Does not matter. */
|
396
|
393
|
info.multicast = info.local;
|
397
|
|
- info.process = process;
|
398
|
394
|
state.ismaster = 0;
|
399
|
395
|
info.name = file;
|
400
|
396
|
|
|
@@ -402,6 +398,7 @@ static int url_tftm ( char *url __unused,
|
402
|
398
|
state.total_bytes = 0;
|
403
|
399
|
state.total_packets = 0;
|
404
|
400
|
state.received_packets = 0;
|
|
401
|
+ state.buffer = buffer;
|
405
|
402
|
state.image = 0;
|
406
|
403
|
state.bitmap = 0;
|
407
|
404
|
state.recvd_oack = 0;
|