mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-24 07:02:05 +08:00
route command: Clean up kernal symbol accesses
This commit is contained in:
parent
e9aaadb911
commit
0fa7dabe89
@ -142,6 +142,7 @@ C_FILES += lib/libmemstat/memstat_uma.c
|
|||||||
# libutil
|
# libutil
|
||||||
C_FILES += lib/libutil/expand_number.c
|
C_FILES += lib/libutil/expand_number.c
|
||||||
C_FILES += lib/libutil/humanize_number.c
|
C_FILES += lib/libutil/humanize_number.c
|
||||||
|
C_FILES += lib/libutil/trimdomain.c
|
||||||
|
|
||||||
# libipsec files
|
# libipsec files
|
||||||
C_FILES += lib/libipsec/pfkey_dump.c
|
C_FILES += lib/libipsec/pfkey_dump.c
|
||||||
|
@ -398,10 +398,12 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *))
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
case AF_APPLETALK:
|
case AF_APPLETALK:
|
||||||
printf("atalk:%-12.12s ",atalk_print(sa,0x10) );
|
printf("atalk:%-12.12s ",atalk_print(sa,0x10) );
|
||||||
printf("%-11.11s ",atalk_print(sa,0x0b) );
|
printf("%-11.11s ",atalk_print(sa,0x0b) );
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case AF_LINK:
|
case AF_LINK:
|
||||||
{
|
{
|
||||||
struct sockaddr_dl *sdl =
|
struct sockaddr_dl *sdl =
|
||||||
@ -710,11 +712,15 @@ loop:
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if ((noutputs != 0) && (--noutputs == 0))
|
if ((noutputs != 0) && (--noutputs == 0))
|
||||||
exit(0);
|
exit(0);
|
||||||
|
#ifndef __rtems__
|
||||||
oldmask = sigblock(sigmask(SIGALRM));
|
oldmask = sigblock(sigmask(SIGALRM));
|
||||||
while (!signalled)
|
while (!signalled)
|
||||||
sigpause(0);
|
sigpause(0);
|
||||||
signalled = NO;
|
signalled = NO;
|
||||||
sigsetmask(oldmask);
|
sigsetmask(oldmask);
|
||||||
|
#else
|
||||||
|
#warning "Add BSD Signals wrapper"
|
||||||
|
#endif
|
||||||
line++;
|
line++;
|
||||||
first = 0;
|
first = 0;
|
||||||
if (line == 21)
|
if (line == 21)
|
||||||
|
@ -69,9 +69,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifndef __rtems__
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#endif
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <nlist.h>
|
#include <nlist.h>
|
||||||
@ -284,12 +282,14 @@ struct protox pfkeyprotox[] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
struct protox atalkprotox[] = {
|
struct protox atalkprotox[] = {
|
||||||
{ N_DDPCB, N_DDPSTAT, 1, atalkprotopr,
|
{ N_DDPCB, N_DDPSTAT, 1, atalkprotopr,
|
||||||
ddp_stats, NULL, "ddp", 0, 0 },
|
ddp_stats, NULL, "ddp", 0, 0 },
|
||||||
{ -1, -1, 0, NULL,
|
{ -1, -1, 0, NULL,
|
||||||
NULL, NULL, NULL, 0, 0 }
|
NULL, NULL, NULL, 0, 0 }
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
#ifdef NETGRAPH
|
#ifdef NETGRAPH
|
||||||
struct protox netgraphprotox[] = {
|
struct protox netgraphprotox[] = {
|
||||||
{ N_NGSOCKS, -1, 1, netgraphprotopr,
|
{ N_NGSOCKS, -1, 1, netgraphprotopr,
|
||||||
@ -322,16 +322,18 @@ struct protox *protoprotox[] = {
|
|||||||
#ifdef IPX
|
#ifdef IPX
|
||||||
ipxprotox,
|
ipxprotox,
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef __rtems__
|
||||||
atalkprotox, NULL };
|
atalkprotox, NULL };
|
||||||
|
#else
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static void printproto(struct protox *, const char *);
|
static void printproto(struct protox *, const char *);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
static struct protox *name2protox(const char *);
|
static struct protox *name2protox(const char *);
|
||||||
static struct protox *knownname(const char *);
|
static struct protox *knownname(const char *);
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
static kvm_t *kvmd;
|
static kvm_t *kvmd;
|
||||||
#endif
|
|
||||||
static char *nlistf = NULL, *memf = NULL;
|
static char *nlistf = NULL, *memf = NULL;
|
||||||
|
|
||||||
int Aflag; /* show addresses of protocol control block */
|
int Aflag; /* show addresses of protocol control block */
|
||||||
@ -528,7 +530,6 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
/*
|
/*
|
||||||
* Discard setgid privileges if not the running kernel so that bad
|
* Discard setgid privileges if not the running kernel so that bad
|
||||||
* guys can't print interesting stuff from kernel memory.
|
* guys can't print interesting stuff from kernel memory.
|
||||||
@ -551,7 +552,6 @@ main(int argc, char *argv[])
|
|||||||
mbpr(NULL, 0);
|
mbpr(NULL, 0);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if 0
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Keep file descriptors open to avoid overhead
|
* Keep file descriptors open to avoid overhead
|
||||||
@ -566,9 +566,7 @@ main(int argc, char *argv[])
|
|||||||
* used for the queries, which is slower.
|
* used for the queries, which is slower.
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
#ifndef __rtems__
|
|
||||||
kread(0, NULL, 0);
|
kread(0, NULL, 0);
|
||||||
#endif
|
|
||||||
if (iflag && !sflag) {
|
if (iflag && !sflag) {
|
||||||
intpr(interval, nl[N_IFNET].n_value, NULL);
|
intpr(interval, nl[N_IFNET].n_value, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -625,17 +623,21 @@ main(int argc, char *argv[])
|
|||||||
printproto(tp, tp->pr_name);
|
printproto(tp, tp->pr_name);
|
||||||
}
|
}
|
||||||
#endif /* IPX */
|
#endif /* IPX */
|
||||||
|
#ifndef __rtems__
|
||||||
if (af == AF_APPLETALK || af == AF_UNSPEC)
|
if (af == AF_APPLETALK || af == AF_UNSPEC)
|
||||||
for (tp = atalkprotox; tp->pr_name; tp++)
|
for (tp = atalkprotox; tp->pr_name; tp++)
|
||||||
printproto(tp, tp->pr_name);
|
printproto(tp, tp->pr_name);
|
||||||
|
#endif
|
||||||
#ifdef NETGRAPH
|
#ifdef NETGRAPH
|
||||||
if (af == AF_NETGRAPH || af == AF_UNSPEC)
|
if (af == AF_NETGRAPH || af == AF_UNSPEC)
|
||||||
for (tp = netgraphprotox; tp->pr_name; tp++)
|
for (tp = netgraphprotox; tp->pr_name; tp++)
|
||||||
printproto(tp, tp->pr_name);
|
printproto(tp, tp->pr_name);
|
||||||
#endif /* NETGRAPH */
|
#endif /* NETGRAPH */
|
||||||
|
#ifndef __rtems__
|
||||||
if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag)
|
if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag)
|
||||||
unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value,
|
unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value,
|
||||||
nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value);
|
nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value);
|
||||||
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,6 +705,10 @@ printproto(tp, name)
|
|||||||
(*pr)(off, name, af, tp->pr_protocol);
|
(*pr)(off, name, af, tp->pr_protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define _POSIX2_LINE_MAX 128
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __rtems__
|
#ifndef __rtems__
|
||||||
/*
|
/*
|
||||||
* Read kernel memory, return 0 on success.
|
* Read kernel memory, return 0 on success.
|
||||||
|
@ -56,9 +56,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#ifndef __rtems__
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#endif
|
|
||||||
#include <memstat.h>
|
#include <memstat.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -119,6 +117,8 @@ mbpr(void *kvmd, u_long mbaddr)
|
|||||||
memstat_strerror(error));
|
memstat_strerror(error));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define __BSD_VISIBLE 1
|
||||||
|
#include <freebsd/sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int Aflag; /* show addresses of protocol control block */
|
extern int Aflag; /* show addresses of protocol control block */
|
||||||
extern int aflag; /* show all sockets (including servers) */
|
extern int aflag; /* show all sockets (including servers) */
|
||||||
@ -63,7 +67,11 @@ extern int unit; /* unit number for above */
|
|||||||
extern int af; /* address family */
|
extern int af; /* address family */
|
||||||
extern int live; /* true if we are examining a live system */
|
extern int live; /* true if we are examining a live system */
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define kread(_x, _y, _z) (0)
|
||||||
|
#else
|
||||||
int kread(u_long addr, void *buf, size_t size);
|
int kread(u_long addr, void *buf, size_t size);
|
||||||
|
#endif
|
||||||
const char *plural(uintmax_t);
|
const char *plural(uintmax_t);
|
||||||
const char *plurales(uintmax_t);
|
const char *plurales(uintmax_t);
|
||||||
const char *pluralies(uintmax_t);
|
const char *pluralies(uintmax_t);
|
||||||
@ -126,6 +134,12 @@ char *ipx_phost(struct sockaddr *);
|
|||||||
char *ns_phost(struct sockaddr *);
|
char *ns_phost(struct sockaddr *);
|
||||||
void upHex(char *);
|
void upHex(char *);
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define routename rtems_shell_netstats_routername
|
||||||
|
#define netname rtems_shell_netstats_netname
|
||||||
|
#define sotoxsocket rtems_shell_netstats_sotoxsocket
|
||||||
|
#endif
|
||||||
|
|
||||||
char *routename(in_addr_t);
|
char *routename(in_addr_t);
|
||||||
char *netname(in_addr_t, u_long);
|
char *netname(in_addr_t, u_long);
|
||||||
char *atalk_print(struct sockaddr *, int);
|
char *atalk_print(struct sockaddr *, int);
|
||||||
|
@ -72,9 +72,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#ifndef __rtems__
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#endif
|
|
||||||
#include "netstat.h"
|
#include "netstat.h"
|
||||||
|
|
||||||
static void unixdomainpr(struct xunpcb *, struct xsocket *);
|
static void unixdomainpr(struct xunpcb *, struct xsocket *);
|
||||||
@ -204,7 +202,9 @@ fail:
|
|||||||
#undef COPYOUT
|
#undef COPYOUT
|
||||||
#undef KREAD
|
#undef KREAD
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
void
|
void
|
||||||
unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off)
|
unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off)
|
||||||
{
|
{
|
||||||
@ -253,7 +253,9 @@ unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off)
|
|||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
static void
|
static void
|
||||||
unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
|
unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user