diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-29 09:37:54 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-11-29 09:37:54 +0000 |
commit | 623df97886da9ee06724b7860a1a2463737b750e (patch) | |
tree | a7638265a42b7b276d10403078411e4f4d8973d8 /src/transport/transport_api_address_lookup.c | |
parent | 51b7d6d6e0d50e77a3fc948af68ae02f325684ac (diff) | |
download | gnunet-623df97886da9ee06724b7860a1a2463737b750e.tar.gz gnunet-623df97886da9ee06724b7860a1a2463737b750e.zip |
first steps to transport_api cleanup
compiles but no guarante to work!
Diffstat (limited to 'src/transport/transport_api_address_lookup.c')
-rw-r--r-- | src/transport/transport_api_address_lookup.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index 968a4324f..259c77152 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c | |||
@@ -30,12 +30,12 @@ | |||
30 | /** | 30 | /** |
31 | * Context for the address lookup. | 31 | * Context for the address lookup. |
32 | */ | 32 | */ |
33 | struct GNUNET_TRANSPORT_AddressLookupContext | 33 | struct GNUNET_TRANSPORT_AddressToStringContext |
34 | { | 34 | { |
35 | /** | 35 | /** |
36 | * Function to call with the human-readable address. | 36 | * Function to call with the human-readable address. |
37 | */ | 37 | */ |
38 | GNUNET_TRANSPORT_AddressLookUpCallback cb; | 38 | GNUNET_TRANSPORT_AddressToStringCallback cb; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Closure for cb. | 41 | * Closure for cb. |
@@ -64,7 +64,7 @@ struct GNUNET_TRANSPORT_AddressLookupContext | |||
64 | static void | 64 | static void |
65 | address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) | 65 | address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) |
66 | { | 66 | { |
67 | struct GNUNET_TRANSPORT_AddressLookupContext *alucb = cls; | 67 | struct GNUNET_TRANSPORT_AddressToStringContext *alucb = cls; |
68 | const char *address; | 68 | const char *address; |
69 | uint16_t size; | 69 | uint16_t size; |
70 | 70 | ||
@@ -117,23 +117,23 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) | |||
117 | * @param aluc_cls closure for aluc | 117 | * @param aluc_cls closure for aluc |
118 | * @return handle to cancel the operation, NULL on error | 118 | * @return handle to cancel the operation, NULL on error |
119 | */ | 119 | */ |
120 | struct GNUNET_TRANSPORT_AddressLookupContext * | 120 | struct GNUNET_TRANSPORT_AddressToStringContext * |
121 | GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | 121 | GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg, |
122 | const char *address, size_t addressLen, | 122 | const struct GNUNET_HELLO_Address *address, |
123 | int numeric, const char *nameTrans, | 123 | int numeric, |
124 | struct GNUNET_TIME_Relative timeout, | 124 | struct GNUNET_TIME_Relative timeout, |
125 | GNUNET_TRANSPORT_AddressLookUpCallback aluc, | 125 | GNUNET_TRANSPORT_AddressToStringCallback aluc, |
126 | void *aluc_cls) | 126 | void *aluc_cls) |
127 | { | 127 | { |
128 | size_t slen; | ||
129 | size_t len; | 128 | size_t len; |
129 | size_t alen; | ||
130 | struct AddressLookupMessage *msg; | 130 | struct AddressLookupMessage *msg; |
131 | struct GNUNET_TRANSPORT_AddressLookupContext *alc; | 131 | struct GNUNET_TRANSPORT_AddressToStringContext *alc; |
132 | struct GNUNET_CLIENT_Connection *client; | 132 | struct GNUNET_CLIENT_Connection *client; |
133 | char *addrbuf; | 133 | char *addrbuf; |
134 | 134 | ||
135 | slen = strlen (nameTrans) + 1; | 135 | alen = GNUNET_HELLO_address_get_size (address); |
136 | len = sizeof (struct AddressLookupMessage) + addressLen + slen; | 136 | len = sizeof (struct AddressLookupMessage) + alen; |
137 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 137 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
138 | { | 138 | { |
139 | GNUNET_break (0); | 139 | GNUNET_break (0); |
@@ -147,11 +147,10 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
147 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); | 147 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); |
148 | msg->numeric_only = htonl (numeric); | 148 | msg->numeric_only = htonl (numeric); |
149 | msg->timeout = GNUNET_TIME_relative_hton (timeout); | 149 | msg->timeout = GNUNET_TIME_relative_hton (timeout); |
150 | msg->addrlen = htonl (addressLen); | 150 | msg->addrlen = htonl (alen); |
151 | addrbuf = (char *) &msg[1]; | 151 | addrbuf = (char *) &msg[1]; |
152 | memcpy (addrbuf, address, addressLen); | 152 | memcpy (addrbuf, address, alen); |
153 | memcpy (&addrbuf[addressLen], nameTrans, slen); | 153 | alc = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_AddressToStringContext)); |
154 | alc = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_AddressLookupContext)); | ||
155 | alc->cb = aluc; | 154 | alc->cb = aluc; |
156 | alc->cb_cls = aluc_cls; | 155 | alc->cb_cls = aluc_cls; |
157 | alc->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 156 | alc->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
@@ -172,8 +171,8 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
172 | * @param alc handle for the request to cancel | 171 | * @param alc handle for the request to cancel |
173 | */ | 172 | */ |
174 | void | 173 | void |
175 | GNUNET_TRANSPORT_address_lookup_cancel (struct | 174 | GNUNET_TRANSPORT_address_to_string_cancel (struct |
176 | GNUNET_TRANSPORT_AddressLookupContext | 175 | GNUNET_TRANSPORT_AddressToStringContext |
177 | *alc) | 176 | *alc) |
178 | { | 177 | { |
179 | GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); | 178 | GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); |