iPXE
peerdisc.h
Go to the documentation of this file.
1#ifndef _IPXE_PEERDISC_H
2#define _IPXE_PEERDISC_H
3
4/** @file
5 *
6 * Peer Content Caching and Retrieval (PeerDist) protocol peer discovery
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/refcnt.h>
15#include <ipxe/list.h>
16#include <ipxe/tables.h>
17#include <ipxe/retry.h>
18#include <ipxe/socket.h>
19#include <ipxe/interface.h>
20#include <ipxe/pccrc.h>
21
22/** A PeerDist discovery socket */
24 /** Name */
25 const char *name;
26 /** Data transfer interface */
28 /** Socket address */
29 union {
30 struct sockaddr sa;
34};
35
36/** PeerDist discovery socket table */
37#define PEERDISC_SOCKETS __table ( struct peerdisc_socket, "peerdisc_sockets" )
38
39/** Declare a PeerDist discovery socket */
40#define __peerdisc_socket __table_entry ( PEERDISC_SOCKETS, 01 )
41
42/** A PeerDist discovery segment */
44 /** Reference count */
45 struct refcnt refcnt;
46 /** List of segments */
48 /** Segment identifier string
49 *
50 * This is MS-PCCRC's "HoHoDk", transcribed as an upper-case
51 * Base16-encoded string.
52 */
53 const char *id;
54 /** Message UUID string */
55 const char *uuid;
56 /** List of discovered peers
57 *
58 * The list of peers may be appended to during the lifetime of
59 * the discovery segment. Discovered peers will not be
60 * removed from the list until the last discovery has been
61 * closed; this allows users to safely maintain a pointer to a
62 * current position within the list.
63 */
65 /** List of active clients */
67 /** Transmission timer */
69};
70
71/** A PeerDist discovery peer */
73 /** List of peers */
75 /** Peer location */
76 char location[0];
77};
78
79/** A PeerDist discovery client */
81 /** Discovery segment */
83 /** List of clients */
85 /** Operations */
87};
88
89/** PeerDist discovery client operations */
91 /** New peers have been discovered
92 *
93 * @v peerdisc PeerDist discovery client
94 */
95 void ( * discovered ) ( struct peerdisc_client *peerdisc );
96};
97
98/**
99 * Initialise PeerDist discovery
100 *
101 * @v peerdisc PeerDist discovery client
102 * @v op Discovery operations
103 */
104static inline __attribute__ (( always_inline )) void
107
108 peerdisc->op = op;
109}
110
111extern unsigned int peerdisc_timeout_secs;
112
113extern void peerdisc_stat ( struct interface *intf, struct peerdisc_peer *peer,
114 struct list_head *peers );
115#define peerdisc_stat_TYPE( object_type ) \
116 typeof ( void ( object_type, struct peerdisc_peer *peer, \
117 struct list_head *peers ) )
118
119extern int peerdisc_open ( struct peerdisc_client *peerdisc, const void *id,
120 size_t len );
121extern void peerdisc_close ( struct peerdisc_client *peerdisc );
122
123#endif /* _IPXE_PEERDISC_H */
ring len
Length.
Definition dwmac.h:226
uint64_t address
Base address.
Definition ena.h:13
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
Object interfaces.
Linked lists.
struct mschapv2_challenge peer
Peer challenge.
Definition mschapv2.h:1
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
Peer Content Caching and Retrieval: Content Identification [MS-PCCRC].
unsigned int peerdisc_timeout_secs
Recommended discovery timeout (in seconds)
Definition peerdisc.c:75
void peerdisc_stat(struct interface *intf, struct peerdisc_peer *peer, struct list_head *peers)
Report peer discovery statistics.
Definition peerdisc.c:101
int peerdisc_open(struct peerdisc_client *peerdisc, const void *id, size_t len)
Open PeerDist discovery client.
Definition peerdisc.c:560
void peerdisc_close(struct peerdisc_client *peerdisc)
Close PeerDist discovery client.
Definition peerdisc.c:598
static void peerdisc_init(struct peerdisc_client *peerdisc, struct peerdisc_client_operations *op)
Initialise PeerDist discovery.
Definition peerdisc.h:105
Reference counting.
Retry timers.
Socket addresses.
An object interface.
Definition interface.h:125
A doubly-linked list entry (or list head)
Definition list.h:19
PeerDist discovery client operations.
Definition peerdisc.h:90
void(* discovered)(struct peerdisc_client *peerdisc)
New peers have been discovered.
Definition peerdisc.h:95
A PeerDist discovery client.
Definition peerdisc.h:80
struct list_head list
List of clients.
Definition peerdisc.h:84
struct peerdisc_segment * segment
Discovery segment.
Definition peerdisc.h:82
struct peerdisc_client_operations * op
Operations.
Definition peerdisc.h:86
A PeerDist discovery peer.
Definition peerdisc.h:72
struct list_head list
List of peers.
Definition peerdisc.h:74
char location[0]
Peer location.
Definition peerdisc.h:76
A PeerDist discovery segment.
Definition peerdisc.h:43
struct retry_timer timer
Transmission timer.
Definition peerdisc.h:68
const char * uuid
Message UUID string.
Definition peerdisc.h:55
const char * id
Segment identifier string.
Definition peerdisc.h:53
struct list_head list
List of segments.
Definition peerdisc.h:47
struct list_head peers
List of discovered peers.
Definition peerdisc.h:64
struct list_head clients
List of active clients.
Definition peerdisc.h:66
struct refcnt refcnt
Reference count.
Definition peerdisc.h:45
A PeerDist discovery socket.
Definition peerdisc.h:23
struct sockaddr_in sin
Definition peerdisc.h:31
struct sockaddr_in6 sin6
Definition peerdisc.h:32
struct sockaddr sa
Definition peerdisc.h:30
const char * name
Name.
Definition peerdisc.h:25
struct interface xfer
Data transfer interface.
Definition peerdisc.h:27
A retry timer.
Definition retry.h:22
IPv6 socket address.
Definition in.h:118
IPv4 socket address.
Definition in.h:85
Generalized socket address structure.
Definition socket.h:97
Linker tables.