aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_unix.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-25 06:24:01 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-25 06:24:01 +0000
commit8a3016481ba6aeb36de3950a56e641dda53ca544 (patch)
tree0c5468ec6e5d2165ad5931940e0b8439d09398de /src/transport/plugin_transport_unix.c
parentb6d4eeb39fd0cd41df164bd0959f58b08aa45e83 (diff)
downloadgnunet-8a3016481ba6aeb36de3950a56e641dda53ca544.tar.gz
gnunet-8a3016481ba6aeb36de3950a56e641dda53ca544.zip
the big NAT change
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r--src/transport/plugin_transport_unix.c79
1 files changed, 6 insertions, 73 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 835f01611..27187a9d6 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -217,29 +217,6 @@ struct RetrySendContext
217 struct RetryList *retry_list_entry; 217 struct RetryList *retry_list_entry;
218}; 218};
219 219
220/**
221 * Local network addresses (actual unix path follows).
222 */
223struct LocalAddrList
224{
225
226 /**
227 * This is a doubly linked list.
228 */
229 struct LocalAddrList *next;
230
231 /**
232 * This is a doubly linked list.
233 */
234 struct LocalAddrList *prev;
235
236 /**
237 * Number of bytes of the address that follow
238 */
239 size_t size;
240
241};
242
243 220
244/** 221/**
245 * UNIX NAT "Session" 222 * UNIX NAT "Session"
@@ -340,16 +317,6 @@ struct Plugin
340 uint16_t port; 317 uint16_t port;
341 318
342 /** 319 /**
343 * List of our IP addresses.
344 */
345 struct LocalAddrList *lal_head;
346
347 /**
348 * Tail of our IP address list.
349 */
350 struct LocalAddrList *lal_tail;
351
352 /**
353 * FD Read set 320 * FD Read set
354 */ 321 */
355 struct GNUNET_NETWORK_FDSet *rs; 322 struct GNUNET_NETWORK_FDSet *rs;
@@ -763,30 +730,6 @@ unix_plugin_send (void *cls,
763} 730}
764 731
765 732
766static void
767add_to_address_list (struct Plugin *plugin,
768 const void *arg,
769 size_t arg_size)
770{
771 struct LocalAddrList *lal;
772
773 lal = plugin->lal_head;
774 while (NULL != lal)
775 {
776 if ( (lal->size == arg_size) &&
777 (0 == memcmp (&lal[1], arg, arg_size)) )
778 return;
779 lal = lal->next;
780 }
781 lal = GNUNET_malloc (sizeof (struct LocalAddrList) + arg_size);
782 lal->size = arg_size;
783 memcpy (&lal[1], arg, arg_size);
784 GNUNET_CONTAINER_DLL_insert (plugin->lal_head,
785 plugin->lal_tail,
786 lal);
787}
788
789
790/** 733/**
791 * Demultiplexer for UNIX messages 734 * Demultiplexer for UNIX messages
792 * 735 *
@@ -1197,8 +1140,10 @@ libgnunet_plugin_transport_unix_init (void *cls)
1197 plugin = GNUNET_malloc (sizeof (struct Plugin)); 1140 plugin = GNUNET_malloc (sizeof (struct Plugin));
1198 plugin->port = port; 1141 plugin->port = port;
1199 plugin->env = env; 1142 plugin->env = env;
1200 GNUNET_asprintf(&plugin->unix_socket_path, "/tmp/unix-plugin-sock.%d", plugin->port); 1143 GNUNET_asprintf (&plugin->unix_socket_path,
1201 1144 "/tmp/unix-plugin-sock.%d",
1145 plugin->port);
1146
1202 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 1147 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1203 api->cls = plugin; 1148 api->cls = plugin;
1204 1149
@@ -1207,19 +1152,15 @@ libgnunet_plugin_transport_unix_init (void *cls)
1207 api->address_pretty_printer = &unix_plugin_address_pretty_printer; 1152 api->address_pretty_printer = &unix_plugin_address_pretty_printer;
1208 api->address_to_string = &unix_address_to_string; 1153 api->address_to_string = &unix_address_to_string;
1209 api->check_address = &unix_check_address; 1154 api->check_address = &unix_check_address;
1210
1211 add_to_address_list (plugin, plugin->unix_socket_path, strlen(plugin->unix_socket_path) + 1);
1212
1213 sockets_created = unix_transport_server_start (plugin); 1155 sockets_created = unix_transport_server_start (plugin);
1214 if (sockets_created == 0) 1156 if (sockets_created == 0)
1215 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1157 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1216 _("Failed to open UNIX sockets\n")); 1158 _("Failed to open UNIX sockets\n"));
1217 1159
1218 plugin->env->notify_address(plugin->env->cls, 1160 plugin->env->notify_address(plugin->env->cls,
1219 "unix", 1161 GNUNET_YES,
1220 plugin->unix_socket_path, 1162 plugin->unix_socket_path,
1221 strlen(plugin->unix_socket_path) + 1, 1163 strlen(plugin->unix_socket_path) + 1);
1222 GNUNET_TIME_UNIT_FOREVER_REL);
1223 return api; 1164 return api;
1224} 1165}
1225 1166
@@ -1228,18 +1169,10 @@ libgnunet_plugin_transport_unix_done (void *cls)
1228{ 1169{
1229 struct GNUNET_TRANSPORT_PluginFunctions *api = cls; 1170 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
1230 struct Plugin *plugin = api->cls; 1171 struct Plugin *plugin = api->cls;
1231 struct LocalAddrList *lal;
1232 1172
1233 unix_transport_server_stop (plugin); 1173 unix_transport_server_stop (plugin);
1234 1174
1235 GNUNET_NETWORK_fdset_destroy (plugin->rs); 1175 GNUNET_NETWORK_fdset_destroy (plugin->rs);
1236 while (NULL != (lal = plugin->lal_head))
1237 {
1238 GNUNET_CONTAINER_DLL_remove (plugin->lal_head,
1239 plugin->lal_tail,
1240 lal);
1241 GNUNET_free (lal);
1242 }
1243 GNUNET_free (plugin); 1176 GNUNET_free (plugin);
1244 GNUNET_free (api); 1177 GNUNET_free (api);
1245 return NULL; 1178 return NULL;