Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <inttypes.h>
00010 #include <pthread.h>
00011
00012
00013 #include "tun.h"
00014 #include "receiver.h"
00015
00016 #include <ibrdtn/api/dtn_api.h>
00017
00018
00019
00020 static char devname[256];
00021 static int tun_fd=-1;
00022
00023 void bundle_received(const void *data, uint32_t len) {
00024 printf("Bundle received, %i bytes\n",len);
00025 printf("Data: %s\n",(const char *)data);
00026 }
00027
00028 int main()
00029 {
00030 DTN_EP dtnfd=-1;
00031
00032 pthread_t receiver;
00033
00034 printf("Tunnel\n");
00035 dtn_hithere();
00036 dtnfd=dtn_register_endpoint("test",bundle_received, NULL);
00037
00038 printf("Got dtnfd %i\n",dtnfd);
00039
00040
00041
00042 strncpy(devname,"ibrdtn0",256);
00043 tun_fd=tun_create(devname);
00044 printf("Got %i\n",tun_fd);
00045 tun_conf_ipv4(devname, "172.16.0.1","172.16.0.2");
00046
00047 pthread_create(&receiver,NULL, receiver_run, (void *) &tun_fd);
00048
00049 while(1) {
00050 sleep(10);
00051 }
00052 return 0;
00053 }