aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-27 15:38:59 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-27 15:38:59 +0000
commit0773a954d6ed9a5c155b9cbceca7a6a316400ba6 (patch)
treee75eb60483aa3bfa69b34f611a9dc20268792cf9 /src
parente53a85834277d70130f9d222ee43a989e16758c6 (diff)
downloadgnunet-0773a954d6ed9a5c155b9cbceca7a6a316400ba6.tar.gz
gnunet-0773a954d6ed9a5c155b9cbceca7a6a316400ba6.zip
-just replacing if by switch, in preparation for future changes
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c81
1 files changed, 43 insertions, 38 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 6ef946747..66029a21c 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -1152,48 +1152,53 @@ handle_gns_resolution_result (void *cls,
1152 { 1152 {
1153 for (i=0;i<rd_count;i++) 1153 for (i=0;i<rd_count;i++)
1154 { 1154 {
1155 if (GNUNET_NAMESTORE_TYPE_VPN == rd[i].record_type) 1155 switch (rd[i].record_type)
1156 { 1156 {
1157 af = (GNUNET_DNSPARSER_TYPE_A == rh->record_type) ? AF_INET : AF_INET6; 1157 case GNUNET_NAMESTORE_TYPE_VPN:
1158 if (sizeof (struct GNUNET_TUN_GnsVpnRecord) <
1159 rd[i].data_size)
1160 { 1158 {
1161 GNUNET_break_op (0); 1159 af = (GNUNET_DNSPARSER_TYPE_A == rh->record_type) ? AF_INET : AF_INET6;
1162 rh->proc (rh->proc_cls, 0, NULL); 1160 if (sizeof (struct GNUNET_TUN_GnsVpnRecord) <
1163 GNS_resolver_lookup_cancel (rh); 1161 rd[i].data_size)
1164 return; 1162 {
1165 } 1163 GNUNET_break_op (0);
1166 vpn = (const struct GNUNET_TUN_GnsVpnRecord *) rd[i].data; 1164 rh->proc (rh->proc_cls, 0, NULL);
1167 vname = (const char *) &vpn[1]; 1165 GNS_resolver_lookup_cancel (rh);
1168 if ('\0' != vname[rd[i].data_size - 1 - sizeof (struct GNUNET_TUN_GnsVpnRecord)]) 1166 return;
1169 { 1167 }
1170 GNUNET_break_op (0); 1168 vpn = (const struct GNUNET_TUN_GnsVpnRecord *) rd[i].data;
1171 rh->proc (rh->proc_cls, 0, NULL); 1169 vname = (const char *) &vpn[1];
1172 GNS_resolver_lookup_cancel (rh); 1170 if ('\0' != vname[rd[i].data_size - 1 - sizeof (struct GNUNET_TUN_GnsVpnRecord)])
1171 {
1172 GNUNET_break_op (0);
1173 rh->proc (rh->proc_cls, 0, NULL);
1174 GNS_resolver_lookup_cancel (rh);
1175 return;
1176 }
1177 GNUNET_CRYPTO_hash (vname,
1178 strlen (vname), // FIXME: +1?
1179 &vhash);
1180 vpn_ctx = GNUNET_new (struct VpnContext);
1181 rh->vpn_ctx = vpn_ctx;
1182 vpn_ctx->rh = rh;
1183 vpn_ctx->rd_data_size = GNUNET_NAMESTORE_records_get_size (rd_count,
1184 rd);
1185 vpn_ctx->rd_data = GNUNET_malloc (vpn_ctx->rd_data_size);
1186 (void) GNUNET_NAMESTORE_records_serialize (rd_count,
1187 rd,
1188 vpn_ctx->rd_data_size,
1189 vpn_ctx->rd_data);
1190 vpn_ctx->vpn_request = GNUNET_VPN_redirect_to_peer (vpn_handle,
1191 af,
1192 ntohs (vpn->proto),
1193 &vpn->peer,
1194 &vhash,
1195 GNUNET_TIME_relative_to_absolute (VPN_TIMEOUT),
1196 &vpn_allocation_cb,
1197 rh);
1173 return; 1198 return;
1174 } 1199 }
1175 GNUNET_CRYPTO_hash (vname, 1200 default:
1176 strlen (vname), // FIXME: +1? 1201 break;
1177 &vhash);
1178 vpn_ctx = GNUNET_new (struct VpnContext);
1179 rh->vpn_ctx = vpn_ctx;
1180 vpn_ctx->rh = rh;
1181 vpn_ctx->rd_data_size = GNUNET_NAMESTORE_records_get_size (rd_count,
1182 rd);
1183 vpn_ctx->rd_data = GNUNET_malloc (vpn_ctx->rd_data_size);
1184 (void) GNUNET_NAMESTORE_records_serialize (rd_count,
1185 rd,
1186 vpn_ctx->rd_data_size,
1187 vpn_ctx->rd_data);
1188 vpn_ctx->vpn_request = GNUNET_VPN_redirect_to_peer (vpn_handle,
1189 af,
1190 ntohs (vpn->proto),
1191 &vpn->peer,
1192 &vhash,
1193 GNUNET_TIME_relative_to_absolute (VPN_TIMEOUT),
1194 &vpn_allocation_cb,
1195 rh);
1196 return;
1197 } 1202 }
1198 } 1203 }
1199 } 1204 }