af_link.c (301059) | af_link.c (301185) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#ifndef lint 31static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#ifndef lint 31static const char rcsid[] = |
32 "$FreeBSD: head/sbin/ifconfig/af_link.c 301059 2016-05-31 17:30:08Z allanjude $"; | 32 "$FreeBSD: head/sbin/ifconfig/af_link.c 301185 2016-06-02 03:16:02Z allanjude $"; |
33#endif /* not lint */ 34 35#include <sys/types.h> 36#include <sys/ioctl.h> 37#include <sys/socket.h> 38#include <net/if.h> 39 40#include <err.h> --- 12 unchanged lines hidden (view full) --- 53 54extern char *f_ether; 55 56static void 57link_status(int s __unused, const struct ifaddrs *ifa) 58{ 59 /* XXX no const 'cuz LLADDR is defined wrong */ 60 struct sockaddr_dl *sdl = (struct sockaddr_dl *) ifa->ifa_addr; | 33#endif /* not lint */ 34 35#include <sys/types.h> 36#include <sys/ioctl.h> 37#include <sys/socket.h> 38#include <net/if.h> 39 40#include <err.h> --- 12 unchanged lines hidden (view full) --- 53 54extern char *f_ether; 55 56static void 57link_status(int s __unused, const struct ifaddrs *ifa) 58{ 59 /* XXX no const 'cuz LLADDR is defined wrong */ 60 struct sockaddr_dl *sdl = (struct sockaddr_dl *) ifa->ifa_addr; |
61 char *ether_format; 62 int i; | 61 char *ether_format, *format_char; |
63 64 if (sdl != NULL && sdl->sdl_alen > 0) { 65 if ((sdl->sdl_type == IFT_ETHER || 66 sdl->sdl_type == IFT_L2VLAN || 67 sdl->sdl_type == IFT_BRIDGE) && | 62 63 if (sdl != NULL && sdl->sdl_alen > 0) { 64 if ((sdl->sdl_type == IFT_ETHER || 65 sdl->sdl_type == IFT_L2VLAN || 66 sdl->sdl_type == IFT_BRIDGE) && |
68 sdl->sdl_alen == ETHER_ADDR_LEN) | 67 sdl->sdl_alen == ETHER_ADDR_LEN) { 68 ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl)); |
69 if (f_ether != NULL && strcmp(f_ether, "dash") == 0) { | 69 if (f_ether != NULL && strcmp(f_ether, "dash") == 0) { |
70 ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl)); 71 for (i = 0; i < strlen(ether_format); i++) { 72 if (ether_format[i] == ':') 73 ether_format[i] = '-'; 74 } 75 printf("\tether %s\n", ether_format); 76 } else 77 printf("\tether %s\n", 78 ether_ntoa((struct ether_addr *)LLADDR(sdl))); 79 else { | 70 for (format_char = strchr(ether_format, ':'); 71 format_char != NULL; 72 format_char = strchr(ether_format, ':')) 73 *format_char = '-'; 74 } 75 printf("\tether %s\n", ether_format); 76 } else { |
80 int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; 81 82 printf("\tlladdr %s\n", link_ntoa(sdl) + n); 83 } 84 } 85} 86 87static void --- 54 unchanged lines hidden --- | 77 int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; 78 79 printf("\tlladdr %s\n", link_ntoa(sdl) + n); 80 } 81 } 82} 83 84static void --- 54 unchanged lines hidden --- |