diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-08-18 15:24:58 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-08-18 15:24:58 +0000 |
commit | af67e292e90dabbe354fdfff3bd4ba994273ce91 (patch) | |
tree | f4ac3efb23a5750d27b2a39e5ab994dcacb0e8df /src/hello/hello.c | |
parent | ab1a779a7136f4ac45adc418feb0fbbacd066751 (diff) | |
download | gnunet-af67e292e90dabbe354fdfff3bd4ba994273ce91.tar.gz gnunet-af67e292e90dabbe354fdfff3bd4ba994273ce91.zip |
doxygen fix
use '+' as separator in hello uris and use ipv6 references delimited with '[' and ']'
Diffstat (limited to 'src/hello/hello.c')
-rw-r--r-- | src/hello/hello.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/src/hello/hello.c b/src/hello/hello.c index 1f9ef0f7e..22da56e88 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c | |||
@@ -732,7 +732,7 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg) | |||
732 | * | 732 | * |
733 | * The concrete URI format is: | 733 | * The concrete URI format is: |
734 | * | 734 | * |
735 | * "gnunet://hello/PEER[!YYYYMMDDHHMMSS!<TYPE>!<ADDRESS>]...". | 735 | * "gnunet://hello/PEER[+YYYYMMDDHHMMSS+<TYPE>+<ADDRESS>]...". |
736 | * These URIs can be used to add a peer record to peerinfo service. | 736 | * These URIs can be used to add a peer record to peerinfo service. |
737 | * PEER is the string representation of peer's public key. | 737 | * PEER is the string representation of peer's public key. |
738 | * YYYYMMDDHHMMSS is the expiration date. | 738 | * YYYYMMDDHHMMSS is the expiration date. |
@@ -744,8 +744,8 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg) | |||
744 | * | 744 | * |
745 | * <TCP|UDP>!IPADDRESS | 745 | * <TCP|UDP>!IPADDRESS |
746 | * IPVDDRESS is either IPV4 .-delimited address in form of XXX.XXX.XXX.XXX:PPPPP | 746 | * IPVDDRESS is either IPV4 .-delimited address in form of XXX.XXX.XXX.XXX:PPPPP |
747 | * or IPV6 :-delimited address, but with '(' and ')' instead of '[' and ']' (RFC2396 advises against using square brackets in URIs): | 747 | * or IPV6 :-delimited address with '[' and ']' (according to RFC2732): |
748 | * (XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX):PPPPP | 748 | * [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:PPPPP |
749 | * PPPPP is the port number. May be 0. | 749 | * PPPPP is the port number. May be 0. |
750 | * | 750 | * |
751 | * </li><li> | 751 | * </li><li> |
@@ -759,8 +759,8 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg) | |||
759 | * | 759 | * |
760 | * Examples: | 760 | * Examples: |
761 | * | 761 | * |
762 | * gnunet://hello/0430205UC7D56PTQK8NV05776671CNN44FK4TL6D0GQ35OMF8MEN4RNMKA5UF6AL3DQO8B1SC5AQF50SQ2MABIRU4HC8H2HAJKJ59JL1JVRJAK308F9GASRFLMGUBB5TQ5AKR94AS5T3MDG8B9O1EMPRKB0HVCG7T6QPP4CDJ913LAEHVJ2DI1TOBB15Q1JIT5ARBOD12U4SIGRFDV3Q7T66G4TBVSJJ90UQF1BG29TGJJKLGEIMSPHHKO544D6EALQ4F2K0416311JC22GVAD48R616I7VK03K7MP7N0RS2MBV1TE9JV8CK1LSQMR7KCDRTLDA6917UGA67DHTGHERIACCGQ54TGSR48RMSGS9BA5HLMOKASFC1I6V4TT09TUGCU8GNDHQF0JF3H7LPV59UL5I38QID040G000!20120302010059!TCP!192.168.0.1:2086!TCP!64.23.8.174:0 | 762 | * gnunet://hello/V8XXK9GAN5ZJFRFQP8MQX3D83BZTSBQVHKWWD0JPE63Z821906EG+20120302010059+TCP+192.168.0.1:2086+TCP+64.23.8.174:0 |
763 | * gnunet://hello/0430205UC7D56PTQK8NV05776671CNN44FK4TL6D0GQ35OMF8MEN4RNMKA5UF6AL3DQO8B1SC5AQF50SQ2MABIRU4HC8H2HAJKJ59JL1JVRJAK308F9GASRFLMGUBB5TQ5AKR94AS5T3MDG8B9O1EMPRKB0HVCG7T6QPP4CDJ913LAEHVJ2DI1TOBB15Q1JIT5ARBOD12U4SIGRFDV3Q7T66G4TBVSJJ90UQF1BG29TGJJKLGEIMSPHHKO544D6EALQ4F2K0416311JC22GVAD48R616I7VK03K7MP7N0RS2MBV1TE9JV8CK1LSQMR7KCDRTLDA6917UGA67DHTGHERIACCGQ54TGSR48RMSGS9BA5HLMOKASFC1I6V4TT09TUGCU8GNDHQF0JF3H7LPV59UL5I38QID040G000!20120302010059!TCP!(2001:db8:85a3:8d3:1319:8a2e:370:7348):2086 | 763 | * gnunet://hello/V8XXK9GAN5ZJFRFQP8MQX3D83BZTSBQVHKWWD0JPE63Z821906EG+20120302010059+TCP+[2001:db8:85a3:8d3:1319:8a2e:370:7348]:2086 |
764 | * | 764 | * |
765 | * <p> | 765 | * <p> |
766 | */ | 766 | */ |
@@ -768,7 +768,7 @@ GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg) | |||
768 | 768 | ||
769 | /* ************************* Compose HELLO URI ************************** */ | 769 | /* ************************* Compose HELLO URI ************************** */ |
770 | 770 | ||
771 | 771 | #if 0 | |
772 | /** | 772 | /** |
773 | * Replace all characters in the input 'in' according | 773 | * Replace all characters in the input 'in' according |
774 | * to the mapping. The mapping says to map each character | 774 | * to the mapping. The mapping says to map each character |
@@ -801,6 +801,7 @@ map_characters (const char *in, | |||
801 | } | 801 | } |
802 | return ret; | 802 | return ret; |
803 | } | 803 | } |
804 | #endif | ||
804 | 805 | ||
805 | 806 | ||
806 | /** | 807 | /** |
@@ -819,7 +820,6 @@ add_address_to_uri (void *cls, const struct GNUNET_HELLO_Address *address, | |||
819 | struct GNUNET_HELLO_ComposeUriContext *ctx = cls; | 820 | struct GNUNET_HELLO_ComposeUriContext *ctx = cls; |
820 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 821 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
821 | const char *addr; | 822 | const char *addr; |
822 | char *uri_addr; | ||
823 | char *ret; | 823 | char *ret; |
824 | char *addr_dup; | 824 | char *addr_dup; |
825 | char *pos; | 825 | char *pos; |
@@ -850,20 +850,19 @@ add_address_to_uri (void *cls, const struct GNUNET_HELLO_Address *address, | |||
850 | if (NULL != (pos = strstr (addr_dup, "_server"))) | 850 | if (NULL != (pos = strstr (addr_dup, "_server"))) |
851 | memcpy (pos, client_str, strlen(client_str)); /* Replace all server addresses with client addresses */ | 851 | memcpy (pos, client_str, strlen(client_str)); /* Replace all server addresses with client addresses */ |
852 | 852 | ||
853 | /* For URIs we use '(' and ')' instead of '[' and ']' as brackets are reserved | ||
854 | characters in URIs */ | ||
855 | uri_addr = map_characters (addr_dup, "[]", "()"); | ||
856 | GNUNET_free (addr_dup); | ||
857 | seconds = expiration.abs_value_us / 1000LL / 1000LL; | 853 | seconds = expiration.abs_value_us / 1000LL / 1000LL; |
858 | t = gmtime (&seconds); | 854 | t = gmtime (&seconds); |
859 | 855 | ||
860 | GNUNET_asprintf (&ret, | 856 | GNUNET_asprintf (&ret, |
861 | "%s!%s!%s!%s", | 857 | "%s%c%s%c%s%c%s", |
862 | ctx->uri, | 858 | ctx->uri, |
859 | GNUNET_HELLO_URI_SEP, | ||
863 | strftime (tbuf, sizeof (tbuf), "%Y%m%d%H%M%S", t) ? tbuf : "0", | 860 | strftime (tbuf, sizeof (tbuf), "%Y%m%d%H%M%S", t) ? tbuf : "0", |
861 | GNUNET_HELLO_URI_SEP, | ||
864 | address->transport_name, | 862 | address->transport_name, |
865 | uri_addr); | 863 | GNUNET_HELLO_URI_SEP, |
866 | GNUNET_free (uri_addr); | 864 | addr_dup); |
865 | GNUNET_free (addr_dup); | ||
867 | GNUNET_free (ctx->uri); | 866 | GNUNET_free (ctx->uri); |
868 | ctx->uri = ret; | 867 | ctx->uri = ret; |
869 | return GNUNET_OK; | 868 | return GNUNET_OK; |
@@ -916,7 +915,6 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
916 | const char *tname; | 915 | const char *tname; |
917 | const char *address; | 916 | const char *address; |
918 | char *uri_address; | 917 | char *uri_address; |
919 | char *plugin_address; | ||
920 | const char *end; | 918 | const char *end; |
921 | char *plugin_name; | 919 | char *plugin_name; |
922 | struct tm expiration_time; | 920 | struct tm expiration_time; |
@@ -931,7 +929,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
931 | 929 | ||
932 | if (NULL == ctx->pos) | 930 | if (NULL == ctx->pos) |
933 | return GNUNET_SYSERR; | 931 | return GNUNET_SYSERR; |
934 | if ('!' != ctx->pos[0]) | 932 | if (GNUNET_HELLO_URI_SEP != ctx->pos[0]) |
935 | { | 933 | { |
936 | ctx->ret = GNUNET_SYSERR; | 934 | ctx->ret = GNUNET_SYSERR; |
937 | GNUNET_break (0); | 935 | GNUNET_break (0); |
@@ -939,7 +937,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
939 | } | 937 | } |
940 | ctx->pos++; | 938 | ctx->pos++; |
941 | 939 | ||
942 | if ('0' == ctx->pos[0] && '!' == ctx->pos[1]) | 940 | if ('0' == ctx->pos[0] && GNUNET_HELLO_URI_SEP == ctx->pos[1]) |
943 | { | 941 | { |
944 | expire = GNUNET_TIME_UNIT_FOREVER_ABS; | 942 | expire = GNUNET_TIME_UNIT_FOREVER_ABS; |
945 | tname = ctx->pos + 1; | 943 | tname = ctx->pos + 1; |
@@ -970,7 +968,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
970 | } | 968 | } |
971 | expire.abs_value_us = expiration_seconds * 1000LL * 1000LL; | 969 | expire.abs_value_us = expiration_seconds * 1000LL * 1000LL; |
972 | } | 970 | } |
973 | if ('!' != tname[0]) | 971 | if (GNUNET_HELLO_URI_SEP != tname[0]) |
974 | { | 972 | { |
975 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 973 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
976 | _("Failed to parse HELLO message: malformed\n")); | 974 | _("Failed to parse HELLO message: malformed\n")); |
@@ -979,7 +977,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
979 | return GNUNET_SYSERR; | 977 | return GNUNET_SYSERR; |
980 | } | 978 | } |
981 | tname++; | 979 | tname++; |
982 | address = strchr (tname, (int) '!'); | 980 | address = strchr (tname, (int) GNUNET_HELLO_URI_SEP); |
983 | if (NULL == address) | 981 | if (NULL == address) |
984 | { | 982 | { |
985 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 983 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -989,7 +987,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
989 | return GNUNET_SYSERR; | 987 | return GNUNET_SYSERR; |
990 | } | 988 | } |
991 | address++; | 989 | address++; |
992 | end = strchr (address, (int) '!'); | 990 | end = strchr (address, (int) GNUNET_HELLO_URI_SEP); |
993 | ctx->pos = end; | 991 | ctx->pos = end; |
994 | ctx->counter_total ++; | 992 | ctx->counter_total ++; |
995 | plugin_name = GNUNET_strndup (tname, address - (tname+1)); | 993 | plugin_name = GNUNET_strndup (tname, address - (tname+1)); |
@@ -1016,26 +1014,22 @@ add_address_to_hello (void *cls, size_t max, void *buffer) | |||
1016 | return 0; | 1014 | return 0; |
1017 | } | 1015 | } |
1018 | uri_address = GNUNET_strndup (address, end - address); | 1016 | uri_address = GNUNET_strndup (address, end - address); |
1019 | /* For URIs we use '(' and ')' instead of '[' and ']' as brackets are reserved | ||
1020 | characters in URIs; need to convert back to '[]' for the plugin */ | ||
1021 | plugin_address = map_characters (uri_address, "()", "[]"); | ||
1022 | GNUNET_free (uri_address); | ||
1023 | if (GNUNET_OK != | 1017 | if (GNUNET_OK != |
1024 | papi->string_to_address (papi->cls, | 1018 | papi->string_to_address (papi->cls, |
1025 | plugin_address, | 1019 | uri_address, |
1026 | strlen (plugin_address) + 1, | 1020 | strlen (uri_address) + 1, |
1027 | &addr, | 1021 | &addr, |
1028 | &addr_len)) | 1022 | &addr_len)) |
1029 | { | 1023 | { |
1030 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1024 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1031 | _("Failed to parse `%s' as an address for plugin `%s'\n"), | 1025 | _("Failed to parse `%s' as an address for plugin `%s'\n"), |
1032 | plugin_address, | 1026 | uri_address, |
1033 | plugin_name); | 1027 | plugin_name); |
1034 | GNUNET_free (plugin_name); | 1028 | GNUNET_free (plugin_name); |
1035 | GNUNET_free (plugin_address); | 1029 | GNUNET_free (uri_address); |
1036 | return 0; | 1030 | return 0; |
1037 | } | 1031 | } |
1038 | GNUNET_free (plugin_address); | 1032 | GNUNET_free (uri_address); |
1039 | /* address.peer is unset - not used by add_address() */ | 1033 | /* address.peer is unset - not used by add_address() */ |
1040 | haddr.address_length = addr_len; | 1034 | haddr.address_length = addr_len; |
1041 | haddr.address = addr; | 1035 | haddr.address = addr; |
@@ -1084,7 +1078,7 @@ GNUNET_HELLO_parse_uri (const char *uri, | |||
1084 | } | 1078 | } |
1085 | else | 1079 | else |
1086 | return GNUNET_SYSERR; | 1080 | return GNUNET_SYSERR; |
1087 | exc = strstr (pks, "!"); | 1081 | exc = strchr (pks, GNUNET_HELLO_URI_SEP); |
1088 | 1082 | ||
1089 | if (GNUNET_OK != | 1083 | if (GNUNET_OK != |
1090 | GNUNET_STRINGS_string_to_data (pks, | 1084 | GNUNET_STRINGS_string_to_data (pks, |