GREProtocol::GREProtocol(const in6_addr &src, const in6_addr &dst)
- : seq(0)
{
memset(&dstaddr, 0, sizeof(dstaddr));
dstaddr.sin6_family = AF_INET6;
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)
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);
perror("sendto");
return;
}
+
+ ++sent_packets;
}
int GREProtocol::fd() const
//printf("gre packet: proto=%x\n", ntohs(gre->protocol_type));
+ ++received_packets;
sender->send_packet(ntohs(gre->protocol_type), string(ptr, buf + ret), seq);
}