projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert to libevent.
[tinc]
/
src
/
net_packet.c
diff --git
a/src/net_packet.c
b/src/net_packet.c
index
d3e25c5
..
bb81081
100644
(file)
--- a/
src/net_packet.c
+++ b/
src/net_packet.c
@@
-1,7
+1,7
@@
/*
net_packet.c -- Handles in- and outgoing VPN packets
/*
net_packet.c -- Handles in- and outgoing VPN packets
- Copyright (C) 1998-2005 Ivo Timmermans
<ivo@tinc-vpn.org>
,
- 2000-200
5
Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 1998-2005 Ivo Timmermans,
+ 2000-200
6
Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-29,14
+29,14
@@
#include <openssl/hmac.h>
#include <zlib.h>
#include <openssl/hmac.h>
#include <zlib.h>
-#include
<lzo1x.h>
+#include
LZO1X_H
#include "avl_tree.h"
#include "conf.h"
#include "connection.h"
#include "device.h"
#include "ethernet.h"
#include "avl_tree.h"
#include "conf.h"
#include "connection.h"
#include "device.h"
#include "ethernet.h"
-#include "event.h"
+#include "
t
event.h"
#include "graph.h"
#include "list.h"
#include "logger.h"
#include "graph.h"
#include "list.h"
#include "logger.h"
@@
-96,11
+96,11
@@
void send_mtu_probe(node_t *n)
send_udppacket(n, &packet);
}
send_udppacket(n, &packet);
}
- n->mtuevent =
xmalloc(sizeof(*n->mtuevent)
);
+ n->mtuevent =
new_tevent(
);
n->mtuevent->handler = (event_handler_t)send_mtu_probe;
n->mtuevent->data = n;
n->mtuevent->time = now + 1;
n->mtuevent->handler = (event_handler_t)send_mtu_probe;
n->mtuevent->data = n;
n->mtuevent->time = now + 1;
- event_add(n->mtuevent);
+
t
event_add(n->mtuevent);
}
void mtu_probe_h(node_t *n, vpn_packet_t *packet) {
}
void mtu_probe_h(node_t *n, vpn_packet_t *packet) {
@@
-285,10
+285,11
@@
void receive_tcppacket(connection_t *c, char *buffer, int len)
receive_packet(c->node, &outpkt);
}
receive_packet(c->node, &outpkt);
}
-static void send_udppacket(node_t *n, vpn_packet_t *
in
pkt)
+static void send_udppacket(node_t *n, vpn_packet_t *
orig
pkt)
{
vpn_packet_t pkt1, pkt2;
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 };
{
vpn_packet_t pkt1, pkt2;
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 };
+ vpn_packet_t *inpkt = origpkt;
int nextpkt = 0;
vpn_packet_t *outpkt;
int origlen;
int nextpkt = 0;
vpn_packet_t *outpkt;
int origlen;
@@
-404,7
+405,7
@@
static void send_udppacket(node_t *n, vpn_packet_t *inpkt)
}
end:
}
end:
-
in
pkt->len = origlen;
+
orig
pkt->len = origlen;
}
/*
}
/*
@@
-457,11
+458,8
@@
void broadcast_packet(const node_t *from, vpn_packet_t *packet)
ifdebug(TRAFFIC) logger(LOG_INFO, _("Broadcasting packet of %d bytes from %s (%s)"),
packet->len, from->name, from->hostname);
ifdebug(TRAFFIC) logger(LOG_INFO, _("Broadcasting packet of %d bytes from %s (%s)"),
packet->len, from->name, from->hostname);
- if(from != myself) {
- if(overwrite_mac)
- memcpy(packet->data, mymac.x, ETH_ALEN);
- write_packet(packet);
- }
+ if(from != myself)
+ send_packet(myself, packet);
for(node = connection_tree->head; node; node = node->next) {
c = node->data;
for(node = connection_tree->head; node; node = node->next) {
c = node->data;
@@
-486,7
+484,7
@@
void flush_queue(node_t *n)
}
}
}
}
-void handle_incoming_vpn_data(int sock)
+void handle_incoming_vpn_data(int sock
, short events, void *data
)
{
vpn_packet_t pkt;
char *hostname;
{
vpn_packet_t pkt;
char *hostname;
@@
-517,3
+515,11
@@
void handle_incoming_vpn_data(int sock)
receive_udppacket(n, &pkt);
}
receive_udppacket(n, &pkt);
}
+
+void handle_device_data(int sock, short events, void *data)
+{
+ vpn_packet_t packet;
+
+ if(read_packet(&packet))
+ route(myself, &packet);
+}