aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/core/downloader.c
diff options
context:
space:
mode:
Diffstat (limited to 'gpxe/src/core/downloader.c')
-rw-r--r--gpxe/src/core/downloader.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/gpxe/src/core/downloader.c b/gpxe/src/core/downloader.c
index 0a443db2..86c144dc 100644
--- a/gpxe/src/core/downloader.c
+++ b/gpxe/src/core/downloader.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
@@ -124,18 +126,37 @@ static int downloader_ensure_size ( struct downloader *downloader,
* @v job Downloader job control interface
*/
static void downloader_job_kill ( struct job_interface *job ) {
- struct downloader *downloader =
+ struct downloader *downloader =
container_of ( job, struct downloader, job );
/* Terminate download */
downloader_finished ( downloader, -ECANCELED );
}
+/**
+ * Report progress of download job
+ *
+ * @v job Downloader job control interface
+ * @v progress Progress report to fill in
+ */
+static void downloader_job_progress ( struct job_interface *job,
+ struct job_progress *progress ) {
+ struct downloader *downloader =
+ container_of ( job, struct downloader, job );
+
+ /* This is not entirely accurate, since downloaded data may
+ * arrive out of order (e.g. with multicast protocols), but
+ * it's a reasonable first approximation.
+ */
+ progress->completed = downloader->pos;
+ progress->total = downloader->image->len;
+}
+
/** Downloader job control interface operations */
static struct job_interface_operations downloader_job_operations = {
.done = ignore_job_done,
.kill = downloader_job_kill,
- .progress = ignore_job_progress,
+ .progress = downloader_job_progress,
};
/****************************************************************************
@@ -205,7 +226,7 @@ static void downloader_xfer_close ( struct xfer_interface *xfer, int rc ) {
/** Downloader data transfer interface operations */
static struct xfer_interface_operations downloader_xfer_operations = {
.close = downloader_xfer_close,
- .vredirect = xfer_vopen,
+ .vredirect = xfer_vreopen,
.window = unlimited_xfer_window,
.alloc_iob = default_xfer_alloc_iob,
.deliver_iob = downloader_xfer_deliver_iob,