diff options
author | maxim <maxim@FreeBSD.org> | 2010-04-20 06:10:05 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2010-04-20 06:10:05 +0000 |
commit | 035a4369ff6e2b1b66cfea8b5e66f399fe009cc5 (patch) | |
tree | 3a78b50beb835e6d9942835f137fef62c71ab7c7 /sbin/ping6/ping6.c | |
parent | 53e61968c013de230abc94448de8048fceec97d8 (diff) | |
download | FreeBSD-src-035a4369ff6e2b1b66cfea8b5e66f399fe009cc5.zip FreeBSD-src-035a4369ff6e2b1b66cfea8b5e66f399fe009cc5.tar.gz |
o Add do-not-fragment option support to ping6(8).
PR: bin/145759
Submitted by: pluknet
MFC after: 1 month
Diffstat (limited to 'sbin/ping6/ping6.c')
-rw-r--r-- | sbin/ping6/ping6.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index f7dba27..69a98b2 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -191,6 +191,7 @@ struct tv32 { #define F_ONCE 0x200000 #define F_AUDIBLE 0x400000 #define F_MISSED 0x800000 +#define F_DONTFRAG 0x1000000 #define F_NOUSERDATA (F_NODEADDR | F_FQDN | F_FQDNOLD | F_SUPTYPES) u_int options; @@ -349,7 +350,7 @@ main(argc, argv) #endif /*IPSEC_POLICY_IPSEC*/ #endif while ((ch = getopt(argc, argv, - "a:b:c:dfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) { + "a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) { #undef ADDOPTS switch (ch) { case 'a': @@ -415,6 +416,9 @@ main(argc, argv) errx(1, "illegal number of packets -- %s", optarg); break; + case 'D': + options |= F_DONTFRAG; + break; case 'd': options |= F_SO_DEBUG; break; @@ -742,7 +746,11 @@ main(argc, argv) for (i = 0; i < sizeof(nonce); i += sizeof(u_int32_t)) *((u_int32_t *)&nonce[i]) = arc4random(); #endif - + optval = 1; + if (options & F_DONTFRAG) + if (setsockopt(s, IPPROTO_IPV6, IPV6_DONTFRAG, + &optval, sizeof(optval)) == -1) + err(1, "IPV6_DONTFRAG"); hold = 1; if (options & F_SO_DEBUG) @@ -2780,7 +2788,7 @@ usage() "A" #endif "usage: ping6 [-" - "d" + "Dd" #if defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC) "E" #endif |