Changeset b6ac989 in rtems-libbsd


Ignore:
Timestamp:
Oct 17, 2012, 4:13:36 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
Children:
2cf245e
Parents:
99ae4eb
Message:

Add netstat command

This adds the netstat command. All but one file is currently enabled.
That file does not currently build.

Also added libmemstat and libutil. libmemstat had a lot of code related
to kvm and kernel memory access disabled. This may or may not be an
issue.

Location:
freebsd-userspace
Files:
14 added
7 edited

Legend:

Unmodified
Added
Removed
  • freebsd-userspace/Makefile

    r99ae4eb rb6ac989  
    1010CFLAGS += -Ilib/libc/resolv
    1111CFLAGS += -Ilib/netgraph
     12CFLAGS += -Ilib/libmemstat
     13CFLAGS += -Ilib/libutil
    1214CFLAGS += -Isys
    1315CFLAGS += -Ilocal
     
    1921CFLAGS += -I$(INSTALL_BASE)/include
    2022
     23#Only needed for route
     24# CFLAGS += -D__BSD_VISIBLE=1
    2125#Only Needed for db files
    2226CFLAGS += -D__DBINTERFACE_PRIVATE
     
    129133C_FILES += lib/libc/db/mpool/mpool.c
    130134
     135# libmemstat
     136C_FILES += lib/libmemstat/memstat_all.c
     137C_FILES += lib/libmemstat/memstat.c
     138C_FILES += lib/libmemstat/memstat_malloc.c
     139C_FILES += lib/libmemstat/memstat_uma.c
     140
     141# libutil
     142C_FILES += lib/libutil/expand_number.c
     143C_FILES += lib/libutil/humanize_number.c
    131144
    132145# libipsec files
     
    207220# C_FILES += commands/sbin/ifconfig/af_ipx.c
    208221
    209 ifeq (1,0)
    210222# netstat command sources
    211223# no need to support AppleTalk yet
     
    219231# C_FILES += commands/usr.bin/netstat/ipx.c
    220232C_FILES += commands/usr.bin/netstat/main.c
    221 C_FILES += commands/usr.bin/netstat/mbuf.c
     233# XXX does not compile yet
     234# C_FILES += commands/usr.bin/netstat/mbuf.c
    222235C_FILES += commands/usr.bin/netstat/mroute6.c
    223236C_FILES += commands/usr.bin/netstat/mroute.c
     
    228241C_FILES += commands/usr.bin/netstat/sctp.c
    229242C_FILES += commands/usr.bin/netstat/unix.c
    230 endif
    231243
    232244C_O_FILES = $(C_FILES:%.c=%.o)
  • freebsd-userspace/commands/usr.bin/netstat/if.c

    r99ae4eb rb6ac989  
    8181#include <err.h>
    8282#include <errno.h>
    83 #ifdef __rtems__
    84 /* apparently libutil.h is not needed */
    85 #else
    8683#include <libutil.h>
    87 #endif
    8884#include <signal.h>
    8985#include <stdint.h>
     
    208204                struct in6_ifaddr in6;
    209205#endif
     206#ifndef __rtems__
    210207                struct ipx_ifaddr ipx;
     208#endif
    211209        } ifaddr;
    212210        u_long ifaddraddr;
     
    381379                                break;
    382380#endif /*INET6*/
     381#ifndef __rtems__
    383382                        case AF_IPX:
    384383                                {
     
    398397                                network_layer = 1;
    399398                                break;
     399#endif
    400400
    401401                        case AF_APPLETALK:
  • freebsd-userspace/commands/usr.bin/netstat/inet.c

    r99ae4eb rb6ac989  
    6767#include <netinet/ip6.h>
    6868#endif /* INET6 */
     69#ifdef __rtems__
     70#include <freebsd/netinet/in_pcb.h>
     71#else
    6972#include <netinet/in_pcb.h>
     73#endif
    7074#include <netinet/ip_icmp.h>
     75#ifdef __rtems__
     76#include <freebsd/netinet/icmp_var.h>
     77#include <freebsd/netinet/igmp_var.h>
     78#include <freebsd/netinet/ip_var.h>
     79#include <freebsd/netinet/pim_var.h>
     80#include <netinet/tcp.h>
     81#include <freebsd/netinet/tcpip.h>
     82#include <freebsd/netinet/tcp_seq.h>
     83#define TCPSTATES
     84#include <freebsd/netinet/tcp_fsm.h>
     85#include <freebsd/netinet/tcp_timer.h>
     86#include <freebsd/netinet/tcp_var.h>
     87#include <freebsd/netinet/tcp_debug.h>
     88#include <netinet/udp.h>
     89#include <freebsd/netinet/udp_var.h>
     90#else
    7191#include <netinet/icmp_var.h>
    7292#include <netinet/igmp_var.h>
     
    83103#include <netinet/udp.h>
    84104#include <netinet/udp_var.h>
     105#endif
    85106
    86107#include <arpa/inet.h>
  • freebsd-userspace/commands/usr.bin/netstat/main.c

    r99ae4eb rb6ac989  
     1#ifdef __rtems__
     2#define __need_getopt_newlib
     3#include <getopt.h>
     4#endif
    15/*-
    26 * Copyright (c) 1983, 1988, 1993
     
    6670#include <err.h>
    6771#include <errno.h>
     72#ifndef __rtems__
    6873#include <kvm.h>
     74#endif
    6975#include <limits.h>
    7076#include <netdb.h>
     
    324330static struct protox *knownname(const char *);
    325331
     332#ifndef __rtems__
    326333static kvm_t *kvmd;
     334#endif
    327335static char *nlistf = NULL, *memf = NULL;
    328336
     
    357365
    358366int
     367#ifdef __rtems__
     368main_netstat(int argc, char *argv[])
     369#else
    359370main(int argc, char *argv[])
     371#endif
    360372{
    361373        struct protox *tp = NULL;  /* for printing cblocks & stats */
    362374        int ch;
     375#ifdef __rtems__
     376        struct getopt_data getopt_reent;
     377#endif
    363378
    364379        af = AF_UNSPEC;
    365380
     381#ifdef __rtems__
     382        memset(&getopt_reent, 0, sizeof(getopt_data));
     383        while ((ch = getopt_r(argc, argv, "AaBbdf:ghI:iLlM:mN:np:q:rSstuWw:xz", &getopt_reent)) != -1)
     384#else
    366385        while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:q:rSstuWw:xz")) != -1)
     386#endif
    367387                switch(ch) {
    368388                case 'A':
     
    509529#endif
    510530
     531#ifndef __rtems__
    511532        /*
    512533         * Discard setgid privileges if not the running kernel so that bad
     
    531552                exit(0);
    532553        }
     554#endif
    533555#if 0
    534556        /*
     
    545567         */
    546568#endif
     569#ifndef __rtems__
    547570        kread(0, NULL, 0);
     571#endif
    548572        if (iflag && !sflag) {
    549573                intpr(interval, nl[N_IFNET].n_value, NULL);
     
    680704}
    681705
     706#ifndef __rtems__
    682707/*
    683708 * Read kernel memory, return 0 on success.
     
    719744        return (0);
    720745}
     746#endif
    721747
    722748const char *
     
    804830        exit(1);
    805831}
     832
     833#ifdef __rtems__
     834  #include <rtems/shell.h>
     835
     836  rtems_shell_cmd_t rtems_shell_NETSTAT_Command = {
     837    "netstat",                     /* name */
     838    "netstat [args]",              /* usage */
     839    "net",                         /* topic */
     840    main_netstat,                  /* command */
     841    NULL,                          /* alias */
     842    NULL                           /* next */
     843  };
     844#endif
  • freebsd-userspace/commands/usr.bin/netstat/mbuf.c

    r99ae4eb rb6ac989  
    5757
    5858#include <err.h>
    59 #ifdef __rtems__
    60 /* XXX what to do? */
    61 #else
     59#ifndef __rtems__
    6260#include <kvm.h>
     61#endif
    6362#include <memstat.h>
    64 #endif
    6563#include <stdint.h>
    6664#include <stdio.h>
     
    111109                }
    112110        } else {
     111#ifndef __rtems__
    113112                if (memstat_kvm_all(mtlp, kvmd) < 0) {
    114113                        error = memstat_mtl_geterror(mtlp);
     
    121120                        goto out;
    122121                }
     122#endif
    123123        }
    124124
  • freebsd-userspace/commands/usr.bin/netstat/unix.c

    r99ae4eb rb6ac989  
    6060#include <sys/sysctl.h>
    6161#include <sys/un.h>
     62#ifndef __rtems__
    6263#include <sys/unpcb.h>
     64#endif
    6365
    6466#include <netinet/in.h>
     
    7173#include <stdlib.h>
    7274#include <strings.h>
     75#ifndef __rtems__
    7376#include <kvm.h>
     77#endif
    7478#include "netstat.h"
    7579
     
    107111}
    108112
     113#ifndef __rtems__
    109114static int
    110115pcblist_kvm(u_long count_off, u_long gencnt_off, u_long head_off, char **bufp)
     
    293298        putchar('\n');
    294299}
     300#endif
  • freebsd-userspace/rtems/include/rtems/netcmds-config.h

    r99ae4eb rb6ac989  
    2828  extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command;
    2929  extern rtems_shell_cmd_t rtems_shell_ROUTE_Command;
    30   // extern rtems_shell_cmd_t rtems_shell_NETSTATS_Command;
     30  extern rtems_shell_cmd_t rtems_shell_NETSTAT_Command;
    3131// #endif
    3232
Note: See TracChangeset for help on using the changeset viewer.