[sr-dev] git:adubovikov/homer: If ser works in IPIP capturing mode, raw_ipip is set to 1, that

Alexandr Dubovikov alexandr.dubovikov at gmail.com
Fri Aug 19 17:23:23 CEST 2011


Module: sip-router
Branch: adubovikov/homer
Commit: 4747dde1929599d3028092eacf0353189b8d0f2b
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4747dde1929599d3028092eacf0353189b8d0f2b

Author: Alexandr Dubovikov <alexandr.dubovikov at gmail.com>
Committer: Alexandr Dubovikov <alexandr.dubovikov at gmail.com>
Date:   Fri Aug 19 17:16:10 2011 +0200

If ser works in IPIP capturing mode, raw_ipip is set to 1, that
point to cut one IP header off.

---

 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);




More information about the sr-dev mailing list