Style(9) fixes.
Approved by: bapt, ae X-MFC-With: r278080
This commit is contained in:
parent
35c73e51cc
commit
07a51db9e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=278081
@ -284,20 +284,23 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
|
|||||||
if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0)
|
if ((flags6 & IN6_IFF_PREFER_SOURCE) != 0)
|
||||||
printf("prefer_source ");
|
printf("prefer_source ");
|
||||||
|
|
||||||
in6_print_scope((uint8_t *)&((struct sockaddr_in6 *)(ifa->ifa_addr))->sin6_addr);
|
in6_print_scope((uint8_t *)&((struct sockaddr_in6 *)
|
||||||
|
(ifa->ifa_addr))->sin6_addr);
|
||||||
|
|
||||||
if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) {
|
if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) {
|
||||||
printf("pltime ");
|
printf("pltime ");
|
||||||
if (lifetime.ia6t_preferred) {
|
if (lifetime.ia6t_preferred) {
|
||||||
printf("%s ", lifetime.ia6t_preferred < now.tv_sec
|
printf("%s ", lifetime.ia6t_preferred < now.tv_sec
|
||||||
? "0" : sec2str(lifetime.ia6t_preferred - now.tv_sec));
|
? "0" :
|
||||||
|
sec2str(lifetime.ia6t_preferred - now.tv_sec));
|
||||||
} else
|
} else
|
||||||
printf("infty ");
|
printf("infty ");
|
||||||
|
|
||||||
printf("vltime ");
|
printf("vltime ");
|
||||||
if (lifetime.ia6t_expire) {
|
if (lifetime.ia6t_expire) {
|
||||||
printf("%s ", lifetime.ia6t_expire < now.tv_sec
|
printf("%s ", lifetime.ia6t_expire < now.tv_sec
|
||||||
? "0" : sec2str(lifetime.ia6t_expire - now.tv_sec));
|
? "0" :
|
||||||
|
sec2str(lifetime.ia6t_expire - now.tv_sec));
|
||||||
} else
|
} else
|
||||||
printf("infty ");
|
printf("infty ");
|
||||||
}
|
}
|
||||||
@ -372,25 +375,25 @@ in6_getaddr(const char *s, int which)
|
|||||||
static int
|
static int
|
||||||
prefix(void *val, int size)
|
prefix(void *val, int size)
|
||||||
{
|
{
|
||||||
u_char *name = (u_char *)val;
|
u_char *name = (u_char *)val;
|
||||||
int byte, bit, plen = 0;
|
int byte, bit, plen = 0;
|
||||||
|
|
||||||
for (byte = 0; byte < size; byte++, plen += 8)
|
for (byte = 0; byte < size; byte++, plen += 8)
|
||||||
if (name[byte] != 0xff)
|
if (name[byte] != 0xff)
|
||||||
break;
|
break;
|
||||||
if (byte == size)
|
if (byte == size)
|
||||||
return (plen);
|
return (plen);
|
||||||
for (bit = 7; bit != 0; bit--, plen++)
|
for (bit = 7; bit != 0; bit--, plen++)
|
||||||
if (!(name[byte] & (1 << bit)))
|
if (!(name[byte] & (1 << bit)))
|
||||||
break;
|
break;
|
||||||
for (; bit != 0; bit--)
|
for (; bit != 0; bit--)
|
||||||
if (name[byte] & (1 << bit))
|
if (name[byte] & (1 << bit))
|
||||||
return(0);
|
return(0);
|
||||||
byte++;
|
byte++;
|
||||||
for (; byte < size; byte++)
|
for (; byte < size; byte++)
|
||||||
if (name[byte])
|
if (name[byte])
|
||||||
return(0);
|
return(0);
|
||||||
return (plen);
|
return (plen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -534,7 +537,11 @@ in6_Lopt_cb(const char *optarg __unused)
|
|||||||
{
|
{
|
||||||
ip6lifetime++; /* print IPv6 address lifetime */
|
ip6lifetime++; /* print IPv6 address lifetime */
|
||||||
}
|
}
|
||||||
static struct option in6_Lopt = { .opt = "L", .opt_usage = "[-L]", .cb = in6_Lopt_cb };
|
static struct option in6_Lopt = {
|
||||||
|
.opt = "L",
|
||||||
|
.opt_usage = "[-L]",
|
||||||
|
.cb = in6_Lopt_cb
|
||||||
|
};
|
||||||
|
|
||||||
static __constructor void
|
static __constructor void
|
||||||
inet6_ctor(void)
|
inet6_ctor(void)
|
||||||
|
@ -151,12 +151,14 @@ usage(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ORDERS_SIZE(x) sizeof(x) / sizeof(x[0])
|
||||||
|
|
||||||
static int
|
static int
|
||||||
calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
|
calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
|
||||||
{
|
{
|
||||||
unsigned int ord, af, ifa_ord;
|
|
||||||
struct ifaddrs *prev;
|
struct ifaddrs *prev;
|
||||||
struct ifa_order_elt *cur;
|
struct ifa_order_elt *cur;
|
||||||
|
unsigned int ord, af, ifa_ord;
|
||||||
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
cur = NULL;
|
cur = NULL;
|
||||||
@ -164,7 +166,8 @@ calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
|
|||||||
ifa_ord = 0;
|
ifa_ord = 0;
|
||||||
|
|
||||||
while (ifa != NULL) {
|
while (ifa != NULL) {
|
||||||
if (prev == NULL || strcmp(ifa->ifa_name, prev->ifa_name) != 0) {
|
if (prev == NULL ||
|
||||||
|
strcmp(ifa->ifa_name, prev->ifa_name) != 0) {
|
||||||
cur = calloc(1, sizeof(*cur));
|
cur = calloc(1, sizeof(*cur));
|
||||||
|
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
@ -179,8 +182,8 @@ calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
|
|||||||
if (ifa->ifa_addr) {
|
if (ifa->ifa_addr) {
|
||||||
af = ifa->ifa_addr->sa_family;
|
af = ifa->ifa_addr->sa_family;
|
||||||
|
|
||||||
if (af < sizeof(cur->af_orders) / sizeof(cur->af_orders[0]) &&
|
if (af < ORDERS_SIZE(cur->af_orders) &&
|
||||||
cur->af_orders[af] == 0)
|
cur->af_orders[af] == 0)
|
||||||
cur->af_orders[af] = ++ord;
|
cur->af_orders[af] = ++ord;
|
||||||
}
|
}
|
||||||
prev = ifa;
|
prev = ifa;
|
||||||
@ -193,15 +196,14 @@ calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
|
|||||||
static int
|
static int
|
||||||
cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q)
|
cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
unsigned int af1, af2;
|
|
||||||
struct ifa_order_elt *cur, *e1, *e2;
|
struct ifa_order_elt *cur, *e1, *e2;
|
||||||
|
unsigned int af1, af2;
|
||||||
|
int ret;
|
||||||
|
|
||||||
e1 = e2 = NULL;
|
e1 = e2 = NULL;
|
||||||
|
|
||||||
ret = strcmp(a->ifa_name, b->ifa_name);
|
ret = strcmp(a->ifa_name, b->ifa_name);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
/* We need to find elements corresponding to these different names */
|
|
||||||
TAILQ_FOREACH(cur, q, link) {
|
TAILQ_FOREACH(cur, q, link) {
|
||||||
if (e1 && e2)
|
if (e1 && e2)
|
||||||
break;
|
break;
|
||||||
@ -231,20 +233,21 @@ cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q)
|
|||||||
af1 = a->ifa_addr->sa_family;
|
af1 = a->ifa_addr->sa_family;
|
||||||
af2 = b->ifa_addr->sa_family;
|
af2 = b->ifa_addr->sa_family;
|
||||||
|
|
||||||
if (af1 < sizeof(e1->af_orders) / sizeof(e1->af_orders[0]) &&
|
if (af1 < ORDERS_SIZE(e1->af_orders) &&
|
||||||
af2 < sizeof(e1->af_orders) / sizeof(e1->af_orders[0]))
|
af2 < ORDERS_SIZE(e1->af_orders))
|
||||||
return (e1->af_orders[af2] - e1->af_orders[af1]);
|
return (e1->af_orders[af2] - e1->af_orders[af1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef ORDERS_SIZE
|
||||||
|
|
||||||
static struct ifaddrs *
|
static struct ifaddrs *
|
||||||
sortifaddrs(struct ifaddrs *list,
|
sortifaddrs(struct ifaddrs *list,
|
||||||
int (*compare)(struct ifaddrs *, struct ifaddrs *, struct ifa_queue *),
|
int (*compare)(struct ifaddrs *, struct ifaddrs *, struct ifa_queue *),
|
||||||
struct ifa_queue *q)
|
struct ifa_queue *q)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ifaddrs *right, *temp, *last, *result, *next, *tail;
|
struct ifaddrs *right, *temp, *last, *result, *next, *tail;
|
||||||
|
|
||||||
right = list;
|
right = list;
|
||||||
@ -499,7 +502,8 @@ main(int argc, char *argv[])
|
|||||||
sdl->sdl_alen != ETHER_ADDR_LEN)
|
sdl->sdl_alen != ETHER_ADDR_LEN)
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (ifa->ifa_addr->sa_family != afp->af_af)
|
if (ifa->ifa_addr->sa_family
|
||||||
|
!= afp->af_af)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user