Add ability to not specify a zone identifier twice, when both source and
destination addresses are specified. For example: # ping6 -S fe80::1%ix0 ff02::1 or # ping6 -S fe80::1 fe80::2%ix0 Obtained from: Yandex LLC Sponsored by: Yandex LLC
This commit is contained in:
parent
d03f0c5199
commit
8150c3ec36
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275830
@ -648,11 +648,20 @@ main(int argc, char *argv[])
|
|||||||
err(1, "socket");
|
err(1, "socket");
|
||||||
|
|
||||||
/* set the source address if specified. */
|
/* set the source address if specified. */
|
||||||
if ((options & F_SRCADDR) &&
|
if ((options & F_SRCADDR) != 0) {
|
||||||
bind(s, (struct sockaddr *)&src, srclen) != 0) {
|
/* properly fill sin6_scope_id */
|
||||||
err(1, "bind");
|
if (IN6_IS_ADDR_LINKLOCAL(&src.sin6_addr) && (
|
||||||
|
IN6_IS_ADDR_LINKLOCAL(&dst.sin6_addr) ||
|
||||||
|
IN6_IS_ADDR_MC_LINKLOCAL(&dst.sin6_addr) ||
|
||||||
|
IN6_IS_ADDR_MC_NODELOCAL(&dst.sin6_addr))) {
|
||||||
|
if (src.sin6_scope_id == 0)
|
||||||
|
src.sin6_scope_id = dst.sin6_scope_id;
|
||||||
|
if (dst.sin6_scope_id == 0)
|
||||||
|
dst.sin6_scope_id = src.sin6_scope_id;
|
||||||
|
}
|
||||||
|
if (bind(s, (struct sockaddr *)&src, srclen) != 0)
|
||||||
|
err(1, "bind");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the gateway (next hop) if specified */
|
/* set the gateway (next hop) if specified */
|
||||||
if (gateway) {
|
if (gateway) {
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
Loading…
Reference in New Issue
Block a user