iPXE
pccrd.h File Reference

Peer Content Caching and Retrieval: Discovery Protocol [MS-PCCRD]. More...

Go to the source code of this file.

Data Structures

struct  peerdist_discovery_block_count
 A PeerDist discovery reply block count. More...
struct  peerdist_discovery_reply
 A PeerDist discovery reply. More...

Macros

#define PEERDIST_DISCOVERY_PORT   3702
 PeerDist discovery port.
#define PEERDIST_DISCOVERY_IPV4    ( ( 239 << 24 ) | ( 255 << 16 ) | ( 255 << 8 ) | ( 250 << 0 ) )
 PeerDist discovery IPv4 address (239.255.255.250)
#define PEERDIST_DISCOVERY_IPV6    { 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc }
 PeerDist discovery IPv6 address (ff02::c)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
struct peerdist_discovery_block_count __attribute__ ((packed))
char * peerdist_discovery_request (const char *uuid, const char *id)
 Construct discovery request.
int peerdist_discovery_reply (char *data, size_t len, struct peerdist_discovery_reply *reply)
 Parse discovery reply.

Variables

char hex [8]
 Count (as an eight-digit hex value)
struct peerdist_discovery_reply __attribute__

Detailed Description

Peer Content Caching and Retrieval: Discovery Protocol [MS-PCCRD].

Definition in file pccrd.h.

Macro Definition Documentation

◆ PEERDIST_DISCOVERY_PORT

#define PEERDIST_DISCOVERY_PORT   3702

PeerDist discovery port.

Definition at line 14 of file pccrd.h.

◆ PEERDIST_DISCOVERY_IPV4

#define PEERDIST_DISCOVERY_IPV4    ( ( 239 << 24 ) | ( 255 << 16 ) | ( 255 << 8 ) | ( 250 << 0 ) )

PeerDist discovery IPv4 address (239.255.255.250)

Definition at line 17 of file pccrd.h.

17#define PEERDIST_DISCOVERY_IPV4 \
18 ( ( 239 << 24 ) | ( 255 << 16 ) | ( 255 << 8 ) | ( 250 << 0 ) )

◆ PEERDIST_DISCOVERY_IPV6

#define PEERDIST_DISCOVERY_IPV6    { 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc }

PeerDist discovery IPv6 address (ff02::c)

Definition at line 21 of file pccrd.h.

21#define PEERDIST_DISCOVERY_IPV6 \
22 { 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc }

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ __attribute__()

struct peerdist_discovery_block_count __attribute__ ( (packed) )

◆ peerdist_discovery_request()

char * peerdist_discovery_request ( const char * uuid,
const char * id )
extern

Construct discovery request.

Parameters
uuidMessage UUID string
idSegment identifier string
Return values
requestDiscovery request, or NULL on failure

The request is dynamically allocated; the caller must eventually free() the request.

Definition at line 107 of file pccrd.c.

107 {
108 char *request;
109 int len;
110
111 /* Construct request */
113 if ( len < 0 )
114 return NULL;
115
116 return request;
117}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
int asprintf(char **strp, const char *fmt,...)
Write a formatted string to newly allocated memory.
Definition asprintf.c:42
ring len
Length.
Definition dwmac.h:226
u8 request[0]
List of IEs requested.
Definition ieee80211.h:2
#define PEERDIST_DISCOVERY_REQUEST
Discovery request format.
Definition pccrd.c:65
A universally unique ID.
Definition uuid.h:16

References asprintf(), len, NULL, PEERDIST_DISCOVERY_REQUEST, and request.

Referenced by peerdisc_socket_tx().

◆ peerdist_discovery_reply()

int peerdist_discovery_reply ( char * data,
size_t len,
struct peerdist_discovery_reply * reply )
extern

Parse discovery reply.

Parameters
dataReply data (not NUL-terminated, will be modified)
lenLength of reply data
replyDiscovery reply to fill in
Return values
rcReturn status code

The discovery reply includes pointers to strings within the modified reply data.

Definition at line 217 of file pccrd.c.

218 {
219 static const struct peerdist_discovery_block_count zcount = {
220 .hex = "00000000",
221 };
223 unsigned int max;
224 unsigned int i;
225 char *scopes;
226 char *xaddrs;
227 char *blockcount;
228 char *in;
229 char *out;
230 size_t skip;
231
232 /* Find <wsd:Scopes> tag */
233 scopes = peerdist_discovery_reply_values ( data, len, "wsd:Scopes" );
234 if ( ! scopes ) {
235 DBGC ( reply, "PCCRD %p missing <wsd:Scopes> tag\n", reply );
236 return -ENOENT;
237 }
238
239 /* Find <wsd:XAddrs> tag */
240 xaddrs = peerdist_discovery_reply_values ( data, len, "wsd:XAddrs" );
241 if ( ! xaddrs ) {
242 DBGC ( reply, "PCCRD %p missing <wsd:XAddrs> tag\n", reply );
243 return -ENOENT;
244 }
245
246 /* Find <PeerDist:BlockCount> tag */
248 "PeerDist:BlockCount" );
249 if ( ! blockcount ) {
250 DBGC ( reply, "PCCRD %p missing <PeerDist:BlockCount> tag\n",
251 reply );
252 return -ENOENT;
253 }
254
255 /* Determine maximum number of segments (according to number
256 * of entries in the block count list).
257 */
258 max = ( strlen ( blockcount ) / sizeof ( *count ) );
259 count = container_of ( blockcount,
261
262 /* Eliminate any segments with a zero block count */
263 for ( i = 0, in = scopes, out = scopes ; *in ; i++, in += skip ) {
264
265 /* Fail if we have overrun the maximum number of segments */
266 if ( i >= max ) {
267 DBGC ( reply, "PCCRD %p too many segment IDs\n",
268 reply );
269 return -EPROTO;
270 }
271
272 /* Delete segment if block count is zero */
273 skip = ( strlen ( in ) + 1 /* NUL */ );
274 if ( memcmp ( count[i].hex, zcount.hex,
275 sizeof ( zcount.hex ) ) == 0 )
276 continue;
277 strcpy ( out, in );
278 out += skip;
279 }
280 out[0] = '\0'; /* Ensure list is terminated with a zero-length string */
281
282 /* Fill in discovery reply */
283 reply->ids = scopes;
284 reply->locations = xaddrs;
285
286 return 0;
287}
__be32 in[4]
Definition CIB_PRM.h:7
__be32 out[4]
Definition CIB_PRM.h:8
#define max(x, y)
Definition ath.h:41
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define DBGC(...)
Definition compiler.h:505
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define ENOENT
No such file or directory.
Definition errno.h:515
#define EPROTO
Protocol error.
Definition errno.h:625
static char * peerdist_discovery_reply_values(char *data, size_t len, const char *name)
Locate discovery reply values.
Definition pccrd.c:158
char hex[8]
Count (as an eight-digit hex value)
Definition pccrd.h:1
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
char * strcpy(char *dest, const char *src)
Copy string.
Definition string.c:347
size_t strlen(const char *src)
Get length of string.
Definition string.c:244
A PeerDist discovery reply block count.
Definition pccrd.h:25
char hex[8]
Count (as an eight-digit hex value)
Definition pccrd.h:27
char * ids
List of segment ID strings.
Definition pccrd.h:36
char * locations
List of peer locations.
Definition pccrd.h:41

References container_of, count, data, DBGC, ENOENT, EPROTO, hex, peerdist_discovery_block_count::hex, peerdist_discovery_reply::ids, in, len, peerdist_discovery_reply::locations, max, memcmp(), out, peerdist_discovery_reply_values(), strcpy(), and strlen().

Variable Documentation

◆ hex

char hex[8]

Count (as an eight-digit hex value)

Definition at line 1 of file pccrd.h.

Referenced by peerdist_discovery_reply(), and vcprintf().