fix more leaks
[oweals/gnunet.git] / src / transport / plugin_transport_template.c
index 8c15f877848c8c8121296c4ab33bc8aadb4a3739..dedc8e85789542868cdb4e213d790f09f6de1051 100644 (file)
  */
 
 #include "platform.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_protocols.h"
-#include "gnunet_connection_lib.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_service_lib.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet_transport_service.h"
 #include "gnunet_transport_plugin.h"
 
-#define DEBUG_TEMPLATE GNUNET_EXTRA_LOGGING
+#define LOG(kind,...) GNUNET_log_from (kind, "transport-template",__VA_ARGS__)
 
 /**
  * After how long do we expire an address that we
@@ -42,6 +40,7 @@
  */
 #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
 
+#define PLUGIN_NAME "template"
 
 /**
  * Encapsulation of all of the state of the plugin.
@@ -106,6 +105,20 @@ struct Session
 
 };
 
+GNUNET_NETWORK_STRUCT_BEGIN
+
+struct TemplateAddress
+{
+       /**
+        * Address options in NBO
+        */
+       uint32_t options GNUNET_PACKED;
+
+       /* Add address here */
+};
+
+GNUNET_NETWORK_STRUCT_END
+
 /**
  * Encapsulation of all of the state of the plugin.
  */
@@ -121,6 +134,10 @@ struct Plugin
    */
   struct Session *sessions;
 
+  /**
+   * Options in HBO to be used with addresses
+   */
+
 };
 
 
@@ -187,6 +204,22 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
 }
 
 
+/**
+ * Function obtain the network type for a session
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param session the session
+ * @return the network type in HBO or GNUNET_SYSERR
+ */
+static enum GNUNET_ATS_Network_Type
+template_plugin_get_network (void *cls,
+                            struct Session *session)
+{
+  GNUNET_assert (NULL != session);
+  return GNUNET_ATS_NET_UNSPECIFIED; /* Change to correct network type */
+}
+
+
 /**
  * Convert the transports address to a nice, human-readable
  * format.
@@ -209,6 +242,11 @@ template_plugin_address_pretty_printer (void *cls, const char *type,
                                         GNUNET_TRANSPORT_AddressStringCallback
                                         asc, void *asc_cls)
 {
+       if (0 == addrlen)
+       {
+               asc (asc_cls, TRANSPORT_SESSION_INBOUND_STRING);
+       }
+
   asc (asc_cls, NULL);
 }
 
@@ -231,8 +269,7 @@ template_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
 {
   /* struct Plugin *plugin = cls; */
 
-  /* check if the address is plausible; if so,
-   * add it to our list! */
+  /* check if the address is belonging to the plugin*/
   return GNUNET_OK;
 }
 
@@ -251,6 +288,15 @@ template_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
 static const char *
 template_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
 {
+       /*
+        * Print address in format template.options.address
+        */
+
+       if (0 == addrlen)
+       {
+               return TRANSPORT_SESSION_INBOUND_STRING;
+       }
+
   GNUNET_break (0);
   return NULL;
 }
@@ -272,6 +318,12 @@ static int
 template_plugin_string_to_address (void *cls, const char *addr, uint16_t addrlen,
     void **buf, size_t *added)
 {
+
+       /*
+        * Parse string in format template.options.address
+        */
+
+
   GNUNET_break (0);
   return GNUNET_SYSERR;
 }
@@ -298,7 +350,7 @@ template_plugin_get_session (void *cls,
  * Entry point for the plugin.
  */
 void *
-gnunet_plugin_transport_template_init (void *cls)
+libgnunet_plugin_transport_template_init (void *cls)
 {
   struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
   struct GNUNET_TRANSPORT_PluginFunctions *api;
@@ -327,7 +379,8 @@ gnunet_plugin_transport_template_init (void *cls)
   api->address_to_string = &template_plugin_address_to_string;
   api->string_to_address = &template_plugin_string_to_address;
   api->get_session = &template_plugin_get_session;
-
+  api->get_network = &template_plugin_get_network;
+  LOG (GNUNET_ERROR_TYPE_INFO, "Template plugin successfully loaded\n");
   return api;
 }
 
@@ -336,7 +389,7 @@ gnunet_plugin_transport_template_init (void *cls)
  * Exit point from the plugin.
  */
 void *
-gnunet_plugin_transport_template_done (void *cls)
+libgnunet_plugin_transport_template_done (void *cls)
 {
   struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
   struct Plugin *plugin = api->cls;