* Set of handlers used for processing incoming messages in the tunnels
*/
const struct GNUNET_MESH_MessageHandler *message_handlers;
+ int n_handlers;
/**
* Set of applications that should be claimed to be offered at this node.
* client application.
*/
const GNUNET_MESH_ApplicationType *applications;
+ int n_applications;
/**
* Double linked list of the tunnels this client is connected to.
};
struct GNUNET_MESH_TransmitHandle {
-
+ // TODO
};
const struct GNUNET_MESH_MessageHandler *handlers,
const GNUNET_MESH_ApplicationType *stypes) {
struct GNUNET_MESH_Handle *h;
+ size_t size;
h = GNUNET_malloc(sizeof(struct GNUNET_MESH_Handle));
+
h->cleaner = cleaner;
h->mesh = GNUNET_CLIENT_connect("mesh", cfg);
+ if(h->mesh == NULL) {
+ GNUNET_free(h);
+ return NULL;
+ }
h->cls = cls;
h->message_handlers = handlers;
h->applications = stypes;
+ for(h->n_handlers = 0; handlers[h->n_handlers].type; h->n_handlers++);
+ for(h->n_applications = 0; stypes[h->n_applications]; h->n_applications++);
+ h->n_handlers--;
+ h->n_applications--;
+
+ size = sizeof(struct GNUNET_MESH_ClientConnect);
+ size += h->n_handlers * sizeof(uint16_t);
+ size += h->n_applications * sizeof(GNUNET_MESH_ApplicationType);
+
GNUNET_CLIENT_notify_transmit_ready(h->mesh,
- sizeof(int),
+ size,
GNUNET_TIME_relative_get_forever(),
GNUNET_YES,
&send_connect_packet,
- (void *)h
- );
+ (void *)h);
return h;
}
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_mesh_service_new.h"
+
+static struct GNUNET_MESH_MessageHandler handlers[] = {
+ {NULL, 0, 0}
+};
+
int main (int argc, char *argv[]) {
- return 0;
+ struct GNUNET_OS_Process *arm_pid;
+ struct GNUNET_MESH_Handle *mesh;
+// struct GNUNET_MESH_Tunnel *t;
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ cfg = GNUNET_CONFIGURATION_create();
+
+ arm_pid = GNUNET_OS_start_process (NULL, NULL,
+ "gnunet-service-arm",
+ "gnunet-service-arm",
+ "-L", "DEBUG",
+ NULL);
+ mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, NULL);
+ if(NULL == mesh) {
+ fprintf(stderr, "Couldn't connect to mesh :(\n");
+// return 1; // succeed anyway
+ }
+ mesh = realloc(mesh, 0); // don't complain about *mesh
+// printf("MESH TEST\n");
+// t = GNUNET_MESH_tunnel_create(mesh, );
+
+ /* do real test work here */
+ if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
+ GNUNET_OS_process_close (arm_pid);
+
+ return 0;
}