use __BITMAP_TYPE
This commit is contained in:
parent
5d0cc05de3
commit
9878d5e5c4
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysctl.c,v 1.147 2012/12/05 13:53:39 christos Exp $ */
|
||||
/* $NetBSD: sysctl.c,v 1.148 2012/12/07 02:27:29 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: sysctl.c,v 1.147 2012/12/05 13:53:39 christos Exp $");
|
||||
__RCSID("$NetBSD: sysctl.c,v 1.148 2012/12/07 02:27:29 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -2692,8 +2692,10 @@ mode_bits(HANDLER_ARGS)
|
|||
}
|
||||
}
|
||||
|
||||
typedef __BITMAP_TYPE(, uint32_t, 0x10000) bitmap;
|
||||
|
||||
static char *
|
||||
bitmask_print(const uint32_t *o)
|
||||
bitmask_print(const bitmap *o)
|
||||
{
|
||||
char *s, *os;
|
||||
|
||||
|
@ -2717,12 +2719,13 @@ bitmask_print(const uint32_t *o)
|
|||
}
|
||||
|
||||
static void
|
||||
bitmask_scan(const void *v, uint32_t *o)
|
||||
bitmask_scan(const void *v, bitmap *o)
|
||||
{
|
||||
char *s = strdup(v);
|
||||
if (s == NULL)
|
||||
err(1, "");
|
||||
|
||||
__BITMAP_ZERO(o);
|
||||
for (s = strtok(s, ","); s; s = strtok(NULL, ",")) {
|
||||
char *e;
|
||||
errno = 0;
|
||||
|
@ -2741,17 +2744,15 @@ reserve(HANDLER_ARGS)
|
|||
{
|
||||
int rc;
|
||||
size_t osz, nsz;
|
||||
uint32_t o[__BITMAP_SIZE(uint32_t, MAXPORTS)];
|
||||
uint32_t n[__BITMAP_SIZE(uint32_t, MAXPORTS)];
|
||||
bitmap o, n;
|
||||
|
||||
if (fn)
|
||||
trim_whitespace(value, 3);
|
||||
|
||||
osz = sizeof(o);
|
||||
if (value) {
|
||||
__BITMAP_ZERO(n);
|
||||
bitmask_scan(value, n);
|
||||
value = (char *)n;
|
||||
bitmask_scan(value, &n);
|
||||
value = (char *)&n;
|
||||
nsz = sizeof(n);
|
||||
} else
|
||||
nsz = 0;
|
||||
|
@ -2766,10 +2767,10 @@ reserve(HANDLER_ARGS)
|
|||
return;
|
||||
|
||||
if (rflag || xflag)
|
||||
display_struct(pnode, sname, o, sizeof(o),
|
||||
display_struct(pnode, sname, &o, sizeof(o),
|
||||
value ? DISPLAY_OLD : DISPLAY_VALUE);
|
||||
else {
|
||||
char *s = bitmask_print(o);
|
||||
char *s = bitmask_print(&o);
|
||||
display_string(pnode, sname, s, strlen(s),
|
||||
value ? DISPLAY_OLD : DISPLAY_VALUE);
|
||||
free(s);
|
||||
|
@ -2777,10 +2778,10 @@ reserve(HANDLER_ARGS)
|
|||
|
||||
if (value) {
|
||||
if (rflag || xflag)
|
||||
display_struct(pnode, sname, n, sizeof(n),
|
||||
display_struct(pnode, sname, &n, sizeof(n),
|
||||
DISPLAY_NEW);
|
||||
else {
|
||||
char *s = bitmask_print(n);
|
||||
char *s = bitmask_print(&n);
|
||||
display_string(pnode, sname, s, strlen(s), DISPLAY_NEW);
|
||||
free(s);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: portalgo.c,v 1.3 2012/12/01 15:11:43 christos Exp $ */
|
||||
/* $NetBSD: portalgo.c,v 1.4 2012/12/07 02:27:41 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2011 Vlad Balan
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.3 2012/12/01 15:11:43 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.4 2012/12/07 02:27:41 christos Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
|
||||
|
@ -86,13 +86,14 @@ static bool portalgo_debug = true;
|
|||
#define DPRINTF while (/*CONSTCOND*/0) printf
|
||||
#endif
|
||||
|
||||
typedef __BITMAP_TYPE(, uint32_t, 0x10000) bitmap;
|
||||
#ifdef INET
|
||||
static int inet4_portalgo = PORTALGO_BSD;
|
||||
static uint32_t inet4_reserve[__BITMAP_SIZE(uint32_t, 0x10000)];
|
||||
static bitmap inet4_reserve;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
static int inet6_portalgo = PORTALGO_BSD;
|
||||
static uint32_t inet6_reserve[__BITMAP_SIZE(uint32_t, 0x10000)];
|
||||
static bitmap inet6_reserve;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
@ -253,7 +254,7 @@ check_suitable_port(uint16_t port, struct inpcb_hdr *inp_hdr, kauth_cred_t cred)
|
|||
struct inpcb *pcb;
|
||||
struct sockaddr_in sin;
|
||||
|
||||
if (__BITMAP_ISSET(port, inet4_reserve))
|
||||
if (__BITMAP_ISSET(port, &inet4_reserve))
|
||||
return false;
|
||||
|
||||
sin.sin_addr = inp->inp_laddr;
|
||||
|
@ -298,7 +299,7 @@ check_suitable_port(uint16_t port, struct inpcb_hdr *inp_hdr, kauth_cred_t cred)
|
|||
struct sockaddr_in6 sin6;
|
||||
void *t;
|
||||
|
||||
if (__BITMAP_ISSET(port, inet6_reserve))
|
||||
if (__BITMAP_ISSET(port, &inet6_reserve))
|
||||
return false;
|
||||
|
||||
sin6.sin6_addr = in6p->in6p_laddr;
|
||||
|
@ -901,7 +902,7 @@ sysctl_portalgo_selected(SYSCTLFN_ARGS, int *algo)
|
|||
}
|
||||
|
||||
static int
|
||||
sysctl_portalgo_reserve(SYSCTLFN_ARGS, uint32_t *bt)
|
||||
sysctl_portalgo_reserve(SYSCTLFN_ARGS, bitmap *bt)
|
||||
{
|
||||
struct sysctlnode node;
|
||||
int error;
|
||||
|
@ -942,7 +943,7 @@ int
|
|||
sysctl_portalgo_reserve4(SYSCTLFN_ARGS)
|
||||
{
|
||||
|
||||
return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), inet4_reserve);
|
||||
return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), &inet4_reserve);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -957,7 +958,7 @@ sysctl_portalgo_selected6(SYSCTLFN_ARGS)
|
|||
int
|
||||
sysctl_portalgo_reserve6(SYSCTLFN_ARGS)
|
||||
{
|
||||
return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), inet6_reserve);
|
||||
return sysctl_portalgo_reserve(SYSCTLFN_CALL(rnode), &inet6_reserve);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue