diff options
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 16 | ||||
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 106 | ||||
-rw-r--r-- | src/namestore/namestore_api.c | 4 |
3 files changed, 87 insertions, 39 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 7a671f1b6..d19184999 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -704,7 +704,8 @@ del_monitor (void *cls, | |||
704 | del_qe = GNUNET_NAMESTORE_records_store (ns, | 704 | del_qe = GNUNET_NAMESTORE_records_store (ns, |
705 | &zone_pkey, | 705 | &zone_pkey, |
706 | name, | 706 | name, |
707 | 0, NULL, | 707 | 0, |
708 | NULL, | ||
708 | &del_continuation, | 709 | &del_continuation, |
709 | NULL); | 710 | NULL); |
710 | return; | 711 | return; |
@@ -740,7 +741,8 @@ del_monitor (void *cls, | |||
740 | del_qe = GNUNET_NAMESTORE_records_store (ns, | 741 | del_qe = GNUNET_NAMESTORE_records_store (ns, |
741 | &zone_pkey, | 742 | &zone_pkey, |
742 | name, | 743 | name, |
743 | rd_left, rdx, | 744 | rd_left, |
745 | rdx, | ||
744 | &del_continuation, | 746 | &del_continuation, |
745 | NULL); | 747 | NULL); |
746 | } | 748 | } |
@@ -809,7 +811,9 @@ testservice_task (void *cls, | |||
809 | type = GNUNET_GNSRECORD_typename_to_number (typestring); | 811 | type = GNUNET_GNSRECORD_typename_to_number (typestring); |
810 | if (UINT32_MAX == type) | 812 | if (UINT32_MAX == type) |
811 | { | 813 | { |
812 | fprintf (stderr, _("Unsupported type `%s'\n"), typestring); | 814 | fprintf (stderr, |
815 | _("Unsupported type `%s'\n"), | ||
816 | typestring); | ||
813 | GNUNET_SCHEDULER_shutdown (); | 817 | GNUNET_SCHEDULER_shutdown (); |
814 | ret = 1; | 818 | ret = 1; |
815 | return; | 819 | return; |
@@ -829,7 +833,8 @@ testservice_task (void *cls, | |||
829 | &data, | 833 | &data, |
830 | &data_size)) | 834 | &data_size)) |
831 | { | 835 | { |
832 | fprintf (stderr, _("Value `%s' invalid for record type `%s'\n"), | 836 | fprintf (stderr, |
837 | _("Value `%s' invalid for record type `%s'\n"), | ||
833 | value, | 838 | value, |
834 | typestring); | 839 | typestring); |
835 | GNUNET_SCHEDULER_shutdown (); | 840 | GNUNET_SCHEDULER_shutdown (); |
@@ -845,7 +850,8 @@ testservice_task (void *cls, | |||
845 | ret = 1; | 850 | ret = 1; |
846 | return; | 851 | return; |
847 | } | 852 | } |
848 | if (0 == strcmp (expirationstring, "never")) | 853 | if (0 == strcmp (expirationstring, |
854 | "never")) | ||
849 | { | 855 | { |
850 | etime_abs = GNUNET_TIME_UNIT_FOREVER_ABS; | 856 | etime_abs = GNUNET_TIME_UNIT_FOREVER_ABS; |
851 | etime_is_rel = GNUNET_NO; | 857 | etime_is_rel = GNUNET_NO; |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 3df8a4ddd..593763894 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -830,6 +830,7 @@ handle_record_lookup (void *cls, | |||
830 | struct RecordLookupContext rlc; | 830 | struct RecordLookupContext rlc; |
831 | const char *name_tmp; | 831 | const char *name_tmp; |
832 | char *res_name; | 832 | char *res_name; |
833 | char *conv_name; | ||
833 | uint32_t name_len; | 834 | uint32_t name_len; |
834 | size_t src_size; | 835 | size_t src_size; |
835 | size_t res_size; | 836 | size_t res_size; |
@@ -857,32 +858,47 @@ handle_record_lookup (void *cls, | |||
857 | if ('\0' != name_tmp[name_len -1]) | 858 | if ('\0' != name_tmp[name_len -1]) |
858 | { | 859 | { |
859 | GNUNET_break (0); | 860 | GNUNET_break (0); |
860 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 861 | GNUNET_SERVER_receive_done (client, |
862 | GNUNET_SYSERR); | ||
861 | return; | 863 | return; |
862 | } | 864 | } |
863 | 865 | ||
864 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 866 | GNUNET_SERVER_receive_done (client, |
867 | GNUNET_OK); | ||
865 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
866 | "Received `%s' message for name `%s'\n", | 869 | "Received NAMESTORE_RECORD_LOOKUP message for name `%s'\n", |
867 | "NAMESTORE_RECORD_LOOKUP", name_tmp); | 870 | name_tmp); |
868 | 871 | ||
869 | if (NULL == (client_lookup (client))) | 872 | if (NULL == (client_lookup (client))) |
870 | { | 873 | { |
871 | GNUNET_break (0); | 874 | GNUNET_break (0); |
872 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 875 | GNUNET_SERVER_receive_done (client, |
876 | GNUNET_SYSERR); | ||
873 | return; | 877 | return; |
874 | } | 878 | } |
875 | 879 | ||
876 | rlc.label = name_tmp; | 880 | conv_name = GNUNET_GNSRECORD_string_to_lowercase (name_tmp); |
881 | if (NULL == conv_name) | ||
882 | { | ||
883 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
884 | "Error converting name `%s'\n", | ||
885 | name_tmp); | ||
886 | GNUNET_SERVER_receive_done (client, | ||
887 | GNUNET_SYSERR); | ||
888 | return; | ||
889 | } | ||
890 | rlc.label = conv_name; | ||
877 | rlc.found = GNUNET_NO; | 891 | rlc.found = GNUNET_NO; |
878 | rlc.res_rd_count = 0; | 892 | rlc.res_rd_count = 0; |
879 | rlc.res_rd = NULL; | 893 | rlc.res_rd = NULL; |
880 | rlc.rd_ser_len = 0; | 894 | rlc.rd_ser_len = 0; |
881 | rlc.nick = get_nick_record (&ll_msg->zone); | 895 | rlc.nick = get_nick_record (&ll_msg->zone); |
882 | |||
883 | res = GSN_database->lookup_records (GSN_database->cls, | 896 | res = GSN_database->lookup_records (GSN_database->cls, |
884 | &ll_msg->zone, name_tmp, &lookup_it, &rlc); | 897 | &ll_msg->zone, |
885 | 898 | conv_name, | |
899 | &lookup_it, | ||
900 | &rlc); | ||
901 | GNUNET_free (conv_name); | ||
886 | res_size = sizeof (struct LabelLookupResponseMessage) + name_len + rlc.rd_ser_len; | 902 | res_size = sizeof (struct LabelLookupResponseMessage) + name_len + rlc.rd_ser_len; |
887 | llr_msg = GNUNET_malloc (res_size); | 903 | llr_msg = GNUNET_malloc (res_size); |
888 | llr_msg->gns_header.header.size = htons (res_size); | 904 | llr_msg->gns_header.header.size = htons (res_size); |
@@ -897,11 +913,16 @@ handle_record_lookup (void *cls, | |||
897 | llr_msg->found = ntohs (GNUNET_YES); | 913 | llr_msg->found = ntohs (GNUNET_YES); |
898 | else | 914 | else |
899 | llr_msg->found = ntohs (GNUNET_NO); | 915 | llr_msg->found = ntohs (GNUNET_NO); |
900 | GNUNET_memcpy (&llr_msg[1], name_tmp, name_len); | 916 | GNUNET_memcpy (&llr_msg[1], |
901 | GNUNET_memcpy (&res_name[name_len], rlc.res_rd, rlc.rd_ser_len); | 917 | name_tmp, |
902 | 918 | name_len); | |
903 | GNUNET_SERVER_notification_context_unicast (snc, client, &llr_msg->gns_header.header, | 919 | GNUNET_memcpy (&res_name[name_len], |
904 | GNUNET_NO); | 920 | rlc.res_rd, |
921 | rlc.rd_ser_len); | ||
922 | GNUNET_SERVER_notification_context_unicast (snc, | ||
923 | client, | ||
924 | &llr_msg->gns_header.header, | ||
925 | GNUNET_NO); | ||
905 | 926 | ||
906 | GNUNET_free_non_null (rlc.res_rd); | 927 | GNUNET_free_non_null (rlc.res_rd); |
907 | GNUNET_free (llr_msg); | 928 | GNUNET_free (llr_msg); |
@@ -935,8 +956,7 @@ handle_record_store (void *cls, | |||
935 | struct ZoneMonitor *zm; | 956 | struct ZoneMonitor *zm; |
936 | 957 | ||
937 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 958 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
938 | "Received `%s' message\n", | 959 | "Received NAMESTORE_RECORD_STORE message\n"); |
939 | "NAMESTORE_RECORD_STORE"); | ||
940 | if (ntohs (message->size) < sizeof (struct RecordStoreMessage)) | 960 | if (ntohs (message->size) < sizeof (struct RecordStoreMessage)) |
941 | { | 961 | { |
942 | GNUNET_break (0); | 962 | GNUNET_break (0); |
@@ -954,13 +974,15 @@ handle_record_store (void *cls, | |||
954 | if (msg_size != msg_size_exp) | 974 | if (msg_size != msg_size_exp) |
955 | { | 975 | { |
956 | GNUNET_break (0); | 976 | GNUNET_break (0); |
957 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 977 | GNUNET_SERVER_receive_done (client, |
978 | GNUNET_SYSERR); | ||
958 | return; | 979 | return; |
959 | } | 980 | } |
960 | if ((0 == name_len) || (name_len > MAX_NAME_LEN)) | 981 | if ((0 == name_len) || (name_len > MAX_NAME_LEN)) |
961 | { | 982 | { |
962 | GNUNET_break (0); | 983 | GNUNET_break (0); |
963 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 984 | GNUNET_SERVER_receive_done (client, |
985 | GNUNET_SYSERR); | ||
964 | return; | 986 | return; |
965 | } | 987 | } |
966 | name_tmp = (const char *) &rp_msg[1]; | 988 | name_tmp = (const char *) &rp_msg[1]; |
@@ -968,7 +990,8 @@ handle_record_store (void *cls, | |||
968 | if ('\0' != name_tmp[name_len -1]) | 990 | if ('\0' != name_tmp[name_len -1]) |
969 | { | 991 | { |
970 | GNUNET_break (0); | 992 | GNUNET_break (0); |
971 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 993 | GNUNET_SERVER_receive_done (client, |
994 | GNUNET_SYSERR); | ||
972 | return; | 995 | return; |
973 | } | 996 | } |
974 | (void) client_lookup (client); | 997 | (void) client_lookup (client); |
@@ -976,21 +999,26 @@ handle_record_store (void *cls, | |||
976 | struct GNUNET_GNSRECORD_Data rd[rd_count]; | 999 | struct GNUNET_GNSRECORD_Data rd[rd_count]; |
977 | 1000 | ||
978 | if (GNUNET_OK != | 1001 | if (GNUNET_OK != |
979 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, rd_ser, rd_count, rd)) | 1002 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, |
1003 | rd_ser, | ||
1004 | rd_count, | ||
1005 | rd)) | ||
980 | { | 1006 | { |
981 | GNUNET_break (0); | 1007 | GNUNET_break (0); |
982 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1008 | GNUNET_SERVER_receive_done (client, |
1009 | GNUNET_SYSERR); | ||
983 | return; | 1010 | return; |
984 | } | 1011 | } |
985 | 1012 | ||
986 | /* Extracting and converting private key */ | 1013 | /* Extracting and converting private key */ |
987 | GNUNET_CRYPTO_ecdsa_key_get_public (&rp_msg->private_key, | 1014 | GNUNET_CRYPTO_ecdsa_key_get_public (&rp_msg->private_key, |
988 | &pubkey); | 1015 | &pubkey); |
989 | conv_name = GNUNET_GNSRECORD_string_to_lowercase (name_tmp); | 1016 | conv_name = GNUNET_GNSRECORD_string_to_lowercase (name_tmp); |
990 | if (NULL == conv_name) | 1017 | if (NULL == conv_name) |
991 | { | 1018 | { |
992 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1019 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
993 | "Error converting name `%s'\n", name_tmp); | 1020 | "Error converting name `%s'\n", |
1021 | name_tmp); | ||
994 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1022 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
995 | return; | 1023 | return; |
996 | } | 1024 | } |
@@ -1003,7 +1031,10 @@ handle_record_store (void *cls, | |||
1003 | if ( (0 == rd_count) && | 1031 | if ( (0 == rd_count) && |
1004 | (GNUNET_NO == | 1032 | (GNUNET_NO == |
1005 | GSN_database->iterate_records (GSN_database->cls, | 1033 | GSN_database->iterate_records (GSN_database->cls, |
1006 | &rp_msg->private_key, 0, NULL, 0)) ) | 1034 | &rp_msg->private_key, |
1035 | 0, | ||
1036 | NULL, | ||
1037 | 0)) ) | ||
1007 | { | 1038 | { |
1008 | /* This name does not exist, so cannot be removed */ | 1039 | /* This name does not exist, so cannot be removed */ |
1009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1040 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1030,7 +1061,8 @@ handle_record_store (void *cls, | |||
1030 | res = GSN_database->store_records (GSN_database->cls, | 1061 | res = GSN_database->store_records (GSN_database->cls, |
1031 | &rp_msg->private_key, | 1062 | &rp_msg->private_key, |
1032 | conv_name, | 1063 | conv_name, |
1033 | rd_clean_off, rd_clean); | 1064 | rd_clean_off, |
1065 | rd_clean); | ||
1034 | if (GNUNET_OK == res) | 1066 | if (GNUNET_OK == res) |
1035 | { | 1067 | { |
1036 | for (zm = monitor_head; NULL != zm; zm = zm->next) | 1068 | for (zm = monitor_head; NULL != zm; zm = zm->next) |
@@ -1072,14 +1104,18 @@ handle_record_store (void *cls, | |||
1072 | &rp_msg->private_key, | 1104 | &rp_msg->private_key, |
1073 | conv_name, | 1105 | conv_name, |
1074 | rd_count, rd); | 1106 | rd_count, rd); |
1075 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1107 | GNUNET_SERVER_receive_done (client, |
1108 | GNUNET_OK); | ||
1076 | GNUNET_free (conv_name); | 1109 | GNUNET_free (conv_name); |
1077 | return; | 1110 | return; |
1078 | } | 1111 | } |
1079 | GNUNET_free (conv_name); | 1112 | GNUNET_free (conv_name); |
1080 | } | 1113 | } |
1081 | send_store_response (client, res, rid); | 1114 | send_store_response (client, |
1082 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1115 | res, |
1116 | rid); | ||
1117 | GNUNET_SERVER_receive_done (client, | ||
1118 | GNUNET_OK); | ||
1083 | } | 1119 | } |
1084 | 1120 | ||
1085 | 1121 | ||
@@ -1671,12 +1707,18 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1671 | namecache = GNUNET_NAMECACHE_connect (cfg); | 1707 | namecache = GNUNET_NAMECACHE_connect (cfg); |
1672 | /* Loading database plugin */ | 1708 | /* Loading database plugin */ |
1673 | if (GNUNET_OK != | 1709 | if (GNUNET_OK != |
1674 | GNUNET_CONFIGURATION_get_value_string (cfg, "namestore", "database", | 1710 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1711 | "namestore", | ||
1712 | "database", | ||
1675 | &database)) | 1713 | &database)) |
1676 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); | 1714 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1715 | "No database backend configured\n"); | ||
1677 | 1716 | ||
1678 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", database); | 1717 | GNUNET_asprintf (&db_lib_name, |
1679 | GSN_database = GNUNET_PLUGIN_load (db_lib_name, (void *) GSN_cfg); | 1718 | "libgnunet_plugin_namestore_%s", |
1719 | database); | ||
1720 | GSN_database = GNUNET_PLUGIN_load (db_lib_name, | ||
1721 | (void *) GSN_cfg); | ||
1680 | GNUNET_free (database); | 1722 | GNUNET_free (database); |
1681 | if (NULL == GSN_database) | 1723 | if (NULL == GSN_database) |
1682 | { | 1724 | { |
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 6dc0df6fd..fd232de81 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -1026,8 +1026,8 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h, | |||
1026 | 1026 | ||
1027 | name_tmp = (char *) &msg[1]; | 1027 | name_tmp = (char *) &msg[1]; |
1028 | GNUNET_memcpy (name_tmp, | 1028 | GNUNET_memcpy (name_tmp, |
1029 | label, | 1029 | label, |
1030 | name_len); | 1030 | name_len); |
1031 | rd_ser = &name_tmp[name_len]; | 1031 | rd_ser = &name_tmp[name_len]; |
1032 | GNUNET_assert (rd_ser_len == | 1032 | GNUNET_assert (rd_ser_len == |
1033 | GNUNET_GNSRECORD_records_serialize (rd_count, | 1033 | GNUNET_GNSRECORD_records_serialize (rd_count, |