Module: sip-router
Branch: master
Commit: ea6bc8837af00cc1841e2c10d1b082c127c70acc
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ea6bc88…
Author: Alexandr Dubovikov <alexandr.dubovikov(a)gmail.com>
Committer: Alexandr Dubovikov <alexandr.dubovikov(a)gmail.com>
Date: Mon Aug 22 13:11:01 2011 +0200
core: new raw_ipip flag, indicate to cut off the extra IP header in IPIP encapsulation.
---
raw_sock.c | 8 +++++++-
raw_sock.h | 1 +
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/raw_sock.c b/raw_sock.c
index 6298da0..b514a87 100644
--- a/raw_sock.c
+++ b/raw_sock.c
@@ -84,6 +84,8 @@
#endif /* __OS_* */
+int raw_ipip = 0; /* set if raw socket is in capture mode for IPIP */
+
/** create and return a raw socket.
* @param proto - protocol used (e.g. IPPROTO_UDP, IPPROTO_RAW)
@@ -319,10 +321,14 @@ int raw_udp4_recv(int rsock, char** buf, int len, union
sockaddr_union* from,
if (unlikely(n<0)) goto error;
end=*buf+n;
- if (unlikely(n<(sizeof(struct ip)+sizeof(struct udphdr)))) {
+ if (unlikely(n<((sizeof(struct ip) * raw_ipip ? 2 : 1)+sizeof(struct udphdr)))) {
n=-3;
goto error;
}
+
+ if(raw_ipip)
+ *buf = *buf + sizeof(struct ip);
+
/* FIXME: if initial buffer is aligned, one could skip the memcpy
and directly cast ip and udphdr pointer to the memory */
memcpy(&iph, *buf, sizeof(struct ip));
diff --git a/raw_sock.h b/raw_sock.h
index 6be0aba..868399f 100644
--- a/raw_sock.h
+++ b/raw_sock.h
@@ -39,6 +39,7 @@ struct raw_filter{
char proto;
};
+extern int raw_ipip;
int raw_socket(int proto, struct ip_addr* ip, str* iface, int iphdr_incl);
int raw_udp4_socket(struct ip_addr* ip, str* iface, int iphdr_incl);