91 unsigned int percentage;
95 percentage = ( ( 100 * stats->
local ) / stats->
total );
97 "%3d%% from %d peers", percentage, stats->
peers );
152 DBGC ( peermux,
"PEERMUX %p could not parse content info: %s\n",
160 DBGC ( peermux,
"PEERMUX %p could not presize buffer: %s\n",
185 unsigned int next_segment;
186 unsigned int next_block;
198 next_block = (
block->index + 1 );
201 if ( next_block >=
segment->blocks ) {
212 if ( next_segment >=
info->segments ) {
221 next_segment ) ) != 0 ) {
222 DBGC (
peermux,
"PEERMUX %p could not get segment %d "
223 "information: %s\n",
peermux, next_segment,
231 DBGC (
peermux,
"PEERMUX %p could not get segment %d block "
239 DBGC (
peermux,
"PEERMUX %p skipping segment %d block %d\n",
247 DBGC (
peermux,
"PEERMUX %p could not start download for "
316 unsigned int count = 0;
328 DBGC2 ( peermux,
"PEERMUX %p downloaded %d/%d from %d peers\n",
struct arbelprm_rc_send_wqe rc
#define assert(condition)
Assert a condition at run-time.
uint8_t meta
Metadata flags.
static unsigned int count
Number of entries.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define ENOMEM
Not enough space.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
void intf_close(struct interface *intf, int rc)
Close an object interface.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
void intf_nullify(struct interface *intf)
Ignore all further operations on an object interface.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
#define iob_disown(iobuf)
Disown an I/O buffer.
uint16_t segment
Code segment.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
#define list_del(list)
Delete an entry from a list.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define list_empty(list)
Test whether a list is empty.
void * zalloc(size_t size)
Allocate cleared memory.
struct mschapv2_challenge peer
Peer challenge.
uint8_t block[3][8]
DES-encrypted blocks.
int peerblk_open(struct interface *xfer, struct uri *uri, struct peerdist_info_block *block)
Open PeerDist block download.
Peer Content Caching and Retrieval (PeerDist) protocol block downloads.
void peerdisc_stat(struct interface *intf, struct peerdisc_peer *peer, struct list_head *peers)
Report peer discovery statistics.
static int peermux_block_deliver(struct peerdist_multiplexed_block *peermblk, struct io_buffer *iobuf, struct xfer_metadata *meta)
Receive data from multiplexed block download.
static struct interface_descriptor peermux_block_desc
Block download data transfer interface descriptor.
static void peermux_info_close(struct peerdist_multiplexer *peermux, int rc)
Close content information interface.
static void peermux_step(struct peerdist_multiplexer *peermux)
Initiate multiplexed block download.
static struct interface_operation peermux_xfer_operations[]
Data transfer interface operations.
static void peermux_block_stat(struct peerdist_multiplexed_block *peermblk, struct peerdisc_peer *peer, struct list_head *peers)
Record peer discovery statistics.
static struct xfer_buffer * peermux_block_buffer(struct peerdist_multiplexed_block *peermblk)
Get multiplexed block download underlying data transfer buffer.
static void peermux_free(struct refcnt *refcnt)
Free PeerDist download multiplexer.
static struct interface_descriptor peermux_xfer_desc
Data transfer interface descriptor.
int peermux_filter(struct interface *xfer, struct interface *info, struct uri *uri)
Add PeerDist content-encoding filter.
static struct interface_operation peermux_info_operations[]
Content information interface operations.
static struct interface_operation peermux_block_operations[]
Block download data transfer interface operations.
static void peermux_block_close(struct peerdist_multiplexed_block *peermblk, int rc)
Close multiplexed block download.
static void peermux_close(struct peerdist_multiplexer *peermux, int rc)
Close PeerDist download multiplexer.
static struct process_descriptor peermux_process_desc
Block download initiation process descriptor.
static struct interface_descriptor peermux_info_desc
Content information interface descriptor.
static int peermux_info_deliver(struct peerdist_multiplexer *peermux, struct io_buffer *iobuf, struct xfer_metadata *meta)
Receive content information.
static int peermux_progress(struct peerdist_multiplexer *peermux, struct job_progress *progress)
Report progress of PeerDist download.
Peer Content Caching and Retrieval (PeerDist) protocol multiplexer.
#define PEERMUX_MAX_BLOCKS
Maximum number of concurrent block downloads.
void process_del(struct process *process)
Remove process from process list.
void process_add(struct process *process)
Add process to process list.
static void process_init_stopped(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process without adding to process list.
#define PROC_DESC(object_type, process, _step)
Define a process descriptor.
static void(* free)(struct refcnt *refcnt))
#define ref_put(refcnt)
Drop reference to object.
#define ref_init(refcnt, free)
Initialise a reference counter.
#define container_of(ptr, type, field)
Get containing structure.
char * strerror(int errno)
Retrieve string representation of error number.
An object interface descriptor.
An object interface operation.
char message[32]
Message (optional)
A doubly-linked list entry (or list head)
A PeerDist discovery peer.
struct list_head list
List of peers.
A content information block.
struct peerdist_info info
Content information.
struct peerdist_info_block block
Content information block.
struct peerdist_info_segment segment
Content information segment.
A content information segment.
A PeerDist multiplexed block download.
struct peerdist_multiplexer * peermux
PeerDist download multiplexer.
struct interface xfer
Data transfer interface.
struct list_head list
List of multiplexed blocks.
A PeerDist download multiplexer.
struct peerdist_statistics stats
Statistics.
struct xfer_buffer buffer
Content information data transfer buffer.
struct list_head idle
List of idle block downloads.
struct peerdist_multiplexed_block block[PEERMUX_MAX_BLOCKS]
Block downloads.
struct interface info
Content information interface.
struct peerdist_info_cache cache
Content information cache.
struct list_head busy
List of busy block downloads.
struct refcnt refcnt
Reference count.
struct uri * uri
Original URI.
struct process process
Block download initiation process.
struct interface xfer
Data transfer interface.
unsigned int total
Number of blocks downloaded in total.
unsigned int peers
Maximum observed number of peers.
unsigned int local
Number of blocks downloaded from peers.
A Uniform Resource Identifier.
Uniform Resource Identifiers.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
static void uri_put(struct uri *uri)
Decrement URI reference count.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
#define XFER_FL_ABS_OFFSET
Offset is absolute.
struct xfer_buffer * xfer_buffer(struct interface *intf)
Get underlying data transfer buffer.
void xferbuf_free(struct xfer_buffer *xferbuf)
Free data transfer buffer.
int xferbuf_deliver(struct xfer_buffer *xferbuf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Add received data to data transfer buffer.
static void xferbuf_umalloc_init(struct xfer_buffer *xferbuf)
Initialise umalloc()-based data transfer buffer.