iPXE
|
Peer Content Caching and Retrieval: Discovery Protocol [MS-PCCRD]. More...
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
#include <ipxe/pccrd.h>
Go to the source code of this file.
Macros | |
#define | PEERDIST_DISCOVERY_REQUEST |
Discovery request format. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
char * | peerdist_discovery_request (const char *uuid, const char *id) |
Construct discovery request. More... | |
static char * | peerdist_discovery_reply_tag (char *data, size_t len, const char *tag) |
Locate discovery reply tag. More... | |
static char * | peerdist_discovery_reply_values (char *data, size_t len, const char *name) |
Locate discovery reply values. More... | |
int | peerdist_discovery_reply (char *data, size_t len, struct peerdist_discovery_reply *reply) |
Parse discovery reply. More... | |
Peer Content Caching and Retrieval: Discovery Protocol [MS-PCCRD].
This protocol manages to ingeniously combine the excessive verbosity of XML with a paucity of actual information. For example: even in version 2.0 of the protocol it is still not possible to discover which peers hold a specific block within a given segment.
For added bonus points, version 1.0 of the protocol is specified to use a case-sensitive string comparison (for SHA2 digest values) but nothing specifies whether the strings in question should be in upper or lower case. There are example strings given in the specification, but the author skilfully manages to leave the issue unresolved by using the somewhat implausible digest value of "0200000000000000000000000000000000000000000000000000000000000000".
Just in case you were thinking that the silver lining of the choice to use an XML-based protocol would be the ability to generate and process messages with standard tools, version 2.0 of the protocol places most of the critical information inside a Base64-encoded custom binary data structure. Within an XML element, naturally.
I hereby announce this specification to be the 2015 winner of the prestigious "UEFI HII API" award for incompetent design.
Definition in file pccrd.c.
#define PEERDIST_DISCOVERY_REQUEST |
Discovery request format.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
char* peerdist_discovery_request | ( | const char * | uuid, |
const char * | id | ||
) |
Construct discovery request.
uuid | Message UUID string |
id | Segment identifier string |
request | Discovery request, or NULL on failure |
The request is dynamically allocated; the caller must eventually free() the request.
Definition at line 106 of file pccrd.c.
References asprintf(), len, NULL, PEERDIST_DISCOVERY_REQUEST, and request.
Referenced by peerdisc_socket_tx().
|
static |
Locate discovery reply tag.
data | Reply data (not NUL-terminated) |
len | Length of reply data |
tag | XML tag |
found | Found tag (or NULL if not found) |
Definition at line 126 of file pccrd.c.
References data, len, NULL, strlen(), strncmp(), and tag.
Referenced by peerdist_discovery_reply_values().
|
static |
Locate discovery reply values.
data | Reply data (not NUL-terminated, will be modified) |
len | Length of reply data |
name | XML tag name |
values | Tag values (or NULL if not found) |
The reply data is modified by adding NULs and moving characters as needed to produce a NUL-separated list of values, terminated with a zero-length string.
This is not supposed to be a full XML parser; it's supposed to include just enough functionality to allow PeerDist discovery to work with existing implementations.
Definition at line 157 of file pccrd.c.
References assert(), c, close, data, end, in, isspace(), len, name, NULL, open(), out, peerdist_discovery_reply_tag(), snprintf(), start, and strlen().
Referenced by peerdist_discovery_reply().
int peerdist_discovery_reply | ( | char * | data, |
size_t | len, | ||
struct peerdist_discovery_reply * | reply | ||
) |
Parse discovery reply.
data | Reply data (not NUL-terminated, will be modified) |
len | Length of reply data |
reply | Discovery reply to fill in |
rc | Return status code |
The discovery reply includes pointers to strings within the modified reply data.
Definition at line 216 of file pccrd.c.
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().