]> git.sesse.net Git - greproxy/blobdiff - greprotocol.cpp
Make Reorderer into a Protocol.
[greproxy] / greprotocol.cpp
index b826a521d7828c4e18421250f07c8a3ee8d09d9d..4a634156789f0aa3848d8ac1aaf5172a65d0bd4d 100644 (file)
@@ -44,7 +44,7 @@ GREProtocol::GREProtocol(const in6_addr &src, const in6_addr &dst)
        }
 }
 
-void GREProtocol::send_packet(uint16_t proto, const string &data)
+void GREProtocol::send_packet(uint16_t proto, const string &data, int incoming_seq)
 {
        char buf[4096];
        gre_header *gre = (gre_header *)buf;
@@ -55,7 +55,7 @@ void GREProtocol::send_packet(uint16_t proto, const string &data)
        gre->protocol_type = htons(proto);
 
        char *ptr = buf + sizeof(*gre);
-       int seq_be = htonl(seq++);
+       int seq_be = htonl(seq++);  // Ignore incoming_seq.
        memcpy(ptr, &seq_be, sizeof(seq_be));
        ptr += sizeof(seq_be);
 
@@ -72,7 +72,7 @@ int GREProtocol::fd() const
        return sock;
 }
 
-void GREProtocol::read_packet(Reorderer *sender)
+void GREProtocol::read_packet(Protocol *sender)
 {
        struct sockaddr_storage addr;
        socklen_t addrlen = sizeof(addr);
@@ -107,6 +107,6 @@ void GREProtocol::read_packet(Reorderer *sender)
 
        //printf("gre packet: proto=%x\n", ntohs(gre->protocol_type));
 
-       sender->handle_packet(ntohs(gre->protocol_type), string(ptr, buf + ret), seq);
+       sender->send_packet(ntohs(gre->protocol_type), string(ptr, buf + ret), seq);
 }