Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157525487
D2856.id17165.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D2856.id17165.diff
View Options
Index: sbin/ifconfig/af_inet.c
===================================================================
--- sbin/ifconfig/af_inet.c
+++ sbin/ifconfig/af_inet.c
@@ -54,7 +54,7 @@
static struct in_aliasreq in_addreq;
static struct ifreq in_ridreq;
-static char addr_buf[MAXHOSTNAMELEN *2 + 1]; /*for getnameinfo()*/
+static char addr_buf[NI_MAXHOST]; /*for getnameinfo()*/
extern char *f_inet, *f_addr;
static void
Index: sbin/ifconfig/af_inet6.c
===================================================================
--- sbin/ifconfig/af_inet6.c
+++ sbin/ifconfig/af_inet6.c
@@ -65,13 +65,13 @@
static int prefix(void *, int);
static char *sec2str(time_t);
static int explicit_prefix = 0;
-extern char *f_inet6, *f_addr, *f_scope;
+extern char *f_inet6, *f_addr;
extern void setnd6flags(const char *, int, int, const struct afswtch *);
extern void setnd6defif(const char *, int, int, const struct afswtch *);
extern void nd6_status(int);
-static char addr_buf[MAXHOSTNAMELEN *2 + 1]; /*for getnameinfo()*/
+static char addr_buf[NI_MAXHOST]; /*for getnameinfo()*/
static void
setifprefixlen(const char *addr, int dummy __unused, int s,
@@ -173,10 +173,9 @@
struct in6_ifreq ifr6;
int s6;
u_int32_t flags6;
- const u_int16_t *a;
struct in6_addrlifetime lifetime;
struct timespec now;
- int error, n_flags, i;
+ int error, n_flags;
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
@@ -208,30 +207,19 @@
lifetime = ifr6.ifr_ifru.ifru_lifetime;
close(s6);
- if (f_addr != NULL && strcmp(f_addr, "full") == 0) {
- a = (const u_int16_t *)&sin->sin6_addr;
- printf("\tinet6 ");
- for (i = 0; i < 8; i++) {
- printf("%04hx", ntohs(*(a + i)));
- if (i < 7)
- printf(":");
- }
- } else {
- if (f_addr != NULL && strcmp(f_addr, "fqdn") == 0)
- n_flags = 0;
- else if (f_addr != NULL && strcmp(f_addr, "host") == 0)
- n_flags = NI_NOFQDN;
- else
- n_flags = NI_NUMERICHOST;
- error = getnameinfo((struct sockaddr *)sin, sin->sin6_len,
- addr_buf, sizeof(addr_buf), NULL, 0,
- n_flags);
- if (error != 0 ||
- (f_scope != NULL && strcmp(f_scope, "none") == 0))
- inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf,
- sizeof(addr_buf));
- printf("\tinet6 %s", addr_buf);
- }
+ if (f_addr != NULL && strcmp(f_addr, "fqdn") == 0)
+ n_flags = 0;
+ else if (f_addr != NULL && strcmp(f_addr, "host") == 0)
+ n_flags = NI_NOFQDN;
+ else
+ n_flags = NI_NUMERICHOST;
+ error = getnameinfo((struct sockaddr *)sin, sin->sin6_len,
+ addr_buf, sizeof(addr_buf), NULL, 0,
+ n_flags);
+ if (error != 0)
+ inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf,
+ sizeof(addr_buf));
+ printf("\tinet6 %s", addr_buf);
if (ifa->ifa_flags & IFF_POINTOPOINT) {
sin = (struct sockaddr_in6 *)ifa->ifa_dstaddr;
@@ -280,8 +268,7 @@
if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0)
printf("prefer_source ");
- if ((f_scope == NULL || strcmp(f_scope, "none") != 0) &&
- ((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);
Index: sbin/ifconfig/af_link.c
===================================================================
--- sbin/ifconfig/af_link.c
+++ sbin/ifconfig/af_link.c
@@ -58,8 +58,7 @@
{
/* XXX no const 'cuz LLADDR is defined wrong */
struct sockaddr_dl *sdl = (struct sockaddr_dl *) ifa->ifa_addr;
- char *ether_format;
- int i;
+ char *ether_format, *format_char;
if (sdl != NULL && sdl->sdl_alen > 0) {
if ((sdl->sdl_type == IFT_ETHER ||
@@ -68,10 +67,8 @@
sdl->sdl_alen == ETHER_ADDR_LEN)
if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl));
- for (i = 0; i < strlen(ether_format); i++) {
- if (ether_format[i] == ':')
- ether_format[i] = '-';
- }
+ while ((format_char = strchr(ether_format, ':')) != NULL)
+ format_char[0] = '-';
printf("\tether %s\n", ether_format);
} else
printf("\tether %s\n",
Index: sbin/ifconfig/ifconfig.c
===================================================================
--- sbin/ifconfig/ifconfig.c
+++ sbin/ifconfig/ifconfig.c
@@ -99,7 +99,7 @@
int printkeys = 0; /* Print keying material for interfaces. */
/* Formatter Strings */
-char *f_inet, *f_inet6, *f_ether, *f_addr, *f_scope;
+char *f_inet, *f_inet6, *f_ether, *f_addr;
static int ifconfig(int argc, char *const *argv, int iscreate,
const struct afswtch *afp);
@@ -257,8 +257,6 @@
free(f_ether);
if (f_addr != NULL)
free(f_addr);
- if (f_scope != NULL)
- free(f_scope);
}
static void setformat(char *input)
@@ -286,8 +284,6 @@
f_inet = strdup(modifier);
else if (strcmp(category, "inet6") == 0)
f_inet6 = strdup(modifier);
- else if (strcmp(category, "scope") == 0)
- f_scope = strdup(modifier);
}
free(formatstr);
}
@@ -372,7 +368,7 @@
size_t iflen;
all = downonly = uponly = namesonly = noload = verbose = 0;
- f_inet = f_inet6 = f_ether = f_addr = f_scope = NULL;
+ f_inet = f_inet6 = f_ether = f_addr = NULL;
envformat = getenv("IFCONFIG_FORMAT");
if (envformat != NULL)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 23, 10:12 AM (22 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33444919
Default Alt Text
D2856.id17165.diff (5 KB)
Attached To
Mode
D2856: make ifconfig print ipv4 netmasks in dotted-quad notation, rather than hex
Attached
Detach File
Event Timeline
Log In to Comment