mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-22 23:55:34 +08:00
NETSTAT(1): Initialize global variables
Use BSD program lock.
This commit is contained in:
parent
5898fa13a3
commit
6da9b2397b
@ -306,7 +306,6 @@ void
|
|||||||
protopr(u_long off, const char *name, int af1, int proto)
|
protopr(u_long off, const char *name, int af1, int proto)
|
||||||
{
|
{
|
||||||
int istcp;
|
int istcp;
|
||||||
static int first = 1;
|
|
||||||
char *buf;
|
char *buf;
|
||||||
const char *vchar;
|
const char *vchar;
|
||||||
struct tcpcb *tp = NULL;
|
struct tcpcb *tp = NULL;
|
||||||
@ -394,7 +393,7 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||||||
))
|
))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (first) {
|
if (!protopr_initialized) {
|
||||||
if (!Lflag) {
|
if (!Lflag) {
|
||||||
printf("Active Internet connections");
|
printf("Active Internet connections");
|
||||||
if (aflag)
|
if (aflag)
|
||||||
@ -424,7 +423,7 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||||||
else
|
else
|
||||||
printf("(state)\n");
|
printf("(state)\n");
|
||||||
}
|
}
|
||||||
first = 0;
|
protopr_initialized = 1;
|
||||||
}
|
}
|
||||||
if (Lflag && so->so_qlimit == 0)
|
if (Lflag && so->so_qlimit == 0)
|
||||||
continue;
|
continue;
|
||||||
@ -913,7 +912,7 @@ arp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char *icmpnames[ICMP_MAXTYPE + 1] = {
|
static const char *const icmpnames[ICMP_MAXTYPE + 1] = {
|
||||||
"echo reply", /* RFC 792 */
|
"echo reply", /* RFC 792 */
|
||||||
"#1",
|
"#1",
|
||||||
"#2",
|
"#2",
|
||||||
|
@ -364,13 +364,54 @@ int af; /* address family */
|
|||||||
int live; /* true if we are examining a live system */
|
int live; /* true if we are examining a live system */
|
||||||
|
|
||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
|
int protopr_initialized;
|
||||||
|
int do_rtent;
|
||||||
|
struct radix_node_head **rt_tables;
|
||||||
|
|
||||||
static int main(int argc, char *argv[]);
|
static int main(int argc, char *argv[]);
|
||||||
|
|
||||||
int rtems_bsd_command_netstat(int argc, char *argv[])
|
int rtems_bsd_command_netstat(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
noutputs = 0;
|
int exit_code;
|
||||||
|
|
||||||
return rtems_bsd_program_call_main("netstat", main, argc, argv);
|
rtems_bsd_program_lock();
|
||||||
|
|
||||||
|
Aflag = 0;
|
||||||
|
aflag = 0;
|
||||||
|
bflag = 0;
|
||||||
|
dflag = 0;
|
||||||
|
gflag = 0;
|
||||||
|
hflag = 0;
|
||||||
|
iflag = 0;
|
||||||
|
Lflag = 0;
|
||||||
|
mflag = 0;
|
||||||
|
noutputs = 0;
|
||||||
|
numeric_addr = 0;
|
||||||
|
numeric_port = 0;
|
||||||
|
pflag = 0;
|
||||||
|
rflag = 0;
|
||||||
|
sflag = 0;
|
||||||
|
tflag = 0;
|
||||||
|
Wflag = 0;
|
||||||
|
xflag = 0;
|
||||||
|
zflag = 0;
|
||||||
|
interval = 0;
|
||||||
|
interface = 0;
|
||||||
|
unit = 0;
|
||||||
|
af = 0;
|
||||||
|
live = 0;
|
||||||
|
|
||||||
|
protopr_initialized = 0;
|
||||||
|
do_rtent = 0;
|
||||||
|
|
||||||
|
exit_code = rtems_bsd_program_call_main("netstat", main, argc, argv);
|
||||||
|
|
||||||
|
free(rt_tables);
|
||||||
|
rt_tables = NULL;
|
||||||
|
|
||||||
|
rtems_bsd_program_unlock();
|
||||||
|
|
||||||
|
return exit_code;
|
||||||
}
|
}
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
int
|
int
|
||||||
|
@ -36,6 +36,12 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#ifdef __rtems__
|
||||||
|
#define rt_tables netstat_rt_tables
|
||||||
|
#define routename rtems_shell_netstats_routername
|
||||||
|
#define netname rtems_shell_netstats_netname
|
||||||
|
#define sotoxsocket rtems_shell_netstats_sotoxsocket
|
||||||
|
#endif /* __rtems__ */
|
||||||
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) */
|
||||||
extern int bflag; /* show i/f total bytes in/out */
|
extern int bflag; /* show i/f total bytes in/out */
|
||||||
@ -62,6 +68,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__
|
||||||
|
extern int protopr_initialized;
|
||||||
|
extern int do_rtent;
|
||||||
|
extern struct radix_node_head **rt_tables;
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
int kread(u_long addr, void *buf, size_t size);
|
int kread(u_long addr, void *buf, size_t size);
|
||||||
const char *plural(uintmax_t);
|
const char *plural(uintmax_t);
|
||||||
@ -126,13 +137,6 @@ char *ipx_phost(struct sockaddr *);
|
|||||||
char *ns_phost(struct sockaddr *);
|
char *ns_phost(struct sockaddr *);
|
||||||
void upHex(char *);
|
void upHex(char *);
|
||||||
|
|
||||||
#ifdef __rtems__
|
|
||||||
#define rt_tables netstat_rt_tables
|
|
||||||
#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);
|
||||||
|
@ -126,16 +126,14 @@ typedef union {
|
|||||||
|
|
||||||
static sa_u pt_u;
|
static sa_u pt_u;
|
||||||
|
|
||||||
int fibnum;
|
static int fibnum;
|
||||||
int do_rtent = 0;
|
static struct rtentry rtentry;
|
||||||
struct rtentry rtentry;
|
static struct radix_node rnode;
|
||||||
struct radix_node rnode;
|
static struct radix_mask rmask;
|
||||||
struct radix_mask rmask;
|
|
||||||
struct radix_node_head **rt_tables;
|
|
||||||
|
|
||||||
int NewTree = 0;
|
static const int NewTree = 0;
|
||||||
|
|
||||||
struct timespec uptime;
|
static struct timespec uptime;
|
||||||
|
|
||||||
static struct sockaddr *kgetsa(struct sockaddr *);
|
static struct sockaddr *kgetsa(struct sockaddr *);
|
||||||
static void size_cols(int ef, struct radix_node *rn);
|
static void size_cols(int ef, struct radix_node *rn);
|
||||||
@ -493,7 +491,7 @@ again:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char nbuf[20];
|
static char nbuf[20];
|
||||||
|
|
||||||
static void
|
static void
|
||||||
p_rtnode(void)
|
p_rtnode(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user