diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-01 12:28:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-01 12:28:08 +0000 |
commit | 9adf180a551d2e4c4cc9bb0932a9f3990b8a1704 (patch) | |
tree | 19594ee8d5df211e06d1fb9bf9671410660c791d /src/conversation/conversation_api.c | |
parent | 3ad907429a4674efe707811c9f03281db388d73a (diff) | |
download | gnunet-9adf180a551d2e4c4cc9bb0932a9f3990b8a1704.tar.gz gnunet-9adf180a551d2e4c4cc9bb0932a9f3990b8a1704.zip |
-fixing misc FTBFS issues
Diffstat (limited to 'src/conversation/conversation_api.c')
-rw-r--r-- | src/conversation/conversation_api.c | 144 |
1 files changed, 77 insertions, 67 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c index cf06e541a..031a69da6 100644 --- a/src/conversation/conversation_api.c +++ b/src/conversation/conversation_api.c | |||
@@ -33,9 +33,10 @@ | |||
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <gnunet/platform.h> | 36 | #include "platform.h" |
37 | #include <gnunet/gnunet_util_lib.h> | 37 | #include "gnunet_util_lib.h" |
38 | #include <gnunet/gnunet_gns_service.h> | 38 | #include "gnunet_dnsparser_lib.h" |
39 | #include "gnunet_gns_service.h" | ||
39 | #include "gnunet_protocols_conversation.h" | 40 | #include "gnunet_protocols_conversation.h" |
40 | #include "gnunet_conversation_service.h" | 41 | #include "gnunet_conversation_service.h" |
41 | 42 | ||
@@ -140,12 +141,10 @@ struct GNUNET_CONVERSATION_Handle | |||
140 | static void | 141 | static void |
141 | setup_gns_txt (struct GNUNET_CONVERSATION_Handle *handle) | 142 | setup_gns_txt (struct GNUNET_CONVERSATION_Handle *handle) |
142 | { | 143 | { |
143 | struct GNUNET_CRYPTO_EccPublicKey zone_pkey; | 144 | struct GNUNET_CRYPTO_EccPublicSignKey zone_pkey; |
144 | struct GNUNET_CRYPTO_EccPrivateKey *zone_key; | 145 | struct GNUNET_CRYPTO_EccPrivateKey *zone_key; |
145 | struct GNUNET_CRYPTO_EccPublicKey peer_pkey; | ||
146 | struct GNUNET_CRYPTO_EccPrivateKey *peer_key; | 146 | struct GNUNET_CRYPTO_EccPrivateKey *peer_key; |
147 | struct GNUNET_NAMESTORE_RecordData rd; | 147 | struct GNUNET_NAMESTORE_RecordData rd; |
148 | struct GNUNET_HashCode hash; | ||
149 | struct GNUNET_PeerIdentity peer; | 148 | struct GNUNET_PeerIdentity peer; |
150 | 149 | ||
151 | char *zone_keyfile; | 150 | char *zone_keyfile; |
@@ -170,22 +169,23 @@ setup_gns_txt (struct GNUNET_CONVERSATION_Handle *handle) | |||
170 | } | 169 | } |
171 | 170 | ||
172 | zone_key = GNUNET_CRYPTO_ecc_key_create_from_file (zone_keyfile); | 171 | zone_key = GNUNET_CRYPTO_ecc_key_create_from_file (zone_keyfile); |
173 | GNUNET_CRYPTO_ecc_key_get_public (zone_key, &zone_pkey); | 172 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (zone_key, &zone_pkey); |
174 | peer_key = GNUNET_CRYPTO_ecc_key_create_from_file (peer_keyfile); | 173 | peer_key = GNUNET_CRYPTO_ecc_key_create_from_file (peer_keyfile); |
175 | GNUNET_CRYPTO_ecc_key_get_public (peer_key, &peer_pkey); | 174 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (peer_key, |
176 | 175 | &peer.public_key); | |
177 | GNUNET_CRYPTO_hash (&peer_pkey, sizeof (peer_pkey), &hash); | ||
178 | |||
179 | peer.hashPubKey = hash; | ||
180 | const char *h = GNUNET_i2s_full (&peer); | 176 | const char *h = GNUNET_i2s_full (&peer); |
181 | 177 | ||
182 | rd.data_size = strlen (h) + 1; | 178 | rd.data_size = strlen (h) + 1; |
183 | rd.data = h; | 179 | rd.data = h; |
184 | rd.record_type = GNUNET_GNS_RECORD_TXT; | 180 | rd.record_type = GNUNET_DNSPARSER_TYPE_TXT; |
185 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 181 | rd.flags = GNUNET_NAMESTORE_RF_NONE; |
186 | 182 | ||
187 | GNUNET_NAMESTORE_record_put_by_authority (handle->namestore, zone_key, | 183 | /* FIXME: continuation? return value? */ |
188 | "conversation", 1, &rd, NULL, NULL); | 184 | GNUNET_NAMESTORE_records_store (handle->namestore, |
185 | zone_key, | ||
186 | "conversation", | ||
187 | 1, &rd, | ||
188 | NULL, NULL); | ||
189 | } | 189 | } |
190 | 190 | ||
191 | /** | 191 | /** |
@@ -219,8 +219,12 @@ check_gns_cb (void *cls, uint32_t rd_count, | |||
219 | static void | 219 | static void |
220 | check_gns (struct GNUNET_CONVERSATION_Handle *h) | 220 | check_gns (struct GNUNET_CONVERSATION_Handle *h) |
221 | { | 221 | { |
222 | GNUNET_GNS_lookup (h->gns, "conversation.gads", GNUNET_GNS_RECORD_TXT, | 222 | GNUNET_GNS_lookup (h->gns, "conversation.gads", |
223 | GNUNET_NO, NULL, &check_gns_cb, (void *) h); | 223 | NULL /* FIXME_ZONE */, |
224 | GNUNET_DNSPARSER_TYPE_TXT, | ||
225 | GNUNET_NO, | ||
226 | NULL, | ||
227 | &check_gns_cb, h); | ||
224 | 228 | ||
225 | return; | 229 | return; |
226 | } | 230 | } |
@@ -238,11 +242,10 @@ check_gns (struct GNUNET_CONVERSATION_Handle *h) | |||
238 | static void | 242 | static void |
239 | receive_message_cb (void *cls, const struct GNUNET_MessageHeader *msg) | 243 | receive_message_cb (void *cls, const struct GNUNET_MessageHeader *msg) |
240 | { | 244 | { |
241 | struct ServerClientAvailableAnswerMessage *avbmsg; | 245 | struct GNUNET_CONVERSATION_Handle *h = cls; |
242 | struct ServerClientSessionInitiateMessage *imsg; | 246 | struct ServerClientSessionInitiateMessage *imsg; |
243 | struct ServerClientSessionRejectMessage *rmsg; | 247 | struct ServerClientSessionRejectMessage *rmsg; |
244 | struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls; | 248 | struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls; |
245 | struct GNUNET_CONVERSATION_Handle *h = (struct GNUNET_CONVERSATION_Handle *) cls; | ||
246 | 249 | ||
247 | if (NULL != msg) | 250 | if (NULL != msg) |
248 | { | 251 | { |
@@ -566,39 +569,37 @@ static void | |||
566 | gns_call_cb (void *cls, uint32_t rd_count, | 569 | gns_call_cb (void *cls, uint32_t rd_count, |
567 | const struct GNUNET_NAMESTORE_RecordData *rd) | 570 | const struct GNUNET_NAMESTORE_RecordData *rd) |
568 | { | 571 | { |
572 | struct GNUNET_CONVERSATION_Handle *handle = cls; | ||
569 | struct GNUNET_PeerIdentity peer; | 573 | struct GNUNET_PeerIdentity peer; |
570 | char hash[104]; | 574 | unsigned int i; |
571 | struct GNUNET_CONVERSATION_Handle *handle = (struct GNUNET_CONVERSATION_Handle *) cls; | ||
572 | int i = 0; | ||
573 | 575 | ||
574 | if (0 == rd_count) | 576 | for (i=0;i<rd_count;i++) |
577 | { | ||
578 | switch (rd[i].record_type) | ||
575 | { | 579 | { |
576 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Lookup failed\n"); | 580 | case GNUNET_DNSPARSER_TYPE_TXT: /* FIXME: use fresh record type for voide... */ |
577 | handle->notification_handler (NULL, handle, NotificationType_NO_PEER, | 581 | if (GNUNET_OK != |
578 | NULL); | 582 | GNUNET_CRYPTO_ecc_public_sign_key_from_string (rd[i].data, |
579 | } | 583 | rd[i].data_size, |
580 | else | 584 | &peer.public_key)) |
581 | { | 585 | { |
582 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Lookup succeeded\n"); | 586 | GNUNET_break_op (0); |
583 | 587 | continue; | |
584 | if (GNUNET_GNS_RECORD_TXT == rd[i].record_type) | 588 | } |
585 | { | 589 | initiate_call (handle, peer); |
586 | memcpy (&hash, rd[i].data, 104); | 590 | return; |
587 | GNUNET_CRYPTO_hash_from_string2 (hash, strlen (hash), | 591 | default: |
588 | &(peer.hashPubKey)); | 592 | break; |
589 | |||
590 | initiate_call (handle, peer); | ||
591 | } | ||
592 | else | ||
593 | { | ||
594 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n"); | ||
595 | handle->notification_handler (NULL, handle, | ||
596 | NotificationType_NO_PEER, NULL); | ||
597 | } | ||
598 | } | 593 | } |
599 | return; | 594 | } |
595 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
596 | "Lookup failed\n"); | ||
597 | handle->notification_handler (NULL, handle, | ||
598 | NotificationType_NO_PEER, | ||
599 | NULL); | ||
600 | } | 600 | } |
601 | 601 | ||
602 | |||
602 | /** | 603 | /** |
603 | * GNS lookup | 604 | * GNS lookup |
604 | */ | 605 | */ |
@@ -618,12 +619,16 @@ gns_lookup_and_call (struct GNUNET_CONVERSATION_Handle *h, const char *callee) | |||
618 | 619 | ||
619 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Lookup for %s\n", domain); | 620 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Lookup for %s\n", domain); |
620 | 621 | ||
621 | GNUNET_GNS_lookup (h->gns, domain, GNUNET_GNS_RECORD_TXT, GNUNET_NO, NULL, | 622 | GNUNET_GNS_lookup (h->gns, |
623 | domain, | ||
624 | NULL /* FIXME: ZONE! */, | ||
625 | GNUNET_DNSPARSER_TYPE_TXT, | ||
626 | GNUNET_NO, | ||
627 | NULL, | ||
622 | &gns_call_cb, h); | 628 | &gns_call_cb, h); |
623 | |||
624 | return; | ||
625 | } | 629 | } |
626 | 630 | ||
631 | |||
627 | /******************************************************************************/ | 632 | /******************************************************************************/ |
628 | /********************** API CALL DEFINITIONS *************************/ | 633 | /********************** API CALL DEFINITIONS *************************/ |
629 | /******************************************************************************/ | 634 | /******************************************************************************/ |
@@ -696,29 +701,34 @@ GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle) | |||
696 | handle = NULL; | 701 | handle = NULL; |
697 | } | 702 | } |
698 | 703 | ||
704 | |||
699 | void | 705 | void |
700 | GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *h, const char *callee, | 706 | GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *h, |
701 | int doGnsLookup) | 707 | const char *callee, |
708 | int doGnsLookup) | ||
702 | { | 709 | { |
703 | struct GNUNET_PeerIdentity peer; | 710 | struct GNUNET_PeerIdentity peer; |
711 | |||
704 | if (NULL == h || NULL == h->client) | 712 | if (NULL == h || NULL == h->client) |
705 | return; | 713 | return; |
706 | 714 | ||
707 | if (GNUNET_YES == doGnsLookup) | 715 | if (GNUNET_YES == doGnsLookup) |
708 | { | 716 | { |
709 | gns_lookup_and_call (h, callee); | 717 | gns_lookup_and_call (h, callee); |
710 | } | 718 | return; |
711 | else | 719 | } |
712 | { | 720 | if (GNUNET_OK != |
713 | if (GNUNET_OK != | 721 | GNUNET_CRYPTO_ecc_public_sign_key_from_string (callee, |
714 | GNUNET_CRYPTO_hash_from_string2 (callee, strlen (callee), | 722 | strlen (callee), |
715 | &(peer.hashPubKey))) | 723 | &peer.public_key)) |
716 | { | 724 | { |
717 | h->notification_handler (NULL, h, NotificationType_NO_PEER, NULL); | 725 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
718 | } | 726 | _("`%s' is not a valid public key\n"), |
719 | 727 | callee); | |
720 | initiate_call (h, peer); | 728 | h->notification_handler (NULL, h, NotificationType_NO_PEER, NULL); |
721 | } | 729 | return; |
730 | } | ||
731 | initiate_call (h, peer); | ||
722 | } | 732 | } |
723 | 733 | ||
724 | void | 734 | void |