X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=greprotocol.cpp;h=d3daa9c829ae9a14c100291405312595f9a63664;hb=3bcabb4fd4764b0804b8b44cb967edf7369cc714;hp=5fd4e4b8262a69be62098fb41524a2b228b7602f;hpb=02120e9414a6e613b17d6284891593271659b5d9;p=greproxy diff --git a/greprotocol.cpp b/greprotocol.cpp index 5fd4e4b..d3daa9c 100644 --- a/greprotocol.cpp +++ b/greprotocol.cpp @@ -43,6 +43,12 @@ GREProtocol::GREProtocol(const in6_addr &src, const in6_addr &dst) perror("bind"); exit(1); } + + int buf = 10 << 20; // 20 MB. + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &buf, sizeof(buf)) == -1) { + perror("setsockopt(SO_RCVBUF)"); + exit(1); + } } void GREProtocol::send_packet(uint16_t proto, const string &data, int incoming_seq) @@ -66,6 +72,8 @@ void GREProtocol::send_packet(uint16_t proto, const string &data, int incoming_s perror("sendto"); return; } + + ++sent_packets; } int GREProtocol::fd() const @@ -108,6 +116,7 @@ void GREProtocol::read_packet(Sender *sender) //printf("gre packet: proto=%x\n", ntohs(gre->protocol_type)); + ++received_packets; sender->send_packet(ntohs(gre->protocol_type), string(ptr, buf + ret), seq); }