git: d77ca41f7762 - main - ifconfig(8): add the dotted format for MAC addresses.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 13 Jun 2023 06:40:47 UTC
The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=d77ca41f7762bc909a83d87ebd95735b4021652f commit d77ca41f7762bc909a83d87ebd95735b4021652f Author: Trond Endrestol <Trond.Endrestol@ximalas.info> AuthorDate: 2023-06-13 06:36:16 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2023-06-13 06:40:15 +0000 ifconfig(8): add the dotted format for MAC addresses. MFC after: 2 weeks PR: 261572 --- sbin/ifconfig/af_link.c | 25 +++++++++++++++++++++---- sbin/ifconfig/ifconfig.8 | 5 ++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/sbin/ifconfig/af_link.c b/sbin/ifconfig/af_link.c index 8fd5e05044e2..7b7c5259d6c9 100644 --- a/sbin/ifconfig/af_link.c +++ b/sbin/ifconfig/af_link.c @@ -62,11 +62,28 @@ print_ether(const struct ether_addr *addr, const char *prefix) { char *ether_format = ether_ntoa(addr); - if (f_ether != NULL && strcmp(f_ether, "dash") == 0) { - char *format_char; + if (f_ether != NULL) { + if (strcmp(f_ether, "dash") == 0) { + char *format_char; - while ((format_char = strchr(ether_format, ':')) != NULL) { - *format_char = '-'; + while ((format_char = strchr(ether_format, ':')) != NULL) { + *format_char = '-'; + } + } else if (strcmp(f_ether, "dotted") == 0) { + /* Indices 0 and 1 is kept as is. */ + ether_format[ 2] = ether_format[ 3]; + ether_format[ 3] = ether_format[ 4]; + ether_format[ 4] = '.'; + ether_format[ 5] = ether_format[ 6]; + ether_format[ 6] = ether_format[ 7]; + ether_format[ 7] = ether_format[ 9]; + ether_format[ 8] = ether_format[10]; + ether_format[ 9] = '.'; + ether_format[10] = ether_format[12]; + ether_format[11] = ether_format[13]; + ether_format[12] = ether_format[15]; + ether_format[13] = ether_format[16]; + ether_format[14] = '\0'; } } printf("\t%s %s\n", prefix, ether_format); diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index a7e1bb26d81a..13685eba4c39 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd May 22, 2023 +.Dd June 13, 2023 .Dt IFCONFIG 8 .Os .Sh NAME @@ -156,6 +156,9 @@ Adjust the display of link-level ethernet (MAC) addresses: Separate address segments with a colon .It Cm dash Separate address segments with a dash +.It Cm dotted +Dotted notation, for example: +.Ql 5254.0015.4a3b .It Cm default Default format, .Cm colon