iPXE
peermux.h
Go to the documentation of this file.
00001 #ifndef _IPXE_PEERMUX_H
00002 #define _IPXE_PEERMUX_H
00003 
00004 /** @file
00005  *
00006  * Peer Content Caching and Retrieval (PeerDist) protocol multiplexer
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/list.h>
00014 #include <ipxe/refcnt.h>
00015 #include <ipxe/interface.h>
00016 #include <ipxe/process.h>
00017 #include <ipxe/uri.h>
00018 #include <ipxe/xferbuf.h>
00019 #include <ipxe/pccrc.h>
00020 
00021 /** Maximum number of concurrent block downloads */
00022 #define PEERMUX_MAX_BLOCKS 32
00023 
00024 /** PeerDist download content information cache */
00025 struct peerdist_info_cache {
00026         /** Content information */
00027         struct peerdist_info info;
00028         /** Content information segment */
00029         struct peerdist_info_segment segment;
00030         /** Content information block */
00031         struct peerdist_info_block block;
00032 };
00033 
00034 /** A PeerDist multiplexed block download */
00035 struct peerdist_multiplexed_block {
00036         /** PeerDist download multiplexer */
00037         struct peerdist_multiplexer *peermux;
00038         /** List of multiplexed blocks */
00039         struct list_head list;
00040         /** Data transfer interface */
00041         struct interface xfer;
00042 };
00043 
00044 /** PeerDist statistics */
00045 struct peerdist_statistics {
00046         /** Maximum observed number of peers */
00047         unsigned int peers;
00048         /** Number of blocks downloaded in total */
00049         unsigned int total;
00050         /** Number of blocks downloaded from peers */
00051         unsigned int local;
00052 };
00053 
00054 /** A PeerDist download multiplexer */
00055 struct peerdist_multiplexer {
00056         /** Reference count */
00057         struct refcnt refcnt;
00058         /** Data transfer interface */
00059         struct interface xfer;
00060         /** Content information interface */
00061         struct interface info;
00062         /** Original URI */
00063         struct uri *uri;
00064 
00065         /** Content information data transfer buffer */
00066         struct xfer_buffer buffer;
00067         /** Content information cache */
00068         struct peerdist_info_cache cache;
00069 
00070         /** Block download initiation process */
00071         struct process process;
00072         /** List of busy block downloads */
00073         struct list_head busy;
00074         /** List of idle block downloads */
00075         struct list_head idle;
00076         /** Block downloads */
00077         struct peerdist_multiplexed_block block[PEERMUX_MAX_BLOCKS];
00078 
00079         /** Statistics */
00080         struct peerdist_statistics stats;
00081 };
00082 
00083 extern int peermux_filter ( struct interface *xfer, struct interface *info,
00084                             struct uri *uri );
00085 
00086 #endif /* _IPXE_PEERMUX_H */