Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig Use getnameinfo() for printing AppleTalk addre...
details: https://anonhg.NetBSD.org/src/rev/af57b30ba4ad
branches: trunk
changeset: 751262:af57b30ba4ad
user: is <is%NetBSD.org@localhost>
date: Sat Jan 30 18:30:33 2010 +0000
description:
Use getnameinfo() for printing AppleTalk addresses. While here, fix
printing of broadcast for this address family (AT broadcast is fixed
node 255 on the local net).
diffstat:
sbin/ifconfig/af_atalk.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diffs (81 lines):
diff -r bbd802ad5bb2 -r af57b30ba4ad sbin/ifconfig/af_atalk.c
--- a/sbin/ifconfig/af_atalk.c Sat Jan 30 18:07:06 2010 +0000
+++ b/sbin/ifconfig/af_atalk.c Sat Jan 30 18:30:33 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: af_atalk.c,v 1.15 2008/08/01 22:44:17 dyoung Exp $ */
+/* $NetBSD: af_atalk.c,v 1.16 2010/01/30 18:30:33 is Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: af_atalk.c,v 1.15 2008/08/01 22:44:17 dyoung Exp $");
+__RCSID("$NetBSD: af_atalk.c,v 1.16 2010/01/30 18:30:33 is Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -42,6 +42,8 @@
#include <netatalk/at.h>
+#include <netdb.h>
+
#include <err.h>
#include <errno.h>
#include <string.h>
@@ -177,19 +179,20 @@
}
static void
-sat_print(const char *prefix, const struct sockaddr *sa)
+sat_print1(const char *prefix, const struct sockaddr *sa)
{
- const struct sockaddr_at *sat = satocsat(sa);
+ char buf[40];
+ int rc;
- printf("%s%d.%d", prefix, ntohs(sat->sat_addr.s_net),
- sat->sat_addr.s_node);
+ rc = getnameinfo(sa, sa->sa_len, buf, sizeof(buf), NULL, 0, 0);
+
+ printf("%s%s", prefix, buf);
}
static void
at_status(prop_dictionary_t env, prop_dictionary_t oenv, bool force)
{
struct sockaddr_at *sat;
- struct netrange *nr;
struct ifreq ifr;
int s;
const char *ifname;
@@ -216,10 +219,7 @@
warn("SIOCGIFADDR");
sat = (struct sockaddr_at *)&ifr.ifr_addr;
- nr = (struct netrange *)&sat->sat_zero;
- sat_print("\tatalk ", &ifr.ifr_addr);
- printf(" range %d-%d phase %d",
- ntohs(nr->nr_firstnet), ntohs(nr->nr_lastnet), nr->nr_phase);
+ sat_print1("\tatalk ", &ifr.ifr_addr);
if (flags & IFF_POINTOPOINT) {
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
@@ -229,11 +229,13 @@
else
warn("SIOCGIFDSTADDR");
}
- sat_print(" --> ", &ifr.ifr_dstaddr);
+ sat_print1(" --> ", &ifr.ifr_dstaddr);
}
if (flags & IFF_BROADCAST) {
/* note RTAX_BRD overlap with IFF_POINTOPOINT */
- sat_print(" broadcast ", &ifr.ifr_broadaddr);
+ /* note Appletalk broadcast is fixed. */
+ printf(" broadcast %u.%u", ntohs(sat->sat_addr.s_net),
+ ATADDR_BCAST);
}
printf("\n");
}
Home |
Main Index |
Thread Index |
Old Index