iPXE
Functions
downloader.h File Reference

Image downloader. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int create_downloader (struct interface *job, struct image *image)
 Instantiate a downloader. More...
 

Detailed Description

Image downloader.

Definition in file downloader.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ create_downloader()

int create_downloader ( struct interface job,
struct image image 
)

Instantiate a downloader.

Parameters
jobJob control interface
imageImage to fill with downloaded file
Return values
rcReturn status code

Instantiates a downloader object to download the content of the specified image from its URI.

Definition at line 262 of file downloader.c.

262  {
263  struct downloader *downloader;
264  int rc;
265 
266  /* Allocate and initialise structure */
267  downloader = zalloc ( sizeof ( *downloader ) );
268  if ( ! downloader )
269  return -ENOMEM;
272  &downloader->refcnt );
274  &downloader->refcnt );
277 
278  /* Instantiate child objects and attach to our interfaces */
279  if ( ( rc = xfer_open_uri ( &downloader->xfer, image->uri ) ) != 0 )
280  goto err;
281 
282  /* Attach parent interface, mortalise self, and return */
284  ref_put ( &downloader->refcnt );
285  return 0;
286 
287  err:
289  ref_put ( &downloader->refcnt );
290  return rc;
291 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct image * image
Image to contain downloaded file.
Definition: downloader.c:56
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
int xfer_open_uri(struct interface *intf, struct uri *uri)
Open URI.
Definition: open.c:67
static struct image * image_get(struct image *image)
Increment reference count on an image.
Definition: image.h:239
static struct interface_descriptor downloader_xfer_desc
Downloader data transfer interface descriptor.
Definition: downloader.c:227
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
An executable image.
Definition: image.h:23
struct interface job
Job control interface.
Definition: downloader.c:51
static void xferbuf_umalloc_init(struct xfer_buffer *xferbuf)
Initialise umalloc()-based data transfer buffer.
Definition: xferbuf.h:66
#define ENOMEM
Not enough space.
Definition: errno.h:534
static void downloader_finished(struct downloader *downloader, int rc)
Terminate download.
Definition: downloader.c:81
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
A downloader.
Definition: downloader.c:46
struct uri * uri
URI of image.
Definition: image.h:31
struct interface xfer
Data transfer interface.
Definition: downloader.c:53
struct refcnt refcnt
Reference count for this object.
Definition: downloader.c:48
struct xfer_buffer buffer
Data transfer buffer.
Definition: downloader.c:58
static struct interface_descriptor downloader_job_desc
Downloader job control interface descriptor.
Definition: downloader.c:243
static void downloader_free(struct refcnt *refcnt)
Free downloader object.
Definition: downloader.c:66
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References downloader::buffer, downloader_finished(), downloader_free(), downloader_job_desc, downloader_xfer_desc, ENOMEM, downloader::image, image_get(), intf_init(), intf_plug_plug(), downloader::job, rc, ref_init, ref_put, downloader::refcnt, image::uri, downloader::xfer, xfer_open_uri(), xferbuf_umalloc_init(), and zalloc().

Referenced by imgdownload().