diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
commit | 502af2167f7c218366666ca4944bd7cc54b5b19a (patch) | |
tree | a91fec5cc9769d260640bd91c6633cb9cf395524 /src/transport/transport_api_address_lookup.c | |
parent | 03af5a603b7cc53432249d5854cd412aa90dde0d (diff) | |
download | gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip |
indentation
Diffstat (limited to 'src/transport/transport_api_address_lookup.c')
-rw-r--r-- | src/transport/transport_api_address_lookup.c | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index 619e60a43..4aadf10f4 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c | |||
@@ -62,45 +62,44 @@ struct AddressLookupCtx | |||
62 | * message with the human-readable address | 62 | * message with the human-readable address |
63 | */ | 63 | */ |
64 | static void | 64 | static void |
65 | address_response_processor (void *cls, | 65 | address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) |
66 | const struct GNUNET_MessageHeader *msg) | ||
67 | { | 66 | { |
68 | struct AddressLookupCtx *alucb = cls; | 67 | struct AddressLookupCtx *alucb = cls; |
69 | const char *address; | 68 | const char *address; |
70 | uint16_t size; | 69 | uint16_t size; |
71 | 70 | ||
72 | if (msg == NULL) | 71 | if (msg == NULL) |
73 | { | 72 | { |
74 | alucb->cb (alucb->cb_cls, NULL); | 73 | alucb->cb (alucb->cb_cls, NULL); |
75 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); | 74 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); |
76 | GNUNET_free (alucb); | 75 | GNUNET_free (alucb); |
77 | return; | 76 | return; |
78 | } | 77 | } |
79 | GNUNET_break (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | 78 | GNUNET_break (ntohs (msg->type) == |
79 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
80 | size = ntohs (msg->size); | 80 | size = ntohs (msg->size); |
81 | if (size == sizeof (struct GNUNET_MessageHeader)) | 81 | if (size == sizeof (struct GNUNET_MessageHeader)) |
82 | { | 82 | { |
83 | /* done! */ | 83 | /* done! */ |
84 | alucb->cb (alucb->cb_cls, NULL); | 84 | alucb->cb (alucb->cb_cls, NULL); |
85 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); | 85 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); |
86 | GNUNET_free (alucb); | 86 | GNUNET_free (alucb); |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | address = (const char *) &msg[1]; | 89 | address = (const char *) &msg[1]; |
90 | if (address[size - sizeof (struct GNUNET_MessageHeader) - 1] != '\0') | 90 | if (address[size - sizeof (struct GNUNET_MessageHeader) - 1] != '\0') |
91 | { | 91 | { |
92 | /* invalid reply */ | 92 | /* invalid reply */ |
93 | GNUNET_break (0); | 93 | GNUNET_break (0); |
94 | alucb->cb (alucb->cb_cls, NULL); | 94 | alucb->cb (alucb->cb_cls, NULL); |
95 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); | 95 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); |
96 | GNUNET_free (alucb); | 96 | GNUNET_free (alucb); |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | /* expect more replies */ | 99 | /* expect more replies */ |
100 | GNUNET_CLIENT_receive (alucb->client, | 100 | GNUNET_CLIENT_receive (alucb->client, |
101 | &address_response_processor, alucb, | 101 | &address_response_processor, alucb, |
102 | GNUNET_TIME_absolute_get_remaining | 102 | GNUNET_TIME_absolute_get_remaining (alucb->timeout)); |
103 | (alucb->timeout)); | ||
104 | alucb->cb (alucb->cb_cls, address); | 103 | alucb->cb (alucb->cb_cls, address); |
105 | } | 104 | } |
106 | 105 | ||
@@ -120,9 +119,9 @@ address_response_processor (void *cls, | |||
120 | */ | 119 | */ |
121 | void | 120 | void |
122 | GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | 121 | GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, |
123 | const char *address, | 122 | const char *address, |
124 | size_t addressLen, | 123 | size_t addressLen, |
125 | int numeric, | 124 | int numeric, |
126 | const char *nameTrans, | 125 | const char *nameTrans, |
127 | struct GNUNET_TIME_Relative timeout, | 126 | struct GNUNET_TIME_Relative timeout, |
128 | GNUNET_TRANSPORT_AddressLookUpCallback aluc, | 127 | GNUNET_TRANSPORT_AddressLookUpCallback aluc, |
@@ -138,17 +137,17 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
138 | slen = strlen (nameTrans) + 1; | 137 | slen = strlen (nameTrans) + 1; |
139 | len = sizeof (struct AddressLookupMessage) + addressLen + slen; | 138 | len = sizeof (struct AddressLookupMessage) + addressLen + slen; |
140 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 139 | if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
141 | { | 140 | { |
142 | GNUNET_break (0); | 141 | GNUNET_break (0); |
143 | aluc (aluc_cls, NULL); | 142 | aluc (aluc_cls, NULL); |
144 | return; | 143 | return; |
145 | } | 144 | } |
146 | client = GNUNET_CLIENT_connect ("transport", cfg); | 145 | client = GNUNET_CLIENT_connect ("transport", cfg); |
147 | if (client == NULL) | 146 | if (client == NULL) |
148 | { | 147 | { |
149 | aluc (aluc_cls, NULL); | 148 | aluc (aluc_cls, NULL); |
150 | return; | 149 | return; |
151 | } | 150 | } |
152 | msg = GNUNET_malloc (len); | 151 | msg = GNUNET_malloc (len); |
153 | msg->header.size = htons (len); | 152 | msg->header.size = htons (len); |
154 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); | 153 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); |
@@ -164,12 +163,12 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
164 | aluCB->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 163 | aluCB->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
165 | aluCB->client = client; | 164 | aluCB->client = client; |
166 | GNUNET_assert (GNUNET_OK == | 165 | GNUNET_assert (GNUNET_OK == |
167 | GNUNET_CLIENT_transmit_and_get_response (client, | 166 | GNUNET_CLIENT_transmit_and_get_response (client, |
168 | &msg->header, | 167 | &msg->header, |
169 | timeout, | 168 | timeout, |
170 | GNUNET_YES, | 169 | GNUNET_YES, |
171 | &address_response_processor, | 170 | &address_response_processor, |
172 | aluCB)); | 171 | aluCB)); |
173 | GNUNET_free (msg); | 172 | GNUNET_free (msg); |
174 | } | 173 | } |
175 | 174 | ||