char *confbase = "/tmp/meshlink/";
char *name = "test";
-tincremotehost* remotenode = malloc(sizeof(tincremotehost));
+node_t* remotenode = new_node();
char *remotename = "nameofremotenode";
-//TODO: change this, calling a function that returns tincremotehost
+//TODO: change this, calling a function that returns node_t
+remotenode->name = malloc(16);
remotenode->name = remotename;
-remotenode->publickey = NULL;
tinc_setup(confbase, name);
tinc_start(confbase);
bool tinc_stop();
// can be called from any thread
-bool tinc_send_packet(tincremotehost *receiver, const char* buf, unsigned int len) {
+bool tinc_send_packet(node_t *receiver, const char* buf, unsigned int len) {
vpn_packet_t packet;
+ tincpackethdr* hdr = malloc(sizeof(tincpackethdr));
+
+ if (sizeof(hdr) + len > MAXSIZE) {
+
+ //log something
+ return false;
+ }
+
+ memcpy(hdr->destination,receiver->name,sizeof(hdr->destination));
+ memcpy(hdr->source,myself->name,sizeof(hdr->source));
packet.priority = 0;
- memcpy(packet.data,buf,len);
+
+ memcpy(packet.data,hdr,sizeof(hdr));
+ memcpy(packet.data+sizeof(hdr),buf,len);
myself->in_packets++;
myself->in_bytes += packet.len;
//It might also be a good idea to add the option of looking up hosts by public
//key (fingerprints) instead of names.
-node_t *tinc_get_host(const char *name);
+node_t *tinc_get_host(const char *name) {
+
+
+
+};
bool tinc_get_hosts(node_t** hosts);
u_int8_t source[16];
} __attribute__ ((__packed__)) tincpackethdr;
-typedef struct tincremotehost {
- char *name;
- char *publickey;
-
-} tincremotehost;
-
// can be called from any thread
-bool tinc_send_packet(tincremotehost *receiver, const char* buf, unsigned int len);
+bool tinc_send_packet(node_t *receiver, const char* buf, unsigned int len);
// handler runs in tinc thread and should return immediately
bool tinc_set_packet_receive_handler(void (*handler)(const char* sender, const char* buf, unsigned int len));