X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=tunprotocol.cpp;h=7a52362c5482ee8e93a7d0cab04038b9faac2c89;hb=3c6c8f4a2bfa4bc729a35c579922e17033309bf3;hp=b8b63a3736f02dfd1d5c84259a97050b59d1e70c;hpb=5b611332f020c9fc94b5992188dd0701fdf4f327;p=greproxy diff --git a/tunprotocol.cpp b/tunprotocol.cpp index b8b63a3..7a52362 100644 --- a/tunprotocol.cpp +++ b/tunprotocol.cpp @@ -1,9 +1,10 @@ -#include #include -#include -#include #include -#include +#include +#include +#include +#include +#include #include #include @@ -38,10 +39,10 @@ int tun_open(const char *name) { } // namespace TUNProtocol::TUNProtocol(const char *devname) - : tunfd(tun_open(devname)) { + : tunfd(tun_open(devname)), seq(0) { } -void TUNProtocol::send_packet(uint16_t proto, const string &data) +void TUNProtocol::send_packet(uint16_t proto, const string &data, int incoming_seq) { char buf[4096]; @@ -68,7 +69,7 @@ int TUNProtocol::fd() const return tunfd; } -void TUNProtocol::read_packet(Protocol *sender) +void TUNProtocol::read_packet(Sender *sender) { char buf[4096]; int ret = read(tunfd, buf, sizeof(buf)); @@ -88,6 +89,6 @@ void TUNProtocol::read_packet(Protocol *sender) ptr += 2; //fprintf(stderr, "tun packet: flags=%x proto=%x len=%d\n", // flags, proto, ret - 4); - sender->send_packet(proto, string(ptr, buf + ret)); + sender->send_packet(proto, string(ptr, buf + ret), seq++); }