View Issue Details

IDProjectCategoryView StatusLast Update
0001499GNUnetobsoletepublic2024-05-03 14:02
ReporterChristian Grothoff Assigned ToChristian Grothoff  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Summary0001499: gnunet-peerinfo should print host addresses of other peers
DescriptionNote that a peer may have multiple addresses and that (at least in the future) we have more than just IPv4 and IPv6. So in order to get a printable string, we'll need to ask the respective transport plugin of the gnunet-service-peerinfo for the conversion of its addresses to strings.
TagsNo tags attached.

Activities

Christian Grothoff

2009-11-19 07:12

manager   ~0003919

Use gnunet_hello_lib.h's GNUNET_HELLO_iterate_addresses to extract addresses from "hello" (in print_peer_info).

Then, the AddressPrettyPrinter (from plugin_transport.h) must be called to convert the binary address to a string. For that, the gnunet_transport_service.h API has to be extended with a new function; the function should be implemented (new file transport_api_address_lookup.c), a request and a reply message format need to be defined (new structs in transport.h, new message types in gnunet_protocols.h), and gnunet-service-transport.c must be extended to handle the new request.

Christian Grothoff

2009-12-03 14:51

manager   ~0003927

How to build struct AddressLookupMessage...


struct AddressLookupMessage *msg = malloc (sizeof (struct AddressLookupMessage) +
                       addrlen +
                       strlen (tname) + 1);
msg->header->size = htons (sizeof (struct AddressLookupMessage) +
               addrlen +
               strlen (tname) + 1);
msg->header->type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP);
msg->addrlen = htonl (addrlen);
char *addrbuf = (char*) &msg[1];
memcpy (addrbuf, addr, addrlen);
char *tbuf = &addrbuf[addrlen];
memcpy (tbuf, tname, strlen(tname) + 1);

send (service, &msg->header);

Ji Lu

2009-12-06 15:23

reporter   ~0003934

/**
 * Obtain a AddressLookupMessage from a client and return to client all the host addresses of other peers.
 *
 * @param handle connection to transport service
 * @param addLUmsg the address-lookup message
 */
void
GNUNET_TRANSPORT_address_lookup (struct GNUNET_TRANSPORT_Handle *handle,
                const struct AddressLookupMessage *addLUmsg);

Christian Grothoff

2009-12-06 16:19

manager   ~0003935

address_lookup should not be given a lookup message -- it should create one *internally*, transmit it, parse the reply and then call a function with the (human-readable) address received from the reply. So the arguments should be the binary address (and name of the transport) and a function to call with the result (and a timeout value).

Ji Lu

2009-12-06 19:17

reporter   ~0003937

typedef void
(*GNUNET_TRANSPORT_AddressLUCallback) (void *cls, char *address, int addrlen);

void
GNUNET_TRANSPORT_address_lookup (struct GNUNET_TRANSPORT_Handle *handle,
                                 const char * address,
                                 const char * nameTrans,
                                 int nameLen,
                         struct GNUNET_TIME_Relative timeout,
                         GNUNET_TRANSPORT_AddressLUCallback aluc,
                         void *aluc_cls);

Is that right?

Christian Grothoff

2009-12-07 13:53

manager   ~0003939

Last edited: 2009-12-07 13:53

Not quite. We want:

typedef void
(*GNUNET_TRANSPORT_AddressLookupCallback) (void *cls, const char *address);

void
GNUNET_TRANSPORT_address_lookup (struct GNUNET_TRANSPORT_Handle *handle,
                                 const char * address,
                                 size_t addressLen,
                                 const char * nameTrans,
                         struct GNUNET_TIME_Relative timeout,
                         GNUNET_TRANSPORT_AddressLookupCallback aluc,
                         void *aluc_cls);


Ji Lu

2009-12-07 22:34

reporter   ~0003940

I have three problems to discuss with you,

first is: I am still a little confused how to use the GNUNET_HELLO_iterate_addresses
        and what is it used for?

second is:
void
GNUNET_TRANSPORT_address_lookup (struct GNUNET_TRANSPORT_Handle *handle,
                                 const char * address,
                                 size_t addressLen,
                                 const char * nameTrans,
                         struct GNUNET_TIME_Relative timeout,
                         GNUNET_TRANSPORT_AddressLUCallback aluc,
                         void *aluc_cls)
{
    size_t len = sizeof (struct AddressLookupMessage) + addressLen +
                     strlen (nameTrans) + 1;
    struct AddressLookupMessage *msg = malloc (len);
    msg->header->size = htons (len);
    msg->header->type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP);
    msg->addrlen = htonl (addressLen);
    char *addrbuf = (char*) &msg[1];
    memcpy (addrbuf, address, addressLen);
    char *tbuf = &addrbuf[addressLen];
    memcpy (tbuf, nameTrans, strlen(nameTrans) + 1);
        ...
        ...
    send (service, &msg->header,sizeof(len),0);
        GNUNET_free(msg);
}

how can I can the address of "service" for "handle", there is no element in the struct handle which contains the address of transport server. Another trouble is the "timeout" usage. could you please give me some tips for the "timeout".

third is: the extend function in gnunet-service-transport.c, which should handle request for the AddressLookupMessage,
static void
handle_addressLookUp (void *cls,
                      struct GNUNET_SERVER_Client *client,
                      const struct GNUNET_MessageHeader *message)
{
    const struct AddressLookupMessage *alum =
          (const struct AddressLookupMessage *) message;
// address_pretty_printer(cls,alum->header->type,&alum[1],alum->addrlen,,);
}

should I implement the function "address_pretty_printer"? There seems to be no implementation for it. Another problem is, according to the definition of struct "AddressLookupMessage", it seems to be a little difficult to extract the elements of alum as parameters of "address_pretty_printer".

please just check these above, and guide me out of the trouble. Thank you!

Christian Grothoff

2009-12-08 00:21

manager   ~0003941

1) Don't worry about it for now. You'll use it once you modify gnunet-peerinfo.

2) You realize that
 send (service, &msg->header,sizeof(len),0);

is totally wrong, right? You need to use gnunet_client_lib to transmit the message. Once you understand the client API, this should also answer your question about timeout. Also, sizeof(len) == 4, which is not what you want anyway.



3) No, the "address_pretty_printer" is already implemented in "transport_plugin.h" (to be more precise, each plugin implements it, and you should just locate the plugin API (using the transport's name, which you have) and call its pretty-printing function to convert the binary address to a string.

Ji Lu

2009-12-08 12:41

reporter   ~0003942

Last edited: 2009-12-08 12:49

void
GNUNET_TRANSPORT_address_lookup (struct GNUNET_TRANSPORT_Handle *handle,
                                 const char * address,
                                 size_t addressLen,
                                 const char * nameTrans,
                         struct GNUNET_TIME_Relative timeout,
                         GNUNET_TRANSPORT_AddressLUCallback aluc,
                         void *aluc_cls)
{
    size_t len = sizeof (struct AddressLookupMessage) + addressLen + strlen (nameTrans) + 1;
    struct AddressLookupMessage *msg = malloc (len);
    msg->header->size = htons (len);
    msg->header->type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP);
    msg->addrlen = htonl (addressLen);
    char *addrbuf = (char*) &msg[1];
    memcpy (addrbuf, address, addressLen);
    char *tbuf = &addrbuf[addressLen];
    memcpy (tbuf, nameTrans, strlen(nameTrans) + 1);
GNUNET_CLIENT_transmit_and_get_response(handle->client,msg->header,timeout,GNUNET_YES,GNUNET_CLIENT_addressLookUp,NULL);
    GNUNET_free(msg);
}

where GNUNET_CLIENT_addressLookUp is a new extend function, which should be called after the reply of server.

Ji Lu

2009-12-08 12:47

reporter   ~0003943

Last edited: 2009-12-08 13:00

with one question, how the server can get the name of the transport? which message_header contains it or it shows up separately?
I think before call its pretty-printing function of corresponding plugin, I should get a object of struct GNUNET_TRANSPORT_PluginFunctions which has the element of address_pretty_printer, right?

Christian Grothoff

2009-12-08 13:02

manager   ~0003944

1) You should not use the "GNUNET_CLIENT_" prefix for internal (static) functions; also, passing "NULL" won't do here: you need to create a struct with the aluc and aluc_cls so that you can then call those again.

2) Re-read HACKING about naming conventions

3) You copied the name of the transport to the address of "tbuf" which is part of the message that you are sending. So the receiver will need to get 'addressLen' from the 'addrlen' field, add that to the end of msg and that will then be the name of the transport.

Ji Lu

2009-12-08 19:56

reporter   ~0003945

static void
address_response_processor(void *cls, const struct
                           GNUNET_MessageHeader * msg)
{


}

struct AddressLookUpCB{
    GNUNET_TRANSPORT_AddressLUCallback cb;
    void *cls;
};

void
GNUNET_TRANSPORT_address_lookup (struct GNUNET_TRANSPORT_Handle *handle,
                                 const char * address,
                                 size_t addressLen,
                                 const char * nameTrans,
                         struct GNUNET_TIME_Relative timeout,
                         GNUNET_TRANSPORT_AddressLUCallback aluc,
                         void *aluc_cls)
{
    size_t len = sizeof (struct AddressLookupMessage) + addressLen + strlen (nameTrans) + 1;
    struct AddressLookupMessage *msg = malloc (len);
    msg->header->size = htons (len);
    msg->header->type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP);
    msg->addrlen = htonl (addressLen);
    char *addrbuf = (char*) &msg[1];
    memcpy (addrbuf, address, addressLen);
    char *tbuf = &addrbuf[addressLen];
    memcpy (tbuf, nameTrans, strlen(nameTrans) + 1);
    AddressLookUpCB aluCB = {aluc,aluc_cls};
    GNUNET_CLIENT_transmit_and_get_response(handle->client, msg->header, timeout, GNUNET_YES, &address_response_processor, &aluCB);
    GNUNET_free(msg);
}

this is in transport_api_address_lookup.c

Ji Lu

2009-12-08 20:01

reporter   ~0003946

void Address2String (void *cls, const char *address){


}

static void
handle_addressLookUp (void *cls,
                      struct GNUNET_SERVER_Client *client,
                      const struct GNUNET_MessageHeader *message)
{
    struct TransportPlugin *lsPlugin;
    const struct AddressLookupMessage *alum =
          (const struct AddressLookupMessage *) message;
    char *addr = &alum[1];
    char *nameTransport = &addr[alum->addrlen];
    lsPlugin = find_transport(nameTransport);
    lsPlugin->api->address_pretty_printer(cls, nameTransport, addr
                alum->addrlen, GNUNET_YES,...,&Address2String,...) ;


}

this is in gnunet-service-transport.c, I don't know how to decide two missing parameters of "address_pretty_printer".

Christian Grothoff

2009-12-09 00:16

manager   ~0003947

Timeout: you might want to add the timeout to the message you received from the client; it will be used in case DNS resolution is required. For the "asc_cls", you should pass "client" so that inside of "Address2String" you can send back the (resolved, human-readable) address to the requesting client.

Christian Grothoff

2009-12-23 08:50

manager   ~0003977

gnunet-peerinfo still does not print host addresses. For starters, clearly gnunet-peerinfo.c needs to be modified as well (see FIXME there!).

Issue History

Date Modified Username Field Change
2009-11-10 14:32 Christian Grothoff New Issue
2009-11-10 14:32 Christian Grothoff Assigned To => Ji Lu
2009-11-10 14:32 Christian Grothoff Status new => assigned
2009-11-10 14:38 Christian Grothoff Severity minor => feature
2009-11-19 07:12 Christian Grothoff Note Added: 0003919
2009-12-03 14:51 Christian Grothoff Note Added: 0003927
2009-12-06 15:23 Ji Lu Note Added: 0003934
2009-12-06 16:19 Christian Grothoff Note Added: 0003935
2009-12-06 19:17 Ji Lu Note Added: 0003937
2009-12-07 13:53 Christian Grothoff Note Added: 0003939
2009-12-07 13:53 Christian Grothoff Note Edited: 0003939
2009-12-07 22:34 Ji Lu Note Added: 0003940
2009-12-08 00:21 Christian Grothoff Note Added: 0003941
2009-12-08 12:41 Ji Lu Note Added: 0003942
2009-12-08 12:47 Ji Lu Note Added: 0003943
2009-12-08 12:49 Ji Lu Note Edited: 0003942
2009-12-08 13:00 Ji Lu Note Edited: 0003943
2009-12-08 13:02 Christian Grothoff Note Added: 0003944
2009-12-08 19:56 Ji Lu Note Added: 0003945
2009-12-08 20:01 Ji Lu Note Added: 0003946
2009-12-09 00:16 Christian Grothoff Note Added: 0003947
2009-12-12 00:44 Ji Lu Status assigned => resolved
2009-12-12 00:44 Ji Lu Fixed in Version => 0.9.0
2009-12-12 00:44 Ji Lu Resolution open => fixed
2009-12-23 08:50 Christian Grothoff Note Added: 0003977
2009-12-23 08:50 Christian Grothoff Status resolved => feedback
2009-12-23 08:50 Christian Grothoff Resolution fixed => reopened
2009-12-23 08:50 Christian Grothoff Status feedback => assigned
2010-03-25 11:53 Christian Grothoff Assigned To Ji Lu => Christian Grothoff
2010-03-25 11:53 Christian Grothoff Status assigned => resolved
2010-03-25 11:53 Christian Grothoff Resolution reopened => fixed
2010-04-03 13:05 Christian Grothoff Status resolved => closed
2010-04-03 13:05 Christian Grothoff Fixed in Version 0.9.0 => 0.9.0pre0
2024-05-03 14:02 Christian Grothoff Category peerinfo service => obsolete