Commit d43161dd authored by nanamicat's avatar nanamicat

fix

parent 42c5ed18
......@@ -5,6 +5,7 @@
#include <netinet/in.h>
#include <fcntl.h>
#include <linux/if.h>
#include <linux/ip.h>
#include <linux/if_tun.h>
#include <sys/ioctl.h>
#include <unistd.h>
......@@ -20,7 +21,9 @@ void inbound(int raw, int tun) {
size_t nread;
while ((nread = recvfrom(raw, buf, sizeof(buf), 0, (sockaddr *) &addr, &addrlen)) >= 0) {
std::cout << "recv " << nread << " bytes from" << inet_ntoa(addr.sin_addr) << std::endl;
if (write(tun, buf, nread) < 0) {
auto *packet = (iphdr *) buf;
auto overhead = packet->ihl * 4;
if (write(tun, buf + overhead, nread - overhead) < 0) {
perror("inbound write");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment