Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

peerdisc.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef _IPXE_PEERDISC_H
  2. #define _IPXE_PEERDISC_H
  3. /** @file
  4. *
  5. * Peer Content Caching and Retrieval (PeerDist) protocol peer discovery
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/refcnt.h>
  11. #include <ipxe/list.h>
  12. #include <ipxe/tables.h>
  13. #include <ipxe/retry.h>
  14. #include <ipxe/socket.h>
  15. #include <ipxe/interface.h>
  16. #include <ipxe/pccrc.h>
  17. /** A PeerDist discovery socket */
  18. struct peerdisc_socket {
  19. /** Name */
  20. const char *name;
  21. /** Data transfer interface */
  22. struct interface xfer;
  23. /** Socket address */
  24. union {
  25. struct sockaddr sa;
  26. struct sockaddr_in sin;
  27. struct sockaddr_in6 sin6;
  28. } address;
  29. };
  30. /** PeerDist discovery socket table */
  31. #define PEERDISC_SOCKETS __table ( struct peerdisc_socket, "peerdisc_sockets" )
  32. /** Declare a PeerDist discovery socket */
  33. #define __peerdisc_socket __table_entry ( PEERDISC_SOCKETS, 01 )
  34. /** A PeerDist discovery segment */
  35. struct peerdisc_segment {
  36. /** Reference count */
  37. struct refcnt refcnt;
  38. /** List of segments */
  39. struct list_head list;
  40. /** Segment identifier string
  41. *
  42. * This is MS-PCCRC's "HoHoDk", transcribed as an upper-case
  43. * Base16-encoded string.
  44. */
  45. const char *id;
  46. /** Message UUID string */
  47. const char *uuid;
  48. /** List of discovered peers
  49. *
  50. * The list of peers may be appended to during the lifetime of
  51. * the discovery segment. Discovered peers will not be
  52. * removed from the list until the last discovery has been
  53. * closed; this allows users to safely maintain a pointer to a
  54. * current position within the list.
  55. */
  56. struct list_head peers;
  57. /** List of active clients */
  58. struct list_head clients;
  59. /** Transmission timer */
  60. struct retry_timer timer;
  61. };
  62. /** A PeerDist discovery peer */
  63. struct peerdisc_peer {
  64. /** List of peers */
  65. struct list_head list;
  66. /** Peer location */
  67. char location[0];
  68. };
  69. /** A PeerDist discovery client */
  70. struct peerdisc_client {
  71. /** Discovery segment */
  72. struct peerdisc_segment *segment;
  73. /** List of clients */
  74. struct list_head list;
  75. /** Operations */
  76. struct peerdisc_client_operations *op;
  77. };
  78. /** PeerDist discovery client operations */
  79. struct peerdisc_client_operations {
  80. /** New peers have been discovered
  81. *
  82. * @v peerdisc PeerDist discovery client
  83. */
  84. void ( * discovered ) ( struct peerdisc_client *peerdisc );
  85. };
  86. /**
  87. * Initialise PeerDist discovery
  88. *
  89. * @v peerdisc PeerDist discovery client
  90. * @v op Discovery operations
  91. */
  92. static inline __attribute__ (( always_inline )) void
  93. peerdisc_init ( struct peerdisc_client *peerdisc,
  94. struct peerdisc_client_operations *op ) {
  95. peerdisc->op = op;
  96. }
  97. extern unsigned int peerdisc_timeout_secs;
  98. extern void peerdisc_stat ( struct interface *intf, struct peerdisc_peer *peer,
  99. struct list_head *peers );
  100. #define peerdisc_stat_TYPE( object_type ) \
  101. typeof ( void ( object_type, struct peerdisc_peer *peer, \
  102. struct list_head *peers ) )
  103. extern int peerdisc_open ( struct peerdisc_client *peerdisc, const void *id,
  104. size_t len );
  105. extern void peerdisc_close ( struct peerdisc_client *peerdisc );
  106. #endif /* _IPXE_PEERDISC_H */