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 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
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>
20 
21 /** A PeerDist discovery socket */
23  /** Name */
24  const char *name;
25  /** Data transfer interface */
26  struct interface xfer;
27  /** Socket address */
28  union {
29  struct sockaddr sa;
30  struct sockaddr_in sin;
32  } address;
33 };
34 
35 /** PeerDist discovery socket table */
36 #define PEERDISC_SOCKETS __table ( struct peerdisc_socket, "peerdisc_sockets" )
37 
38 /** Declare a PeerDist discovery socket */
39 #define __peerdisc_socket __table_entry ( PEERDISC_SOCKETS, 01 )
40 
41 /** A PeerDist discovery segment */
43  /** Reference count */
44  struct refcnt refcnt;
45  /** List of segments */
46  struct list_head list;
47  /** Segment identifier string
48  *
49  * This is MS-PCCRC's "HoHoDk", transcribed as an upper-case
50  * Base16-encoded string.
51  */
52  const char *id;
53  /** Message UUID string */
54  const char *uuid;
55  /** List of discovered peers
56  *
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.
62  */
63  struct list_head peers;
64  /** List of active clients */
66  /** Transmission timer */
68 };
69 
70 /** A PeerDist discovery peer */
71 struct peerdisc_peer {
72  /** List of peers */
73  struct list_head list;
74  /** Peer location */
75  char location[0];
76 };
77 
78 /** A PeerDist discovery client */
80  /** Discovery segment */
82  /** List of clients */
83  struct list_head list;
84  /** Operations */
86 };
87 
88 /** PeerDist discovery client operations */
90  /** New peers have been discovered
91  *
92  * @v peerdisc PeerDist discovery client
93  */
94  void ( * discovered ) ( struct peerdisc_client *peerdisc );
95 };
96 
97 /**
98  * Initialise PeerDist discovery
99  *
100  * @v peerdisc PeerDist discovery client
101  * @v op Discovery operations
102  */
103 static inline __attribute__ (( always_inline )) void
104 peerdisc_init ( struct peerdisc_client *peerdisc,
105  struct peerdisc_client_operations *op ) {
106 
107  peerdisc->op = op;
108 }
109 
110 extern unsigned int peerdisc_timeout_secs;
111 
112 extern void peerdisc_stat ( struct interface *intf, struct peerdisc_peer *peer,
113  struct list_head *peers );
114 #define peerdisc_stat_TYPE( object_type ) \
115  typeof ( void ( object_type, struct peerdisc_peer *peer, \
116  struct list_head *peers ) )
117 
118 extern int peerdisc_open ( struct peerdisc_client *peerdisc, const void *id,
119  size_t len );
120 extern void peerdisc_close ( struct peerdisc_client *peerdisc );
121 
122 #endif /* _IPXE_PEERDISC_H */
#define __attribute__(x)
Definition: compiler.h:10
struct list_head peers
List of discovered peers.
Definition: peerdisc.h:63
PeerDist discovery client operations.
Definition: peerdisc.h:89
struct sockaddr_in sin
Definition: peerdisc.h:30
void peerdisc_stat(struct interface *intf, struct peerdisc_peer *peer, struct list_head *peers)
Report peer discovery statistics.
Definition: peerdisc.c:100
const char * id
Segment identifier string.
Definition: peerdisc.h:52
A PeerDist discovery socket.
Definition: peerdisc.h:22
Retry timers.
A PeerDist discovery segment.
Definition: peerdisc.h:42
A retry timer.
Definition: retry.h:21
static void peerdisc_init(struct peerdisc_client *peerdisc, struct peerdisc_client_operations *op)
Initialise PeerDist discovery.
Definition: peerdisc.h:104
void peerdisc_close(struct peerdisc_client *peerdisc)
Close PeerDist discovery client.
Definition: peerdisc.c:597
IPv4 socket address.
Definition: in.h:82
struct list_head list
List of clients.
Definition: peerdisc.h:83
A doubly-linked list entry (or list head)
Definition: list.h:18
A reference counter.
Definition: refcnt.h:26
A timer.
Definition: timer.h:28
const char * uuid
Message UUID string.
Definition: peerdisc.h:54
struct interface xfer
Data transfer interface.
Definition: peerdisc.h:26
void(* discovered)(struct peerdisc_client *peerdisc)
New peers have been discovered.
Definition: peerdisc.h:94
struct sockaddr sa
Definition: peerdisc.h:29
A PeerDist discovery client.
Definition: peerdisc.h:79
An object interface.
Definition: interface.h:124
Object interfaces.
Linked lists.
Peer Content Caching and Retrieval: Content Identification [MS-PCCRC].
Generalized socket address structure.
Definition: socket.h:96
char location[0]
Peer location.
Definition: peerdisc.h:75
struct peerdisc_segment * segment
Discovery segment.
Definition: peerdisc.h:81
struct list_head clients
List of active clients.
Definition: peerdisc.h:65
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
struct list_head list
List of segments.
Definition: peerdisc.h:46
union peerdisc_socket::@589 address
Socket address.
uint32_t len
Length.
Definition: ena.h:14
unsigned int peerdisc_timeout_secs
Recommended discovery timeout (in seconds)
Definition: peerdisc.c:74
Reference counting.
Linker tables.
struct sockaddr_in6 sin6
Definition: peerdisc.h:31
int peerdisc_open(struct peerdisc_client *peerdisc, const void *id, size_t len)
Open PeerDist discovery client.
Definition: peerdisc.c:559
IPv6 socket address.
Definition: in.h:115
struct peerdisc_client_operations * op
Operations.
Definition: peerdisc.h:85
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12
const char * name
Name.
Definition: peerdisc.h:24
struct list_head list
List of peers.
Definition: peerdisc.h:73
Socket addresses.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A PeerDist discovery peer.
Definition: peerdisc.h:71