gnunet_transport_wlan_helper_SOURCES = \
gnunet-transport-wlan-helper.c
gnunet_transport_wlan_helper_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
-lpcap
test_plugin_transport_wlan_SOURCES = \
$(HTTP_API_TEST) \
$(HTTPS_PLUGIN_TEST) \
$(HTTPS_API_TEST) \
+ test_transport_api_wlan \
test_transport_api_multi \
test_transport_api_reliability_tcp \
test_transport_api_reliability_tcp_nat \
$(HTTP_API_TEST) \
$(HTTPS_PLUGIN_TEST) \
$(HTTPS_API_TEST) \
+ test_transport_api_wlan \
test_transport_api_multi \
test_transport_api_reliability_tcp \
test_transport_api_reliability_tcp_nat \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_transport_api_wlan_SOURCES = \
+ test_transport_api.c
+test_transport_api_wlan_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
test_quota_compliance_tcp_SOURCES = \
test_quota_compliance.c
test_quota_compliance_tcp_LDADD = \
test_transport_api_http_peer2.conf \
test_transport_api_https_peer1.conf \
test_transport_api_https_peer2.conf \
+ test_transport_api_wlan_peer1.conf \
+ test_transport_api_wlan_peer2.conf \
test_transport_api_multi_peer1.conf \
test_transport_api_multi_peer2.conf \
test_transport_api_rel_http_peer1.conf \
* This program serves as the mediator between the wlan interface and
* gnunet
*/
-#include "gnunet-transport-wlan-helper.h"
+
+
+#include "platform.h"
+#include "gnunet_constants.h"
+#include "gnunet_os_lib.h"
+#include "gnunet_transport_plugin.h"
+#include "transport.h"
#include "plugin_transport_wlan.h"
+#include "gnunet_common.h"
+#include "gnunet-transport-wlan-helper.h"
#include "ieee80211_radiotap.h"
-
#include <pcap.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+
return -ENOENT;
}
+#define FIFO_FILE1 "MYFIFOin"
+#define FIFO_FILE2 "MYFIFOout"
+#define MAXLINE 5000
+
+int closeprog = 0;
+
+void sigfunc(int sig)
+{
+
+ if(sig != SIGINT || sig != SIGTERM || sig != SIGKILL)
+ return;
+ else
+ {
+ closeprog = 1;
+ }
+}
+
+
+
+int
+testmode(int argc, char *argv[])
+{
+ struct stat st;
+ int erg;
+ int first;
+ FILE *fpin;
+ FILE *fpout;
+ pid_t pid;
+
+ signal(SIGINT,sigfunc);
+ signal(SIGTERM,sigfunc);
+ signal(SIGKILL,sigfunc);
+
+ //make the fifos if needed
+ if (stat(FIFO_FILE1, &st) != 0)
+ {
+ if (stat(FIFO_FILE2, &st) != 0)
+ {
+ perror("FIFO 2 exists, but FIFO 1 not");
+ exit(1);
+ }
+ first = 1;
+ umask(0);
+ erg = mknod(FIFO_FILE1, S_IFIFO | 0666, 0);
+ erg = mknod(FIFO_FILE2, S_IFIFO | 0666, 0);
+
+ if ((fpin = fopen(FIFO_FILE1, "r")) == NULL)
+ {
+ perror("fopen");
+ exit(1);
+ }
+ if ((fpout = fopen(FIFO_FILE2, "w")) == NULL)
+ {
+ perror("fopen");
+ exit(1);
+ }
+ }
+ else
+ {
+ first = 0;
+ if (stat(FIFO_FILE2, &st) == 0)
+ {
+ perror("FIFO 1 exists, but FIFO 2 not");
+ exit(1);
+ }
+ if ((fpout = fopen(FIFO_FILE1, "w")) == NULL)
+ {
+ perror("fopen");
+ exit(1);
+ }
+ if ((fpin = fopen(FIFO_FILE2, "r")) == NULL)
+ {
+ perror("fopen");
+ exit(1);
+ }
+
+ }
+
+ // fork
+
+ if ((pid = fork()) < 0)
+ {
+ perror("FORK ERROR");
+
+ //clean up
+ if (first == 1)
+ {
+ unlink(FIFO_FILE1);
+ unlink(FIFO_FILE2);
+ }
+ fclose(fpin);
+ fclose(fpout);
+ return -3;
+ }
+ else if (pid == 0) // CHILD PROCESS
+ {
+ int rv = 0;
+ int readc = 0;
+ int pos = 0;
+ char line[MAXLINE];
+
+ while (closeprog == 0)
+ {
+ readc = 0;
+
+ while (readc < sizeof( struct RadiotapHeader) + sizeof(struct GNUNET_MessageHeader)){
+ if ((rv = read(STDIN_FILENO, line, MAXLINE)) < 0)
+ {
+ perror("READ ERROR FROM STDIN");
+ }
+ readc += rv;
+ }
+
+ pos = 0;
+
+ fwrite(&line[pos], 1, sizeof(struct GNUNET_MessageHeader), fpout);
+
+ pos += sizeof(struct GNUNET_MessageHeader);
+
+ //do not send radiotap header
+ pos += sizeof( struct RadiotapHeader);
+
+ while (pos < readc)
+ {
+ pos += fwrite(&line[pos], 1, readc - pos, fpout);
+ }
+ }
+
+
+ //clean up
+ fclose(fpout);
+ }
+ else // PARENT PROCESS
+ {
+ int rv = 0;
+ ssize_t pos = 0;
+ char line[MAXLINE];
+ struct Wlan_Helper_Control_Message macmsg;
+
+
+ //Send random mac address
+ macmsg.mac.mac[0] = 0x13;
+ macmsg.mac.mac[1] = 0x22;
+ macmsg.mac.mac[2] = 0x33;
+ macmsg.mac.mac[3] = 0x44;
+ macmsg.mac.mac[4] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255);
+ macmsg.mac.mac[5] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255);
+ macmsg.hdr.size = sizeof(struct Wlan_Helper_Control_Message);
+
+ pos = 0;
+ while (pos < sizeof(struct Wlan_Helper_Control_Message))
+ {
+ pos += write(STDOUT_FILENO, &macmsg + pos, sizeof(struct Wlan_Helper_Control_Message) - pos);
+ }
+
+ while (closeprog == 0)
+ {
+ if ((rv = fread(line, 1, MAXLINE, fpin)) < 0)
+ {
+ perror("READ ERROR FROM fpin");
+ }
+
+ pos = 0;
+ while (pos < rv)
+ {
+ pos += write(STDOUT_FILENO, &line[pos], rv - pos);
+ }
+ }
+
+
+ //clean up
+ fclose(fpin);
+
+ if (first == 1)
+ {
+ unlink(FIFO_FILE1);
+ unlink(FIFO_FILE2);
+ }
+ }
+
+ // Write the input to the output
+
+ return (0);
+}
int
main(int argc, char *argv[])
{
+ if ((argc==3) && (strstr(argv[2],"1")))
+ {
+ return testmode(argc, argv);
+ }
+
u8 u8aSendBuffer[500];
char szErrbuf[PCAP_ERRBUF_SIZE];
int nCaptureHeaderLength = 0, n80211HeaderLength = 0, nLinkEncap = 0;
* @return GNUNET_YES if process was started, GNUNET_SYSERR on error
*/
static int
-wlan_transport_start_wlan_helper(struct Plugin *plugin)
+wlan_transport_start_wlan_helper(struct Plugin *plugin, int testmode)
{
plugin->server_stdout = GNUNET_DISK_pipe(GNUNET_YES, GNUNET_NO, GNUNET_YES);
/* Start the server process */
plugin->server_proc = GNUNET_OS_start_process(plugin->server_stdin,
plugin->server_stdout, "gnunet-transport-wlan-helper",
- "gnunet-transport-wlan-helper", plugin->interface, NULL);
+ plugin->interface, testmode, NULL);
if (plugin->server_proc == NULL)
{
#if DEBUG_wlan
}
+/**
+ * Exit point from the plugin.
+ */
+//TODO doxigen
+//FIXME cleanup
+void *
+libgnunet_plugin_transport_wlan_done (void *cls)
+{
+ struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+ struct Plugin *plugin = api->cls;
+
+ GNUNET_assert(cls !=NULL);
+
+ if (plugin->consoltoken != NULL)
+ GNUNET_SERVER_mst_destroy(plugin->consoltoken);
+
+ GNUNET_free_non_null(plugin->interface);
+ GNUNET_free (plugin);
+ GNUNET_free (api);
+ return NULL;
+}
/**
* Entry point for the plugin.
void *
libgnunet_plugin_transport_wlan_init (void *cls)
{
- struct GNUNET_SERVICE_Context *service;
+ //struct GNUNET_SERVICE_Context *service;
struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct Plugin *plugin;
+ int testmode;
GNUNET_assert(cls !=NULL);
- service = GNUNET_SERVICE_start ("transport-wlan", env->cfg);
- if (service == NULL){
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to start service for `%s' transport plugin.\n"),
- "wlan");
- return NULL;
- }
-
+ fprintf(stderr,"HERE");
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
plugin->pendingsessions = 0;
plugin->server_read_task = GNUNET_SCHEDULER_NO_TASK;
plugin->server_write_delay_task = GNUNET_SCHEDULER_NO_TASK;
- wlan_transport_start_wlan_helper(plugin);
+ testmode = GNUNET_NO;
+ if (GNUNET_CONFIGURATION_have_value (env->cfg,
+ "transport-wlan", "TESTMODE"))
+ {
+ testmode = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+ "transport-wlan","TESTMODE");
+ }
+
+ if (GNUNET_CONFIGURATION_have_value (env->cfg,
+ "transport-wlan", "INTERFACE"))
+ {
+ if (GNUNET_CONFIGURATION_get_value_string (env->cfg,
+ "transport-wlan","INTERFACE", &(plugin->interface)) != GNUNET_YES){
+ libgnunet_plugin_transport_wlan_done(plugin);
+ return NULL;
+ }
+ }
+
+ wlan_transport_start_wlan_helper(plugin, testmode);
plugin->consoltoken = GNUNET_SERVER_mst_create(&wlan_process_helper,plugin);
//plugin->sessions = GNUNET_malloc (sizeof (struct Sessionqueue));
return api;
}
-
-/**
- * Exit point from the plugin.
- */
-//TODO doxigen
-//FIXME cleanup
-void *
-libgnunet_plugin_transport_wlan_done (void *cls)
-{
- struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
- struct Plugin *plugin = api->cls;
-
- GNUNET_assert(cls !=NULL);
-
- GNUNET_SERVER_mst_destroy(plugin->consoltoken);
-
- GNUNET_free (plugin);
- GNUNET_free (api);
- return NULL;
-}
-
/* end of plugin_transport_wlan.c */
int\r
main(int argc, char *argv[])\r
{\r
- struct stat st;\r
+ struct stat st,st2;\r
int erg;\r
int first;\r
FILE *fpin;\r
//make the fifos if needed\r
if (stat(FIFO_FILE1, &st) != 0)\r
{\r
- if (stat(FIFO_FILE2, &st) != 0)\r
+ if (stat(FIFO_FILE2, &st2) != 0)\r
{\r
perror("FIFO 2 exists, but FIFO 1 not");\r
exit(1);\r
else\r
{\r
first = 0;\r
- if (stat(FIFO_FILE2, &st) == 0)\r
+ if (stat(FIFO_FILE2, &st2) == 0)\r
{\r
perror("FIFO 1 exists, but FIFO 2 not");\r
exit(1);\r
#include "gnunet_transport_service.h"
#include "transport.h"
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
#define VERBOSE_ARM GNUNET_NO
static int is_multi_protocol;
+static int is_wlan;
+
static GNUNET_SCHEDULER_TaskIdentifier die_task;
static char * key_file_p1;
setup_peer (&p1, "test_transport_api_https_peer1.conf");
setup_peer (&p2, "test_transport_api_https_peer2.conf");
}
+ else if (is_wlan)
+ {
+ setup_peer (&p1, "test_transport_api_wlan_peer1.conf");
+ setup_peer (&p2, "test_transport_api_wlan_peer2.conf");
+ }
GNUNET_assert(p1.th != NULL);
GNUNET_assert(p2.th != NULL);
{
is_http = GNUNET_YES;
}
+ else if (strstr(argv[0], "wlan") != NULL)
+ {
+ is_wlan = GNUNET_YES;
+ }
else if (strstr(argv[0], "multi") != NULL)
{
is_multi_protocol = GNUNET_YES;
}
-
ret = check ();
if (is_multi_protocol)
{
--- /dev/null
+[fs]
+AUTOSTART = NO
+
+[datastore]
+AUTOSTART = NO
+
+[core]
+AUTOSTART = NO
+
+[transport-wlan]
+INTERFACE = wlan0
+TESTMODE = YES
+
+[hostlist]
+HTTP-PROXY =
+SERVERS = http://gnunet.org:8080/
+OPTIONS = -b
+BINARY = gnunet-daemon-hostlist
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+HTTPPORT = 8080
+
+[topology]
+BINARY = gnunet-daemon-topology
+CONFIG = $DEFAULTCONFIG
+FRIENDS = $SERVICEHOME/friends
+TARGET-CONNECTION-COUNT = 16
+AUTOCONNECT = YES
+FRIENDS-ONLY = NO
+MINIMUM-FRIENDS = 0
+
+[transport]
+PLUGINS = wlan
+DEBUG = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+NEIGHBOUR_LIMIT = 50
+BINARY = gnunet-service-transport
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 12365
+UNIXPATH = /tmp/gnunet-p1-service-transport.sock
+#PREFIX = xterm -T transport2 -e gdb --command=cmd --args
+#PREFIX = valgrind --leak-check=full
+#PREFIX = valgrind --tool=massif
+
+[peerinfo]
+TRUST = $SERVICEHOME/data/credit/
+HOSTS = $SERVICEHOME/data/hosts/
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-peerinfo
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 12369
+UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
+
+[resolver]
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-resolver
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 12364
+UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
+
+[statistics]
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-statistics
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 12367
+UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
+
+[arm]
+DEFAULTSERVICES =
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-arm
+#CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 12366
+UNIXPATH = /tmp/gnunet-p1-service-arm.sock
+
+[TESTING]
+WEAKRANDOM = YES
+
+[gnunetd]
+HOSTKEY = $SERVICEHOME/.hostkey
+
+[PATHS]
+SERVICEHOME = /tmp/test-gnunetd-transport-peer-1/
+
+
+[dht]
+AUTOSTART = NO
+
+
--- /dev/null
+[fs]
+AUTOSTART = NO
+
+[datastore]
+AUTOSTART = NO
+
+[core]
+AUTOSTART = NO
+
+[transport-wlan]
+INTERFACE = wlan1
+TESTMODE = YES
+
+[hostlist]
+HTTP-PROXY =
+SERVERS = http://gnunet.org:8080/
+OPTIONS = -b
+BINARY = gnunet-daemon-hostlist
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+HTTPPORT = 8080
+
+[topology]
+BINARY = gnunet-daemon-topology
+CONFIG = $DEFAULTCONFIG
+FRIENDS = $SERVICEHOME/friends
+TARGET-CONNECTION-COUNT = 16
+AUTOCONNECT = YES
+FRIENDS-ONLY = NO
+MINIMUM-FRIENDS = 0
+
+[transport]
+PLUGINS = wlan
+DEBUG = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+NEIGHBOUR_LIMIT = 50
+BINARY = gnunet-service-transport
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 22365
+UNIXPATH = /tmp/gnunet-p2-service-transport.sock
+#PREFIX = xterm -T transport1 -e gdb --command=cmd --args
+#PREFIX = valgrind --leak-check=full
+#PREFIX = valgrind --tool=massif
+
+[peerinfo]
+TRUST = $SERVICEHOME/data/credit/
+HOSTS = $SERVICEHOME/data/hosts/
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-peerinfo
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 22369
+UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
+
+[resolver]
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-resolver
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 22364
+UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
+
+[statistics]
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-statistics
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 22367
+UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
+
+[arm]
+DEFAULTSERVICES =
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-arm
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 22366
+UNIXPATH = /tmp/gnunet-p2-service-arm.sock
+
+[TESTING]
+WEAKRANDOM = YES
+
+[gnunetd]
+HOSTKEY = $SERVICEHOME/.hostkey
+
+[PATHS]
+SERVICEHOME = /tmp/test-gnunetd-transport-peer-2/
+
+
+[dht]
+AUTOSTART = NO
+
+