mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
ifconfig(8): add the dotted format for MAC addresses.
MFC after: 2 weeks PR: 261572
This commit is contained in:
parent
ea73ff9752
commit
d77ca41f77
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue