iPXE
Data Structures | Macros | Functions
peermux.h File Reference

Peer Content Caching and Retrieval (PeerDist) protocol multiplexer. More...

#include <stdint.h>
#include <ipxe/list.h>
#include <ipxe/refcnt.h>
#include <ipxe/interface.h>
#include <ipxe/process.h>
#include <ipxe/uri.h>
#include <ipxe/xferbuf.h>
#include <ipxe/pccrc.h>

Go to the source code of this file.

Data Structures

struct  peerdist_info_cache
 PeerDist download content information cache. More...
 
struct  peerdist_multiplexed_block
 A PeerDist multiplexed block download. More...
 
struct  peerdist_statistics
 PeerDist statistics. More...
 
struct  peerdist_multiplexer
 A PeerDist download multiplexer. More...
 

Macros

#define PEERMUX_MAX_BLOCKS   32
 Maximum number of concurrent block downloads. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int peermux_filter (struct interface *xfer, struct interface *info, struct uri *uri)
 Add PeerDist content-encoding filter. More...
 

Detailed Description

Peer Content Caching and Retrieval (PeerDist) protocol multiplexer.

Definition in file peermux.h.

Macro Definition Documentation

◆ PEERMUX_MAX_BLOCKS

#define PEERMUX_MAX_BLOCKS   32

Maximum number of concurrent block downloads.

Definition at line 22 of file peermux.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ peermux_filter()

int peermux_filter ( struct interface xfer,
struct interface info,
struct uri uri 
)

Add PeerDist content-encoding filter.

Parameters
xferData transfer interface
infoContent information interface
uriOriginal URI
Return values
rcReturn status code

Definition at line 411 of file peermux.c.

412  {
413  struct peerdist_multiplexer *peermux;
414  struct peerdist_multiplexed_block *peermblk;
415  unsigned int i;
416 
417  /* Allocate and initialise structure */
418  peermux = zalloc ( sizeof ( *peermux ) );
419  if ( ! peermux )
420  return -ENOMEM;
424  peermux->uri = uri_get ( uri );
425  xferbuf_umalloc_init ( &peermux->buffer,
426  &peermux->cache.info.raw.data );
428  &peermux->refcnt );
431  for ( i = 0 ; i < PEERMUX_MAX_BLOCKS ; i++ ) {
432  peermblk = &peermux->block[i];
433  peermblk->peermux = peermux;
434  list_add_tail ( &peermblk->list, &peermux->idle );
435  intf_init ( &peermblk->xfer, &peermux_block_desc,
436  &peermux->refcnt );
437  }
438 
439  /* Attach to parent interfaces, mortalise self, and return */
442  ref_put ( &peermux->refcnt );
443  return 0;
444 }
u32 info
Definition: ar9003_mac.h:67
userptr_t data
Data buffer.
Definition: pccrc.h:303
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition: uri.h:177
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:102
A PeerDist multiplexed block download.
Definition: peermux.h:35
struct peerdist_info_cache cache
Content information cache.
Definition: peermux.h:68
struct peerdist_multiplexer * peermux
PeerDist download multiplexer.
Definition: peermux.h:37
static struct interface_descriptor peermux_info_desc
Content information interface descriptor.
Definition: peermux.c:378
A PeerDist download multiplexer.
Definition: peermux.h:55
#define ENOMEM
Not enough space.
Definition: errno.h:534
static void peermux_free(struct refcnt *refcnt)
Free PeerDist download multiplexer.
Definition: peermux.c:46
struct process process
Block download initiation process.
Definition: peermux.h:71
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
static struct interface_descriptor peermux_block_desc
Block download data transfer interface descriptor.
Definition: peermux.c:395
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
struct list_head list
List of multiplexed blocks.
Definition: peermux.h:39
struct peerdist_multiplexed_block block[PEERMUX_MAX_BLOCKS]
Block downloads.
Definition: peermux.h:77
static void process_init_stopped(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process without adding to process list.
Definition: process.h:145
struct refcnt refcnt
Reference count.
Definition: peermux.h:57
struct interface xfer
Data transfer interface.
Definition: peermux.h:41
struct list_head idle
List of idle block downloads.
Definition: peermux.h:75
static struct process_descriptor peermux_process_desc
Block download initiation process descriptor.
Definition: peermux.c:400
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct interface xfer
Data transfer interface.
Definition: peermux.h:59
static struct interface_descriptor peermux_xfer_desc
Data transfer interface descriptor.
Definition: peermux.c:365
struct list_head busy
List of busy block downloads.
Definition: peermux.h:73
A Uniform Resource Identifier.
Definition: uri.h:50
struct xfer_buffer buffer
Content information data transfer buffer.
Definition: peermux.h:66
#define PEERMUX_MAX_BLOCKS
Maximum number of concurrent block downloads.
Definition: peermux.h:22
struct peerdist_raw raw
Raw content information.
Definition: pccrc.h:319
struct interface info
Content information interface.
Definition: peermux.h:61
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:173
struct uri * uri
Original URI.
Definition: peermux.h:63
struct peerdist_info info
Content information.
Definition: peermux.h:27
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References peerdist_multiplexer::block, peerdist_multiplexer::buffer, peerdist_multiplexer::busy, peerdist_multiplexer::cache, peerdist_raw::data, ENOMEM, peerdist_multiplexer::idle, peerdist_multiplexer::info, info, peerdist_info_cache::info, INIT_LIST_HEAD, intf_init(), intf_plug_plug(), peerdist_multiplexed_block::list, list_add_tail, peerdist_multiplexed_block::peermux, peermux_block_desc, peermux_free(), peermux_info_desc, PEERMUX_MAX_BLOCKS, peermux_process_desc, peermux_xfer_desc, peerdist_multiplexer::process, process_init_stopped(), peerdist_info::raw, ref_init, ref_put, peerdist_multiplexer::refcnt, peerdist_multiplexer::uri, uri_get(), peerdist_multiplexed_block::xfer, peerdist_multiplexer::xfer, and zalloc().

Referenced by http_peerdist_init().