diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-06-29 08:24:25 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-06-29 08:24:25 +0000 |
commit | ecfbbfc341c5c49d23b468f84efa1d7fa5706261 (patch) | |
tree | 89e8ce70505777fad936c1fb41d414c741886a61 | |
parent | 0beed5ba03f1a29dbc27c62a063ca51dbe625663 (diff) | |
download | gnunet-ecfbbfc341c5c49d23b468f84efa1d7fa5706261.tar.gz gnunet-ecfbbfc341c5c49d23b468f84efa1d7fa5706261.zip |
fixing "minor changes" and repair things that obviously never worked
-rw-r--r-- | src/transport/gnunet-service-transport.c | 8 | ||||
-rw-r--r-- | src/transport/plugin_transport_unix.c | 57 |
2 files changed, 26 insertions, 39 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index b96ae6c22..cf7434c32 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -1681,9 +1681,11 @@ a2s (const char *plugin, | |||
1681 | p = find_transport (plugin); | 1681 | p = find_transport (plugin); |
1682 | if ((p == NULL) || (addr_len == 0) || (addr == NULL)) | 1682 | if ((p == NULL) || (addr_len == 0) || (addr == NULL)) |
1683 | return NULL; | 1683 | return NULL; |
1684 | return p->api->address_to_string (p->api->cls, | 1684 | |
1685 | return p->api->address_to_string (NULL, | ||
1685 | addr, | 1686 | addr, |
1686 | addr_len); | 1687 | addr_len); |
1688 | return NULL; | ||
1687 | } | 1689 | } |
1688 | 1690 | ||
1689 | 1691 | ||
@@ -2773,7 +2775,7 @@ plugin_env_session_end (void *cls, | |||
2773 | * provided by the plugin can be reached. | 2775 | * provided by the plugin can be reached. |
2774 | * | 2776 | * |
2775 | * @param cls closure | 2777 | * @param cls closure |
2776 | * @param add_remove YES to add, NO to remove the address | 2778 | * @param add_remove GNUNET_YES to add, GNUNET_NO to remove the address |
2777 | * @param addr one of the addresses of the host, NULL for the last address | 2779 | * @param addr one of the addresses of the host, NULL for the last address |
2778 | * the specific address format depends on the transport | 2780 | * the specific address format depends on the transport |
2779 | * @param addrlen length of the address | 2781 | * @param addrlen length of the address |
@@ -2788,6 +2790,8 @@ plugin_env_notify_address (void *cls, | |||
2788 | struct OwnAddressList *al; | 2790 | struct OwnAddressList *al; |
2789 | struct OwnAddressList *prev; | 2791 | struct OwnAddressList *prev; |
2790 | 2792 | ||
2793 | GNUNET_assert (p->api != NULL); | ||
2794 | |||
2791 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2795 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2792 | (add_remove == GNUNET_YES) | 2796 | (add_remove == GNUNET_YES) |
2793 | ? "Adding `%s':%s to the set of our addresses\n" | 2797 | ? "Adding `%s':%s to the set of our addresses\n" |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 4f10d7270..ad8756ecd 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -1070,41 +1070,27 @@ unix_address_to_string (void *cls, | |||
1070 | const void *addr, | 1070 | const void *addr, |
1071 | size_t addrlen) | 1071 | size_t addrlen) |
1072 | { | 1072 | { |
1073 | static char rbuf[INET6_ADDRSTRLEN + 10]; | 1073 | if ((addr != NULL) && (addrlen > 0)) |
1074 | char buf[INET6_ADDRSTRLEN]; | 1074 | return (const char *) addr; |
1075 | const void *sb; | ||
1076 | struct in_addr a4; | ||
1077 | struct in6_addr a6; | ||
1078 | const struct IPv4UdpAddress *t4; | ||
1079 | const struct IPv6UdpAddress *t6; | ||
1080 | int af; | ||
1081 | uint16_t port; | ||
1082 | |||
1083 | if (addrlen == sizeof (struct IPv6UdpAddress)) | ||
1084 | { | ||
1085 | t6 = addr; | ||
1086 | af = AF_INET6; | ||
1087 | port = ntohs (t6->u6_port); | ||
1088 | memcpy (&a6, &t6->ipv6_addr, sizeof (a6)); | ||
1089 | sb = &a6; | ||
1090 | } | ||
1091 | else if (addrlen == sizeof (struct IPv4UdpAddress)) | ||
1092 | { | ||
1093 | t4 = addr; | ||
1094 | af = AF_INET; | ||
1095 | port = ntohs (t4->u_port); | ||
1096 | memcpy (&a4, &t4->ipv4_addr, sizeof (a4)); | ||
1097 | sb = &a4; | ||
1098 | } | ||
1099 | else | 1075 | else |
1100 | return NULL; | 1076 | return NULL; |
1101 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); | 1077 | } |
1102 | GNUNET_snprintf (rbuf, | 1078 | |
1103 | sizeof (rbuf), | 1079 | /** |
1104 | "%s:%u", | 1080 | * Notify transport service about address |
1105 | buf, | 1081 | * |
1106 | port); | 1082 | * @param cls the plugin |
1107 | return rbuf; | 1083 | * @param tc unused |
1084 | */ | ||
1085 | static void | ||
1086 | address_notification (void *cls, | ||
1087 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1088 | { | ||
1089 | struct Plugin *plugin = cls; | ||
1090 | plugin->env->notify_address(plugin->env->cls, | ||
1091 | GNUNET_YES, | ||
1092 | plugin->unix_socket_path, | ||
1093 | strlen(plugin->unix_socket_path) + 1); | ||
1108 | } | 1094 | } |
1109 | 1095 | ||
1110 | /** | 1096 | /** |
@@ -1157,10 +1143,7 @@ libgnunet_plugin_transport_unix_init (void *cls) | |||
1157 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1143 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1158 | _("Failed to open UNIX sockets\n")); | 1144 | _("Failed to open UNIX sockets\n")); |
1159 | 1145 | ||
1160 | plugin->env->notify_address(plugin->env->cls, | 1146 | GNUNET_SCHEDULER_add_now(address_notification, plugin); |
1161 | GNUNET_YES, | ||
1162 | plugin->unix_socket_path, | ||
1163 | strlen(plugin->unix_socket_path) + 1); | ||
1164 | return api; | 1147 | return api; |
1165 | } | 1148 | } |
1166 | 1149 | ||