summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/src/include/ipxe/peermux.h
blob: 44cbdb9d647632536c8d610eba4e5acac2347318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef _IPXE_PEERMUX_H
#define _IPXE_PEERMUX_H

/** @file
 *
 * Peer Content Caching and Retrieval (PeerDist) protocol multiplexer
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#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>

/** Maximum number of concurrent block downloads */
#define PEERMUX_MAX_BLOCKS 32

/** PeerDist download content information cache */
struct peerdist_info_cache {
	/** Content information */
	struct peerdist_info info;
	/** Content information segment */
	struct peerdist_info_segment segment;
	/** Content information block */
	struct peerdist_info_block block;
};

/** A PeerDist multiplexed block download */
struct peerdist_multiplexed_block {
	/** PeerDist download multiplexer */
	struct peerdist_multiplexer *peermux;
	/** List of multiplexed blocks */
	struct list_head list;
	/** Data transfer interface */
	struct interface xfer;
};

/** A PeerDist download multiplexer */
struct peerdist_multiplexer {
	/** Reference count */
	struct refcnt refcnt;
	/** Data transfer interface */
	struct interface xfer;
	/** Content information interface */
	struct interface info;
	/** Original URI */
	struct uri *uri;

	/** Content information data transfer buffer */
	struct xfer_buffer buffer;
	/** Content information cache */
	struct peerdist_info_cache cache;

	/** Block download initiation process */
	struct process process;
	/** List of busy block downloads */
	struct list_head busy;
	/** List of idle block downloads */
	struct list_head idle;
	/** Block downloads */
	struct peerdist_multiplexed_block block[PEERMUX_MAX_BLOCKS];
};

extern int peermux_filter ( struct interface *xfer, struct interface *info,
			    struct uri *uri );

#endif /* _IPXE_PEERMUX_H */