Module: sip-router
Branch: andrei/raw_sock
Commit: fb20a055a029198cbc9dd5c755c3806fbb1e80cf
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fb20a05…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Jun 9 22:58:55 2010 +0200
raw sockets: get dst. ip from the ip header
Get the destination ip from the packet header (when using
IP_HDRINCL we don't set PKT_INFO so we don't have the destination
information).
---
raw_sock.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/raw_sock.c b/raw_sock.c
index fb357c0..e8b90b1 100644
--- a/raw_sock.c
+++ b/raw_sock.c
@@ -284,9 +284,13 @@ int raw_udp4_recv(int rsock, char** buf, int len, union
sockaddr_union* from,
/* advance buf */
*buf=udp_payload;
n=(int)(end-*buf);
+ /* fill ip from the packet (needed if no PKT_INFO is used) */
+ dst_ip.af=AF_INET;
+ dst_ip.len=4;
+ dst_ip.u.addr32[0]=iph.daddr;
/* fill dst_port */
dst_port=ntohs(udph.dest);
- su_setport(to, dst_port);
+ ip_addr2su(to, &dst_ip, port);
/* fill src_port */
src_port=ntohs(udph.source);
su_setport(from, src_port);