diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2005-01-19 13:40:48 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2005-01-19 13:40:48 +0000 |
commit | 32ae4c7606813925856a8f6d568185dce44029ef (patch) | |
tree | b509106ca99e4e525ab08b8b59f08f641b38bef4 | |
parent | 33b3db42e399e40816dc09c27ca2c1135e03864f (diff) |
Don't ignore a provided source address, when building an own IP header.
This makes the -I option work together with -D, -T and -t.
OK deraadt@, hshoexer@, markus@
-rw-r--r-- | sbin/ping/ping.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 88f501e546a..75db06c5a37 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.69 2004/09/14 23:52:46 deraadt Exp $ */ +/* $OpenBSD: ping.c,v 1.70 2005/01/19 13:40:47 mpf Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: ping.c,v 1.69 2004/09/14 23:52:46 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: ping.c,v 1.70 2005/01/19 13:40:47 mpf Exp $"; #endif #endif /* not lint */ @@ -403,7 +403,10 @@ main(int argc, char *argv[]) ip->ip_off = htons(df ? IP_DF : 0); ip->ip_ttl = ttl; ip->ip_p = IPPROTO_ICMP; - ip->ip_src.s_addr = INADDR_ANY; + if (options & F_SADDR) + ip->ip_src = saddr; + else + ip->ip_src.s_addr = INADDR_ANY; ip->ip_dst = to->sin_addr; } |