-add dv_get_network to DV API, improve signature to use 'struct Session *' instead...
authorChristian Grothoff <christian@grothoff.org>
Sat, 13 Jul 2013 15:33:30 +0000 (15:33 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 13 Jul 2013 15:33:30 +0000 (15:33 +0000)
src/dv/plugin_transport_dv.c
src/include/gnunet_transport_plugin.h
src/transport/plugin_transport_bluetooth.c
src/transport/plugin_transport_http_client.c
src/transport/plugin_transport_http_server.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_template.c
src/transport/plugin_transport_udp.c
src/transport/plugin_transport_unix.c
src/transport/plugin_transport_wlan.c

index f094075e847be81d4ee7cc8e3b574cc56bdffe56..8f22246eb2cba44f601033b9b471cc531e237be1 100644 (file)
@@ -634,6 +634,26 @@ dv_plugin_string_to_address (void *cls,
 }
 
 
+
+/**
+ * Function to obtain the network type for a session
+ * FIXME: we should probably look at the network type
+ * used by the next hop here.  Or find some other way
+ * to properly allow ATS-DV resource allocation.
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param session the session
+ * @return the network type
+ */
+static enum GNUNET_ATS_Network_Type 
+dv_get_network (void *cls,
+               struct Session *session)
+{
+  GNUNET_assert (NULL != session);
+  return GNUNET_ATS_NET_UNSPECIFIED;
+}
+
+
 /**
  * Entry point for the plugin.
  */
@@ -670,7 +690,8 @@ libgnunet_plugin_transport_dv_init (void *cls)
   api->check_address = &dv_plugin_check_address;
   api->address_to_string = &dv_plugin_address_to_string;
   api->string_to_address = &dv_plugin_string_to_address;
-  api->get_session = dv_get_session;
+  api->get_session = &dv_get_session;
+  api->get_network = &dv_get_network;
   return api;
 }
 
index 456bd1ada59de34c2d6d9a15b92013eaa752efbd..1579980ea904959a16d095b64ddfcce28cbce5a3 100644 (file)
@@ -497,14 +497,14 @@ typedef int (*GNUNET_TRANSPORT_StringToAddress) (void *cls,
 
 
 /**
- * Function obtain the network type for a session
+ * Function to obtain the network type for a session
  *
  * @param cls closure ('struct Plugin*')
  * @param session the session
  * @return the network type
  */
 typedef enum GNUNET_ATS_Network_Type (*GNUNET_TRANSPORT_GetNetworkType) (void *cls,
-                                                void *session);
+                                                                        struct Session *session);
 
 
 /**
@@ -571,7 +571,6 @@ struct GNUNET_TRANSPORT_PluginFunctions
    */
   GNUNET_TRANSPORT_CreateSession get_session;
 
-
   /**
    * Function to obtain the network type for a session
    */
index 57de3022b8eaf01620a0141769bc7961d60b9f7b..3f432b90ef9175cdcb007066b9d94a4cd0ac022a 100644 (file)
@@ -1024,6 +1024,7 @@ create_macendpoint (struct Plugin *plugin,
   return pos;
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -1032,10 +1033,11 @@ create_macendpoint (struct Plugin *plugin,
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-bluetooth_get_network (void *cls, void *session)
+bluetooth_get_network (void *cls,
+                      struct Session *session)
 {
-       GNUNET_assert (NULL != session);
-       return GNUNET_ATS_NET_BT;
+  GNUNET_assert (NULL != session);
+  return GNUNET_ATS_NET_BT;
 }
 
 
index 8f814b5903a80a657d00d0f9789d13206c8538bd..75daeab71da289a63787799ff21aeee9c4e846db 100644 (file)
@@ -1438,6 +1438,7 @@ client_connect (struct Session *s)
   return res;
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -1446,11 +1447,11 @@ client_connect (struct Session *s)
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-http_client_get_network (void *cls, void *session)
+http_client_get_network (void *cls,
+                        struct Session *session)
 {
-       struct Session *s = (struct Session *) session;
-       GNUNET_assert (NULL != s);
-       return ntohl(s->ats_address_network_type);
+  GNUNET_assert (NULL != session);
+  return ntohl (session->ats_address_network_type);
 }
 
 
index 10ba80a190fdb763d450007414b43b3e44694708..968ee23fa1f0421d69e45229a875011e4f915b8e 100644 (file)
@@ -3021,6 +3021,7 @@ const char *http_plugin_address_to_string (void *cls,
 
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -3029,13 +3030,14 @@ const char *http_plugin_address_to_string (void *cls,
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-http_server_get_network (void *cls, void *session)
+http_server_get_network (void *cls,
+                        struct Session *session)
 {
-       struct Session *s = (struct Session *) session;
-       GNUNET_assert (NULL != s);
-       return ntohl(s->ats_address_network_type);
+  GNUNET_assert (NULL != session);
+  return ntohl (session->ats_address_network_type);
 }
 
+
 /**
  * Entry point for the plugin.
  *
index 85b91ecad2c7a3df27f66b382850a00cc7b54bbb..b124fc618a4e1ac54ef7ac55d96092fb4f4377e0 100644 (file)
@@ -2394,11 +2394,11 @@ stop_session_timeout (struct Session *s)
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-tcp_get_network (void *cls,void *session)
+tcp_get_network (void *cls,
+                struct Session *session)
 {
-       struct Session *s = (struct Session *) session;
-       GNUNET_assert (NULL != session);
-       return ntohl(s->ats_address_network_type);
+  GNUNET_assert (NULL != session);
+  return ntohl (session->ats_address_network_type);
 }
 
 
index bf405dba6fd5e6a0e6a9727adb1c0a0246930a4f..00729050428a312dd66a56e846bb0647a52fd1ac 100644 (file)
@@ -205,6 +205,7 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
   // FIXME
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -213,13 +214,14 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-template_plugin_get_network (void *cls, void *session)
+template_plugin_get_network (void *cls, 
+                            struct Session *session)
 {
-       struct Session *s = (struct Session *) session;
-       GNUNET_assert (NULL != s);
-       return GNUNET_ATS_NET_UNSPECIFIED; /* Change to correct network type */
+  GNUNET_assert (NULL != session);
+  return GNUNET_ATS_NET_UNSPECIFIED; /* Change to correct network type */
 }
 
+
 /**
  * Convert the transports address to a nice, human-readable
  * format.
index 421da9812ca266ec27c56635503bc0333766deb0..4d74e272e9d2ba3d3cf82dd920cf763925defcc8 100644 (file)
@@ -1443,6 +1443,7 @@ session_cmp_it (void *cls,
   return GNUNET_YES;
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -1451,13 +1452,13 @@ session_cmp_it (void *cls,
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-udp_get_network (void *cls, void *session)
+udp_get_network (void *cls, 
+                struct Session *session)
 {
-       struct Session *s = (struct Session *) session;
-
-       return ntohl(s->ats.value);
+  return ntohl (session->ats.value);
 }
 
+
 /**
  * Creates a new outbound session the transport service will use to send data to the
  * peer
index afa19d0e8155727409033475161ea9f6d64a5ae0..88df452235ffac85965a3e23f966212f6475afb0 100644 (file)
@@ -732,6 +732,7 @@ session_timeout (void *cls,
   disconnect_session (s);
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -740,10 +741,11 @@ session_timeout (void *cls,
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-unix_get_network (void *cls, void *session)
+unix_get_network (void *cls, 
+                 struct Session *session)
 {
-       GNUNET_assert (NULL != session);
-       return GNUNET_ATS_NET_LOOPBACK;
+  GNUNET_assert (NULL != session);
+  return GNUNET_ATS_NET_LOOPBACK;
 }
 
 
index 298d5565339edfb9f171ac85f6224ed9769b6036..a376a2642b97828c712909c24ebaf8c36bb23cc2 100644 (file)
@@ -1057,6 +1057,7 @@ create_macendpoint (struct Plugin *plugin,
   return pos;
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -1065,12 +1066,14 @@ create_macendpoint (struct Plugin *plugin,
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-wlan_get_network (void *cls, void *session)
+wlan_get_network (void *cls, 
+                 struct Session *session)
 {
-       GNUNET_assert (NULL != session);
-       return GNUNET_ATS_NET_WLAN;
+  GNUNET_assert (NULL != session);
+  return GNUNET_ATS_NET_WLAN;
 }
 
+
 /**
  * Creates a new outbound session the transport service will use to send data to the
  * peer