From: Steinar H. Gunderson Date: Sat, 7 Feb 2015 16:18:47 +0000 (+0100) Subject: Make GREProtocol no longer make its own sequence numbers. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=db5c35411fa6e348da943be860beffec71d304eb;p=greproxy Make GREProtocol no longer make its own sequence numbers. --- diff --git a/greprotocol.cpp b/greprotocol.cpp index 2fb2503..5fd4e4b 100644 --- a/greprotocol.cpp +++ b/greprotocol.cpp @@ -24,7 +24,6 @@ struct gre_header { GREProtocol::GREProtocol(const in6_addr &src, const in6_addr &dst) - : seq(0) { memset(&dstaddr, 0, sizeof(dstaddr)); dstaddr.sin6_family = AF_INET6; @@ -57,7 +56,7 @@ void GREProtocol::send_packet(uint16_t proto, const string &data, int incoming_s gre->protocol_type = htons(proto); char *ptr = buf + sizeof(*gre); - int seq_be = htonl(seq++); // Ignore incoming_seq. + int seq_be = htonl(incoming_seq); memcpy(ptr, &seq_be, sizeof(seq_be)); ptr += sizeof(seq_be); diff --git a/greprotocol.h b/greprotocol.h index fd595b7..739b97e 100644 --- a/greprotocol.h +++ b/greprotocol.h @@ -16,7 +16,6 @@ public: virtual void read_packet(Sender* sender); private: - int seq; int sock; sockaddr_in6 dstaddr; }; diff --git a/tunprotocol.cpp b/tunprotocol.cpp index f8bde7d..7a52362 100644 --- a/tunprotocol.cpp +++ b/tunprotocol.cpp @@ -39,7 +39,7 @@ 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, int incoming_seq) @@ -89,6 +89,6 @@ void TUNProtocol::read_packet(Sender *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), -1); + sender->send_packet(proto, string(ptr, buf + ret), seq++); } diff --git a/tunprotocol.h b/tunprotocol.h index 7f16066..d9f40fa 100644 --- a/tunprotocol.h +++ b/tunprotocol.h @@ -15,6 +15,7 @@ public: private: int tunfd; + int seq; }; #endif // !defined(_TUNPROTOCOL_H)