From owner-freebsd-hackers@freebsd.org Wed Aug 9 20:18:09 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AA56CDD53BB for ; Wed, 9 Aug 2017 20:18:09 +0000 (UTC) (envelope-from raichoo@googlemail.com) Received: from mail-it0-x22f.google.com (mail-it0-x22f.google.com [IPv6:2607:f8b0:4001:c0b::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 716DB84C72 for ; Wed, 9 Aug 2017 20:18:09 +0000 (UTC) (envelope-from raichoo@googlemail.com) Received: by mail-it0-x22f.google.com with SMTP id f16so11815375itb.0 for ; Wed, 09 Aug 2017 13:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=y8fJvpS/dYLEvzMCOonur9SRF+uB1OzeAwjyP4DrIxc=; b=hiRYovkqN6gnH9ButnajKmb713YiENrVxt1RgaC1jE/fZPT2GNxvJjSvugwsLeIHFm bh7P5OTU4EB1v5/YsP2FLk7dinB4FS8Tjy4znRMz0c/JgDGNFIk0NMYGKkR80S6tmMKc XpxXDUQM3PqX9OIX9x6jwEVAJFVZI2lovf3pfTZQiYdxyuqwyx4EwVEAjxAcE97Uokt/ YOpvP+YOZ/XIqQ1DMiIVru0bhIrL/BqnzGSzxtRV+e/8i8HKM7VF4WPjFAEg665IlEV4 TcJlqpTR5qVVhXOUsUlLKiavyx0ASX+Wp0E0jZe2AWe7kH7MZJTr/OHtvcp/BIHD0u+1 DI4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=y8fJvpS/dYLEvzMCOonur9SRF+uB1OzeAwjyP4DrIxc=; b=Smrv5OF+oA8bJdC7zzmGc9Gykgd0bPORlX7glVSSVIeVFuH40kVKoBT5bLDuEyEkCK hBvas7omtlHolnB9NLwkwYx4uMNLTaw5swzX+bgu5hMQZQtigqMmMs4uU9hzcNtXUFM0 SXfOVL0Ew2yr7WZZOVN30VPoI0ahrHV5C8hIyHG3jl+YgPJKzojr2ugSBRnlNd5aTRPC 0/XswMva/pvRDH1Mlw1wxE6j7Mh2rlKibswbtccGAXMQ/fM/Nf6DEMHOXV12MVTgbbsV NUN5Qo28c3wGwiqMkdg8h5gRkSKcX4epnDKp74OCYURd3i0nLtBqC4bIr/j22llCfgIV 3E1Q== X-Gm-Message-State: AIVw111dYEAZCpnW+E+wVdAr8oTrNr5qzrGENVq0P4angm7nrEAvXgrZ 2MoovH5xVdnopMGmGjRLsU2KSXoTH7zq X-Received: by 10.36.237.137 with SMTP id r131mr5353148ith.70.1502309888363; Wed, 09 Aug 2017 13:18:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.16.69 with HTTP; Wed, 9 Aug 2017 13:18:07 -0700 (PDT) From: raichoo Date: Wed, 9 Aug 2017 22:18:07 +0200 Message-ID: Subject: `ifconfig` patch to resolve IPv6 scope names To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Aug 2017 20:18:09 -0000 Hi, I've made a trivial patch that resolves IPv6 scope names (according to rfc4291). I thought this might be handy, so one does not have to memorize what id refers to which scope. And it's a nice opportunity to get my feet wet I guess :) This is my first patch and I have no idea what's the best way to contribute to the project (probably I didn't look hard enough or in the wrong places). Feedback and pointers appreciated. Kind regards, raichoo diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index e93d94355e..165b2cc90a 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -268,10 +268,32 @@ in6_status(int s __unused, const struct ifaddrs *ifa) if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0) printf("prefer_source "); - if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) + if (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) { printf("scopeid 0x%x ", ((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id); + switch (((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_scope_id) { + case 0x1: + printf("interface-local "); + break; + case 0x2: + printf("link-local "); + break; + case 0x4: + printf("admin-local "); + break; + case 0x5: + printf("site-local "); + break; + case 0x8: + printf("organization-local "); + break; + case 0xe: + printf("global "); + break; + } + } + if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) { printf("pltime "); if (lifetime.ia6t_preferred) {