fast timeout on disconnect
[oweals/gnunet.git] / src / include / gnunet_hello_lib.h
index 6191c4f7e794b7ca1f0d154c00b2efb5dd04c87d..c5628928687b7592deab1682093c2940019f99de 100644 (file)
@@ -4,7 +4,7 @@
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
+     by the Free Software Foundation; either version 3, or (at your
      option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
@@ -64,7 +64,7 @@ size_t
 GNUNET_HELLO_add_address (const char *tname,
                           struct GNUNET_TIME_Absolute expiration,
                           const void *addr,
-                          size_t addr_len, char *target, size_t max);
+                          uint16_t addr_len, char *target, size_t max);
 
 
 /**
@@ -120,6 +120,29 @@ struct GNUNET_HELLO_Message *GNUNET_HELLO_merge (const struct
                                                  GNUNET_HELLO_Message *h2);
 
 
+/**
+ * Test if two HELLO messages contain the same addresses.
+ * If they only differ in expiration time, the lowest
+ * expiration time larger than 'now' where they differ
+ * is returned.
+ *
+ * @param h1 first HELLO message
+ * @param h2 the second HELLO message
+ * @param now time to use for deciding which addresses have
+ *            expired and should not be considered at all
+ * @return absolute time forever if the two HELLOs are 
+ *         totally identical; smallest timestamp >= now if
+ *         they only differ in timestamps; 
+ *         zero if the some addresses with expirations >= now
+ *         do not match at all
+ */
+struct GNUNET_TIME_Absolute 
+GNUNET_HELLO_equals (const struct
+                    GNUNET_HELLO_Message *h1,
+                    const struct
+                    GNUNET_HELLO_Message *h2,
+                    struct GNUNET_TIME_Absolute now);
+
 
 /**
  * Iterator callback to go over all addresses.
@@ -137,7 +160,8 @@ typedef int
   (*GNUNET_HELLO_AddressIterator) (void *cls,
                                    const char *tname,
                                    struct GNUNET_TIME_Absolute expiration,
-                                   const void *addr, size_t addrlen);
+                                   const void *addr, 
+                                  uint16_t addrlen);
 
 
 /**
@@ -207,6 +231,18 @@ int
 GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello,
                     struct GNUNET_PeerIdentity *peer);
 
+
+/**
+ * Get the header from a HELLO message, used so other code
+ * can correctly send HELLO messages.
+ *
+ * @param hello the hello message
+ *
+ * @return header or NULL if the HELLO was malformed
+ */
+struct GNUNET_MessageHeader *
+GNUNET_HELLO_get_header (struct GNUNET_HELLO_Message *hello);
+
 /* ifndef GNUNET_HELLO_LIB_H */
 #endif
 /* end of gnunet_hello_lib.h */