diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-08-23 07:29:40 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-08-23 07:29:40 +0000 |
commit | 71e539f5385364cddf51cb56a0859aa68dfc2375 (patch) | |
tree | 0919aa6db2a7394304a7ce82ba25106d750822e1 /src/transport/test_plugin_transport.c | |
parent | 5a5839a733897f3d9f7ae693843bc8b606a4ac13 (diff) | |
download | gnunet-71e539f5385364cddf51cb56a0859aa68dfc2375.tar.gz gnunet-71e539f5385364cddf51cb56a0859aa68dfc2375.zip |
changes to plugin test
Diffstat (limited to 'src/transport/test_plugin_transport.c')
-rw-r--r-- | src/transport/test_plugin_transport.c | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index 55dfb40a1..2cce50622 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_common.h" | ||
28 | #include "gnunet_constants.h" | 29 | #include "gnunet_constants.h" |
29 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_hello_lib.h" | 31 | #include "gnunet_hello_lib.h" |
@@ -82,7 +83,7 @@ static int ok; | |||
82 | /** | 83 | /** |
83 | */ | 84 | */ |
84 | static void | 85 | static void |
85 | receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 86 | env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
86 | const struct GNUNET_MessageHeader *message, uint32_t distance, | 87 | const struct GNUNET_MessageHeader *message, uint32_t distance, |
87 | const char *sender_address, size_t sender_address_len) | 88 | const char *sender_address, size_t sender_address_len) |
88 | { | 89 | { |
@@ -90,11 +91,38 @@ receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
90 | } | 91 | } |
91 | 92 | ||
92 | void | 93 | void |
93 | notify_address (void *cls, const char *name, const void *addr, size_t addrlen, | 94 | env_notify_address (void *cls, const char *name, const void *addr, size_t addrlen, |
94 | struct GNUNET_TIME_Relative expires) | 95 | struct GNUNET_TIME_Relative expires) |
95 | { | 96 | { |
96 | } | 97 | } |
97 | 98 | ||
99 | struct GNUNET_ATS_Information | ||
100 | env_get_address_type (void *cls, | ||
101 | const struct sockaddr *addr, | ||
102 | size_t addrlen) | ||
103 | { | ||
104 | struct GNUNET_ATS_Information ats; | ||
105 | ats.type = htonl (0); | ||
106 | ats.value = htonl (0); | ||
107 | return ats; | ||
108 | } | ||
109 | |||
110 | |||
111 | const struct GNUNET_MessageHeader * | ||
112 | env_get_our_hello (void) | ||
113 | { | ||
114 | GNUNET_break (0); | ||
115 | return NULL; | ||
116 | } | ||
117 | |||
118 | void env_session_end (void *cls, | ||
119 | const struct GNUNET_PeerIdentity *peer, | ||
120 | struct Session * session) | ||
121 | { | ||
122 | |||
123 | } | ||
124 | |||
125 | |||
98 | /** | 126 | /** |
99 | * Function called when the service shuts | 127 | * Function called when the service shuts |
100 | * down. Unloads our plugins. | 128 | * down. Unloads our plugins. |
@@ -161,11 +189,16 @@ static void | |||
161 | setup_plugin_environment () | 189 | setup_plugin_environment () |
162 | { | 190 | { |
163 | env.cfg = cfg; | 191 | env.cfg = cfg; |
164 | env.my_identity = &my_identity; | ||
165 | env.cls = &env; | 192 | env.cls = &env; |
166 | env.receive = &receive; | 193 | env.my_identity = &my_identity; |
167 | env.notify_address = ¬ify_address; | ||
168 | env.max_connections = max_connect_per_transport; | 194 | env.max_connections = max_connect_per_transport; |
195 | env.stats = NULL; | ||
196 | |||
197 | env.receive = &env_receive; | ||
198 | env.notify_address = &env_notify_address; | ||
199 | env.get_address_type = &env_get_address_type; | ||
200 | env.get_our_hello = &env_get_our_hello; | ||
201 | env.session_end = &env_session_end; | ||
169 | } | 202 | } |
170 | 203 | ||
171 | 204 | ||
@@ -179,23 +212,24 @@ static void | |||
179 | run (void *cls, char *const *args, const char *cfgfile, | 212 | run (void *cls, char *const *args, const char *cfgfile, |
180 | const struct GNUNET_CONFIGURATION_Handle *c) | 213 | const struct GNUNET_CONFIGURATION_Handle *c) |
181 | { | 214 | { |
215 | #if 0 | ||
182 | unsigned long long tneigh; | 216 | unsigned long long tneigh; |
183 | char *keyfile; | 217 | char *keyfile; |
184 | char *libname; | 218 | char *libname; |
185 | 219 | ||
186 | cfg = c; | 220 | cfg = c; |
187 | /* parse configuration */ | 221 | /* parse configuration */ |
188 | if ((GNUNET_OK != | 222 | if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, |
189 | GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT", | 223 | "TRANSPORT", |
190 | &tneigh)) || | 224 | "NEIGHBOUR_LIMIT", |
191 | (GNUNET_OK != | 225 | &tneigh)) || |
192 | GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", | 226 | (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, |
193 | &keyfile))) | 227 | "GNUNETD", "HOSTKEY", |
228 | &keyfile))) | ||
194 | { | 229 | { |
195 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 230 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
196 | _ | 231 | _("Transport service is lacking key configuration settings. Exiting.\n")); |
197 | ("Transport service is lacking key configuration settings. Exiting.\n")); | 232 | GNUNET_SCHEDULER_shutdown (); |
198 | GNUNET_SCHEDULER_shutdown (s); | ||
199 | return; | 233 | return; |
200 | } | 234 | } |
201 | max_connect_per_transport = (uint32_t) tneigh; | 235 | max_connect_per_transport = (uint32_t) tneigh; |
@@ -205,15 +239,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
205 | { | 239 | { |
206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 240 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
207 | _("Transport service could not access hostkey. Exiting.\n")); | 241 | _("Transport service could not access hostkey. Exiting.\n")); |
208 | GNUNET_SCHEDULER_shutdown (s); | 242 | GNUNET_SCHEDULER_shutdown (); |
209 | return; | 243 | return; |
210 | } | 244 | } |
211 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); | 245 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); |
212 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), | 246 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), |
213 | &my_identity.hashPubKey); | 247 | &my_identity.hashPubKey); |
214 | 248 | ||
215 | |||
216 | |||
217 | /* load plugins... */ | 249 | /* load plugins... */ |
218 | setup_plugin_environment (); | 250 | setup_plugin_environment (); |
219 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading tcp transport plugin\n")); | 251 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading tcp transport plugin\n")); |
@@ -229,6 +261,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
229 | return; | 261 | return; |
230 | } | 262 | } |
231 | test_validation (); | 263 | test_validation (); |
264 | #endif | ||
232 | } | 265 | } |
233 | 266 | ||
234 | 267 | ||