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 FILE_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 */
27  struct interface xfer;
28  /** Socket address */
29  union {
30  struct sockaddr sa;
31  struct sockaddr_in sin;
33  } address;
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 */
47  struct list_head list;
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  */
64  struct list_head peers;
65  /** List of active clients */
67  /** Transmission timer */
69 };
70 
71 /** A PeerDist discovery peer */
72 struct peerdisc_peer {
73  /** List of peers */
74  struct list_head list;
75  /** Peer location */
76  char location[0];
77 };
78 
79 /** A PeerDist discovery client */
81  /** Discovery segment */
83  /** List of clients */
84  struct list_head list;
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  */
104 static inline __attribute__ (( always_inline )) void
105 peerdisc_init ( struct peerdisc_client *peerdisc,
106  struct peerdisc_client_operations *op ) {
107 
108  peerdisc->op = op;
109 }
110 
111 extern unsigned int peerdisc_timeout_secs;
112 
113 extern 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 
119 extern int peerdisc_open ( struct peerdisc_client *peerdisc, const void *id,
120  size_t len );
121 extern void peerdisc_close ( struct peerdisc_client *peerdisc );
122 
123 #endif /* _IPXE_PEERDISC_H */
#define __attribute__(x)
Definition: compiler.h:10
struct list_head peers
List of discovered peers.
Definition: peerdisc.h:64
PeerDist discovery client operations.
Definition: peerdisc.h:90
struct sockaddr_in sin
Definition: peerdisc.h:31
void peerdisc_stat(struct interface *intf, struct peerdisc_peer *peer, struct list_head *peers)
Report peer discovery statistics.
Definition: peerdisc.c:101
const char * id
Segment identifier string.
Definition: peerdisc.h:53
A PeerDist discovery socket.
Definition: peerdisc.h:23
Retry timers.
A PeerDist discovery segment.
Definition: peerdisc.h:43
A retry timer.
Definition: retry.h:22
static void peerdisc_init(struct peerdisc_client *peerdisc, struct peerdisc_client_operations *op)
Initialise PeerDist discovery.
Definition: peerdisc.h:105
void peerdisc_close(struct peerdisc_client *peerdisc)
Close PeerDist discovery client.
Definition: peerdisc.c:598
IPv4 socket address.
Definition: in.h:85
struct list_head list
List of clients.
Definition: peerdisc.h:84
A doubly-linked list entry (or list head)
Definition: list.h:19
A reference counter.
Definition: refcnt.h:27
A timer.
Definition: timer.h:29
const char * uuid
Message UUID string.
Definition: peerdisc.h:55
struct interface xfer
Data transfer interface.
Definition: peerdisc.h:27
void(* discovered)(struct peerdisc_client *peerdisc)
New peers have been discovered.
Definition: peerdisc.h:95
struct sockaddr sa
Definition: peerdisc.h:30
A PeerDist discovery client.
Definition: peerdisc.h:80
An object interface.
Definition: interface.h:125
Object interfaces.
ring len
Length.
Definition: dwmac.h:231
Linked lists.
Peer Content Caching and Retrieval: Content Identification [MS-PCCRC].
Generalized socket address structure.
Definition: socket.h:97
FILE_SECBOOT(PERMITTED)
char location[0]
Peer location.
Definition: peerdisc.h:76
struct peerdisc_segment * segment
Discovery segment.
Definition: peerdisc.h:82
struct list_head clients
List of active clients.
Definition: peerdisc.h:66
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
struct list_head list
List of segments.
Definition: peerdisc.h:47
unsigned int peerdisc_timeout_secs
Recommended discovery timeout (in seconds)
Definition: peerdisc.c:75
Reference counting.
Linker tables.
struct sockaddr_in6 sin6
Definition: peerdisc.h:32
int peerdisc_open(struct peerdisc_client *peerdisc, const void *id, size_t len)
Open PeerDist discovery client.
Definition: peerdisc.c:560
IPv6 socket address.
Definition: in.h:118
struct peerdisc_client_operations * op
Operations.
Definition: peerdisc.h:86
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12
const char * name
Name.
Definition: peerdisc.h:25
struct list_head list
List of peers.
Definition: peerdisc.h:74
Socket addresses.
union peerdisc_socket::@655 address
Socket address.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A PeerDist discovery peer.
Definition: peerdisc.h:72