Data Structures | Defines | 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...


 Maximum number of concurrent block downloads.


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

Detailed Description

Peer Content Caching and Retrieval (PeerDist) protocol multiplexer.

Definition in file peermux.h.

Define Documentation


Maximum number of concurrent block downloads.

Definition at line 22 of file peermux.h.

Referenced by peermux_close(), and peermux_filter().

Function Documentation

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

Add PeerDist content-encoding filter.

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

Definition at line 411 of file peermux.c.

References peerdist_multiplexer::block, peerdist_multiplexer::buffer, peerdist_multiplexer::busy, peerdist_multiplexer::cache, peerdist_raw::data, ENOMEM, peerdist_multiplexer::idle, peerdist_info_cache::info, peerdist_multiplexer::info, INIT_LIST_HEAD, intf_init(), intf_plug_plug(), peerdist_multiplexed_block::list, list_add_tail, peerdist_multiplexed_block::peermux, peermux_free(), PEERMUX_MAX_BLOCKS, 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().

        struct peerdist_multiplexer *peermux;
        struct peerdist_multiplexed_block *peermblk;
        unsigned int i;

        /* Allocate and initialise structure */
        peermux = zalloc ( sizeof ( *peermux ) );
        if ( ! peermux )
                return -ENOMEM;
        ref_init ( &peermux->refcnt, peermux_free );
        intf_init ( &peermux->xfer, &peermux_xfer_desc, &peermux->refcnt );
        intf_init ( &peermux->info, &peermux_info_desc, &peermux->refcnt );
        peermux->uri = uri_get ( uri );
        xferbuf_umalloc_init ( &peermux->buffer,
                               &peermux->cache.info.raw.data );
        process_init_stopped ( &peermux->process, &peermux_process_desc,
                               &peermux->refcnt );
        INIT_LIST_HEAD ( &peermux->busy );
        INIT_LIST_HEAD ( &peermux->idle );
        for ( i = 0 ; i < PEERMUX_MAX_BLOCKS ; i++ ) {
                peermblk = &peermux->block[i];
                peermblk->peermux = peermux;
                list_add_tail ( &peermblk->list, &peermux->idle );
                intf_init ( &peermblk->xfer, &peermux_block_desc,
                            &peermux->refcnt );

        /* Attach to parent interfaces, mortalise self, and return */
        intf_plug_plug ( &peermux->xfer, xfer );
        intf_plug_plug ( &peermux->info, info );
        ref_put ( &peermux->refcnt );
        return 0;