Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146094837
D35271.id106229.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D35271.id106229.diff
View Options
Index: sbin/ping/main.c
===================================================================
--- sbin/ping/main.c
+++ sbin/ping/main.c
@@ -93,6 +93,18 @@
case '6':
ipv6 = true;
break;
+#endif
+#if defined(INET) && defined(INET6)
+ case 'S':
+ /*
+ * If -S is given with a numeric parameter,
+ * force use of the corresponding version.
+ */
+ if (inet_pton(AF_INET, optarg, &a) == 1)
+ ipv4 = true;
+ else if (inet_pton(AF_INET6, optarg, &a) == 1)
+ ipv6 = true;
+ break;
#endif
default:
break;
Index: sbin/ping/tests/ping_c1_s56_t1_S127.out
===================================================================
--- /dev/null
+++ sbin/ping/tests/ping_c1_s56_t1_S127.out
@@ -0,0 +1,6 @@
+PING localhost from: 56 data bytes
+64 bytes from: icmp_seq=0 ttl= time= ms
+
+--- localhost ping statistics ---
+1 packets transmitted, 1 packets received, 0.0% packet loss
+round-trip min/avg/max/stddev = /// ms
Index: sbin/ping/tests/ping_c1_s8_t1_S1.out
===================================================================
--- /dev/null
+++ sbin/ping/tests/ping_c1_s8_t1_S1.out
@@ -0,0 +1,6 @@
+PING6(56=40+8+8 bytes) ::1 --> ::1
+16 bytes from ::1, icmp_seq=0 hlim= time= ms
+
+--- localhost ping6 statistics ---
+1 packets transmitted, 1 packets received, 0.0% packet loss
+round-trip min/avg/max/std-dev = /// ms
Index: sbin/ping/tests/ping_test.sh
===================================================================
--- sbin/ping/tests/ping_test.sh
+++ sbin/ping/tests/ping_test.sh
@@ -49,6 +49,18 @@
check_ping_statistics std.out $(atf_get_srcdir)/ping_c1_s56_t1.out
}
+atf_test_case ping_c1_s56_t1_S127
+ping_c1_s56_t1_S127_head() {
+ atf_set "descr" "Check that ping -S 127.0.0.1 localhost succeeds"
+}
+ping_c1_s56_t1_S127_body() {
+ require_ipv4
+ require_ipv6
+ atf_check -s exit:0 -o save:std.out -e empty \
+ ping -c 1 -s 56 -t 1 -S 127.0.0.1 localhost
+ check_ping_statistics std.out $(atf_get_srcdir)/ping_c1_s56_t1_S127.out
+}
+
atf_test_case ping_6_c1_s8_t1
ping_6_c1_s8_t1_head() {
atf_set "descr" "Stop after receiving 1 ECHO_RESPONSE packet"
@@ -60,6 +72,17 @@
check_ping_statistics std.out $(atf_get_srcdir)/ping_6_c1_s8_t1.out
}
+atf_test_case ping_c1_s8_t1_S1
+ping_c1_s8_t1_S1_head() {
+ atf_set "descr" "Check that ping -S ::1 localhost succeeds"
+}
+ping_c1_s8_t1_S1_body() {
+ require_ipv6
+ atf_check -s exit:0 -o save:std.out -e empty \
+ ping -c 1 -s 8 -t 1 -S ::1 localhost
+ check_ping_statistics std.out $(atf_get_srcdir)/ping_c1_s8_t1_S1.out
+}
+
atf_test_case ping6_c1_s8_t1
ping6_c1_s8_t1_head() {
atf_set "descr" "Use IPv6 when invoked as ping6"
@@ -104,7 +127,9 @@
atf_init_test_cases() {
atf_add_test_case ping_c1_s56_t1
+ atf_add_test_case ping_c1_s56_t1_S127
atf_add_test_case ping_6_c1_s8_t1
+ atf_add_test_case ping_c1_s8_t1_S1
atf_add_test_case ping6_c1_s8_t1
atf_add_test_case ping_c1t6
atf_add_test_case ping6_c1t4
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 28, 6:41 PM (12 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29078983
Default Alt Text
D35271.id106229.diff (2 KB)
Attached To
Mode
D35271: ping: if -S srcaddr uses a numeric address, use that protocol
Attached
Detach File
Event Timeline
Log In to Comment