1 #ifndef _IPXE_PEERDISC_H
2 #define _IPXE_PEERDISC_H
6 * Peer Content Caching and Retrieval (PeerDist) protocol peer discovery
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13 #include <ipxe/refcnt.h>
14 #include <ipxe/list.h>
15 #include <ipxe/tables.h>
16 #include <ipxe/retry.h>
17 #include <ipxe/socket.h>
18 #include <ipxe/interface.h>
19 #include <ipxe/pccrc.h>
21 /** A PeerDist discovery socket */
22 struct peerdisc_socket {
25 /** Data transfer interface */
26 struct interface xfer;
30 struct sockaddr_in sin;
31 struct sockaddr_in6 sin6;
35 /** PeerDist discovery socket table */
36 #define PEERDISC_SOCKETS __table ( struct peerdisc_socket, "peerdisc_sockets" )
38 /** Declare a PeerDist discovery socket */
39 #define __peerdisc_socket __table_entry ( PEERDISC_SOCKETS, 01 )
41 /** A PeerDist discovery segment */
42 struct peerdisc_segment {
43 /** Reference count */
45 /** List of segments */
46 struct list_head list;
47 /** Segment identifier string
49 * This is MS-PCCRC's "HoHoDk", transcribed as an upper-case
50 * Base16-encoded string.
53 /** Message UUID string */
55 /** List of discovered peers
57 * The list of peers may be appended to during the lifetime of
58 * the discovery segment. Discovered peers will not be
59 * removed from the list until the last discovery has been
60 * closed; this allows users to safely maintain a pointer to a
61 * current position within the list.
63 struct list_head peers;
64 /** List of active clients */
65 struct list_head clients;
66 /** Transmission timer */
67 struct retry_timer timer;
70 /** A PeerDist discovery peer */
71 struct peerdisc_peer {
73 struct list_head list;
78 /** A PeerDist discovery client */
79 struct peerdisc_client {
80 /** Discovery segment */
81 struct peerdisc_segment *segment;
82 /** List of clients */
83 struct list_head list;
85 struct peerdisc_client_operations *op;
88 /** PeerDist discovery client operations */
89 struct peerdisc_client_operations {
90 /** New peers have been discovered
92 * @v peerdisc PeerDist discovery client
94 void ( * discovered ) ( struct peerdisc_client *peerdisc );
98 * Initialise PeerDist discovery
100 * @v peerdisc PeerDist discovery client
101 * @v op Discovery operations
103 static inline __attribute__ (( always_inline )) void
104 peerdisc_init ( struct peerdisc_client *peerdisc,
105 struct peerdisc_client_operations *op ) {
110 extern unsigned int peerdisc_timeout_secs;
112 extern int peerdisc_open ( struct peerdisc_client *peerdisc, const void *id,
114 extern void peerdisc_close ( struct peerdisc_client *peerdisc );
116 #endif /* _IPXE_PEERDISC_H */