aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_unix.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-06-29 08:24:25 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-06-29 08:24:25 +0000
commitecfbbfc341c5c49d23b468f84efa1d7fa5706261 (patch)
tree89e8ce70505777fad936c1fb41d414c741886a61 /src/transport/plugin_transport_unix.c
parent0beed5ba03f1a29dbc27c62a063ca51dbe625663 (diff)
downloadgnunet-ecfbbfc341c5c49d23b468f84efa1d7fa5706261.tar.gz
gnunet-ecfbbfc341c5c49d23b468f84efa1d7fa5706261.zip
fixing "minor changes" and repair things that obviously never worked
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r--src/transport/plugin_transport_unix.c57
1 files changed, 20 insertions, 37 deletions
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 */
1085static void
1086address_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