-/**
- * Method that assembles our hostlist advertisement message
- * @param peer peer to send the hostlist advertisement
- */
-static size_t
-adv_create_message ( const struct GNUNET_PeerIdentity * peer )
-
-{
- size_t length = 0;
- size_t size = 0;
- unsigned long long port;
-
- char *uri;
- char hostname[GNUNET_OS_get_hostname_max_length() + 1];
- char *protocol = "http://";
- char *port_s = GNUNET_malloc(6 * sizeof(char));
-
- if (0 != gethostname (hostname, sizeof (hostname) - 1))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "Could not get system's hostname, unable to create advertisement message");
- return GNUNET_NO;
- }
- if (-1 == GNUNET_CONFIGURATION_get_value_number (cfg,
- "HOSTLIST",
- "HTTPPORT",
- &port))
- return GNUNET_SYSERR;
-
- sprintf(port_s, "%llu", port);
- length = strlen(hostname)+strlen(protocol)+strlen(port_s)+2;
- size = (length+1) * sizeof (char);
- uri = GNUNET_malloc(size);
- uri = strcpy(uri, protocol);
- uri = strcat(uri, hostname);
- uri = strcat(uri, ":");
- uri = strcat(uri, port_s);
- uri = strcat(uri, "/");
- strcpy(hostlist_uri,uri);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Address to obtain hostlist: %s\n", hostlist_uri);
-
- if ( ( size + sizeof( struct GNUNET_HOSTLIST_ADV_Message )) > GNUNET_SERVER_MAX_MESSAGE_SIZE)
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
- "Advertisement message is bigger than GNUNET allows");
- return GNUNET_NO;
- }
-
- /* Request core to transmit message to peer */
- size = size + sizeof ( struct GNUNET_HOSTLIST_ADV_Message );
- adv_transmit_message(peer, size);
-
- GNUNET_free ( port_s );
- GNUNET_free ( uri );
-
- return GNUNET_OK;
-}