summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2015-08-17 14:16:33 +0200
committerMichael Brown2015-08-17 14:24:39 +0200
commitdc9d24e7d29ae6926fcafadbc8ca4089f0aae616 (patch)
tree0ff04cd3e1dddb1d789be0544e957536402e08ac /src/include
parent[http] Rewrite HTTP core to support content encodings (diff)
downloadipxe-dc9d24e7d29ae6926fcafadbc8ca4089f0aae616.tar.gz
ipxe-dc9d24e7d29ae6926fcafadbc8ca4089f0aae616.tar.xz
ipxe-dc9d24e7d29ae6926fcafadbc8ca4089f0aae616.zip
[peerdist] Add segment discovery mechanism
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/errfile.h1
-rw-r--r--src/include/ipxe/peerdisc.h116
2 files changed, 117 insertions, 0 deletions
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index 979747ae6..e1837d158 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -252,6 +252,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_httpauth ( ERRFILE_NET | 0x00420000 )
#define ERRFILE_httpbasic ( ERRFILE_NET | 0x00430000 )
#define ERRFILE_httpdigest ( ERRFILE_NET | 0x00440000 )
+#define ERRFILE_peerdisc ( ERRFILE_NET | 0x00450000 )
#define ERRFILE_image ( ERRFILE_IMAGE | 0x00000000 )
#define ERRFILE_elf ( ERRFILE_IMAGE | 0x00010000 )
diff --git a/src/include/ipxe/peerdisc.h b/src/include/ipxe/peerdisc.h
new file mode 100644
index 000000000..f08ccaae2
--- /dev/null
+++ b/src/include/ipxe/peerdisc.h
@@ -0,0 +1,116 @@
+#ifndef _IPXE_PEERDISC_H
+#define _IPXE_PEERDISC_H
+
+/** @file
+ *
+ * Peer Content Caching and Retrieval (PeerDist) protocol peer discovery
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+#include <ipxe/refcnt.h>
+#include <ipxe/list.h>
+#include <ipxe/tables.h>
+#include <ipxe/retry.h>
+#include <ipxe/socket.h>
+#include <ipxe/interface.h>
+#include <ipxe/pccrc.h>
+
+/** A PeerDist discovery socket */
+struct peerdisc_socket {
+ /** Name */
+ const char *name;
+ /** Data transfer interface */
+ struct interface xfer;
+ /** Socket address */
+ union {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ } address;
+};
+
+/** PeerDist discovery socket table */
+#define PEERDISC_SOCKETS __table ( struct peerdisc_socket, "peerdisc_sockets" )
+
+/** Declare a PeerDist discovery socket */
+#define __peerdisc_socket __table_entry ( PEERDISC_SOCKETS, 01 )
+
+/** A PeerDist discovery segment */
+struct peerdisc_segment {
+ /** Reference count */
+ struct refcnt refcnt;
+ /** List of segments */
+ struct list_head list;
+ /** Segment identifier string
+ *
+ * This is MS-PCCRC's "HoHoDk", transcribed as an upper-case
+ * Base16-encoded string.
+ */
+ const char *id;
+ /** Message UUID string */
+ const char *uuid;
+ /** List of discovered peers
+ *
+ * The list of peers may be appended to during the lifetime of
+ * the discovery segment. Discovered peers will not be
+ * removed from the list until the last discovery has been
+ * closed; this allows users to safely maintain a pointer to a
+ * current position within the list.
+ */
+ struct list_head peers;
+ /** List of active clients */
+ struct list_head clients;
+ /** Transmission timer */
+ struct retry_timer timer;
+};
+
+/** A PeerDist discovery peer */
+struct peerdisc_peer {
+ /** List of peers */
+ struct list_head list;
+ /** Peer location */
+ char location[0];
+};
+
+/** A PeerDist discovery client */
+struct peerdisc_client {
+ /** Discovery segment */
+ struct peerdisc_segment *segment;
+ /** List of clients */
+ struct list_head list;
+ /** Operations */
+ struct peerdisc_client_operations *op;
+};
+
+/** PeerDist discovery client operations */
+struct peerdisc_client_operations {
+ /** New peers have been discovered
+ *
+ * @v peerdisc PeerDist discovery client
+ */
+ void ( * discovered ) ( struct peerdisc_client *peerdisc );
+};
+
+/**
+ * Initialise PeerDist discovery
+ *
+ * @v peerdisc PeerDist discovery client
+ * @v op Discovery operations
+ */
+static inline __attribute__ (( always_inline )) void
+peerdisc_init ( struct peerdisc_client *peerdisc,
+ struct peerdisc_client_operations *op ) {
+
+ peerdisc->op = op;
+}
+
+extern unsigned int peerdisc_timeout_secs;
+
+extern int peerdisc_open ( struct peerdisc_client *peerdisc, const void *id,
+ size_t len );
+extern void peerdisc_close ( struct peerdisc_client *peerdisc );
+
+#endif /* _IPXE_PEERDISC_H */