/*
* netstat This file contains an implementation of the command
* that helps in debugging the networking modules.
*
* NET-TOOLS A collection of programs that form the base set of the
* NET-3 Networking Distribution for the LINUX operating
* system.
*
* Version: $Id: netstat.c,v 1.1.1.1 2003/08/18 05:40:38 kaohj Exp $
*
* Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* Phil Packer, <pep@wicked.demon.co.uk>
* Johannes Stille, <johannes@titan.os.open.de>
* Bernd Eckenfels, <net-tools@lina.inka.de>
* Phil Blundell <philb@gnu.org>
* Tuan Hoang <tqhoang@bigfoot.com>
*
* Tuned for NET3 by:
* Alan Cox, <A.Cox@swansea.ac.uk>
* Copyright (c) 1993 Fred Baumgarten
*
* Modified:
*
*960116 {1.01} Bernd Eckenfels: verbose, cleanups
*960204 {1.10} Bernd Eckenfels: aftrans, usage, new route_info,
* DLFT_AF
*960204 {1.11} Bernd Eckenfels: netlink support
*960204 {1.12} Bernd Eckenfels: route_init()
*960215 {1.13} Bernd Eckenfels: netlink_print honors HAVE_
*960217 {1.14} Bernd Eckenfels: masq_info from Jos Vos and
* ax25_info from Jonathan Naylor.
*960218 {1.15} Bernd Eckenfels: ipx_info rewritten, -e for tcp/ipx
*960220 {1.16} Bernd Eckenfels: minor output reformats, -a for -x
*960221 {1.17} Bernd Eckenfels: route_init->getroute_init
*960426 {1.18} Bernd Eckenfels: new RTACTION, SYM/NUM, FIB/CACHE
*960517 {1.19} Bernd Eckenfels: usage() spelling fix and --unix inode,
* ':' is part of sock_addr for --inet
*960822 {x.xx} Frank Strauss: INET6 support
*
*970406 {1.33} Philip Copeland Added snmp reporting support module -s
* code provided by Andi Kleen
* (relly needs to be kernel hooked but
* this will do in the meantime)
* minor header file misplacement tidy up.
*980815 {1.xx} Stephane Fillod: X.25 support
*980411 {1.34} Arnaldo Carvalho i18n: catgets -> gnu gettext, substitution
* of sprintf for snprintf
*10/1998 Andi Kleen Use new interface primitives.
*990101 {1.36} Bernd Eckenfels usage updated to include -s and -C -F,
* fixed netstat -rC output (lib/inet_gr.c)
* removed broken NETLINK Support
* fixed format for /proc/net/udp|tcp|raw
* added -w,-t,-u TcpExt support to -s
*990131 {1.37} Jan Kratochvil added -p for prg_cache() & friends
* Flames to <short@ucw.cz>.
* Tuan Hoang added IGMP support for IPv4 and IPv6
*
*990420 {1.38} Tuan Hoang removed a useless assignment from igmp_do_one()
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <ctype.h>
#include <fcntl.h>
#include <netdb.h>
#include <paths.h>
#include <pwd.h>
#include <getopt.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <dirent.h>
#include "net-support.h"
#include "pathnames.h"
#include "version.h"
#include "config.h"
#include "intl.h"
#include "sockets.h"
#include "interface.h"
#include "util.h"
#define PROGNAME_WIDTH 20
#if !defined(s6_addr32) && defined(in6a_words)
#define s6_addr32 in6a_words /* libinet6 */
#endif
#if 0
/* prototypes for statistics.c */
void parsesnmp(int, int, int);
void inittab(void);
#endif
typedef enum {
SS_FREE = 0, /* not allocated */
SS_UNCONNECTED, /* unconnected to any socket */
SS_CONNECTING, /* in process of connecting */
SS_CONNECTED, /* connected to socket */
SS_DISCONNECTING /* in process of disconnecting */
} socket_state;
#define SO_ACCEPTCON (1<<16) /* performed a listen */
#define SO_WAITDATA (1<<17) /* wait data to read */
#define SO_NOSPACE (1<<18) /* no space to write */
#define DFLT_AF "inet"
#define FEATURE_NETSTAT
#include "lib/net-features.h"
char *Release = RELEASE, *Version = "netstat 1.39 (2000-05-21)", *Signature = "Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang and others";
#define E_READ -1
#define E_IOCTL -3
int flag_int = 0;
int flag_rou = 0;
int flag_mas = 0;
int flag_sta = 0;
int flag_all = 0;
int flag_lst = 0;
int flag_cnt = 0;
int flag_deb = 0;
int flag_not = 0;
int flag_cf = 0;
int flag_opt = 0;
int flag_raw = 0;
int flag_tcp = 0;
int flag_udp = 0;
int flag_igmp= 0;
int flag_rom = 0;
int flag_exp = 1;
int flag_prg = 0;
int flag_arg = 0;
int flag_ver = 0;
int flag_x25 = 0;
FILE *procinfo;
#define INFO_GUTS1(file,name,proc) \
procinfo = fopen((file), "r"); \
if (procinfo == NULL) { \
if (errno != ENOENT) { \
perror((file)); \
return -1; \
} \
if (flag_arg || flag_ver) \
ESYSNOT("netstat", (name)); \
if (flag_arg) \
rc = 1; \
} else { \
do { \
if (fgets(buffer, sizeof(buffer), procinfo)) \
(proc)(lnr++, buffer); \
} while (!feof(procinfo)); \
fclose(procinfo); \
}
#if HAVE_AFINET6
#define INFO_GUTS2(file,proc) \
lnr = 0; \
procinfo = fopen((file), "r"); \
if (procinfo != NULL) { \
do { \
if (fgets(buffer, sizeof(buffer), procinfo)) \
(proc)(lnr++, buffer); \
} while (!feof(procinfo)); \
fclose(procinfo); \
}
#else
#define INFO_GUTS2(file,proc)
#endif
#define INFO_GUTS3 \
return rc;
#define INFO_GUTS6(file,file6,name,proc) \
char buffer[8192]; \
int rc = 0; \
int lnr = 0; \
if (!flag_arg || flag_inet) { \
INFO_GUTS1(file,name,proc) \
} \
if (!flag_arg || flag_inet6) { \
INFO_GUTS2(file6,proc) \
} \
INFO_GUTS3
#define INFO_GUTS(file,name,proc) \
char buffer[8192]; \
int rc = 0; \
int lnr = 0; \
INFO_GUTS1(file,name,proc) \
INFO_GUTS3
#define PROGNAME_WIDTHs PROGNAME_WIDTH1(PROGNAME_WIDTH)
#define PROGNAME_WIDTH1(s) PROGNAME_WIDTH2(s)
#define PROGNAME_WIDTH2(s) #s
#define PRG_HASH_SIZE 211
static struct prg_node {
struct prg_node *next;
int inode;
char name[PROGNAME_WIDTH];
} *prg_hash[PRG_HASH_SIZE];
static char prg_cache_loaded = 0;
#define PRG_HASHIT(x) ((x) % PRG_HASH_SIZE)
#define PROGNAME_BANNER "PID/Program name"
#define print_progname_banner() do { if (flag_prg) printf("%-" PROGNAME_WIDTHs "s"," " PROGNAME_BANNER); } while (0)
#define PRG_LOCAL_ADDRESS "local_address"
#define PRG_INODE "inode"
#define PRG_SOCKET_PFX "socket:["
#define PRG_SOCKET_PFXl (strlen(PRG_SOCKET_PFX))
#define PRG_SOCKET_PFX2 "[0000]:"
#define PRG_SOCKET_PFX2l (strlen(PRG_SOCKET_PFX2))
#ifndef LINE_MAX
#define LINE_MAX 4096
#endif
#define PATH_PROC "/proc"
#define PATH_FD_SUFF "fd"
#define PATH_FD_SUFFl strlen(PATH_FD_SUFF)
#define PATH_PROC_X_FD PATH_PROC "/%s/" PATH_FD_SUFF
#define PATH_CMDLINE "cmdline"
#define PATH_CMDLINEl strlen(PATH_CMDLINE)
/* NOT working as of glibc-2.0.7: */
#undef DIRENT_HAVE_D_TYPE_WORKS
static void prg_cache_add(int inode, char *name)
{
unsigned hi = PRG_HASHIT(inode);
没有合适的资源?快使用搜索试试~ 我知道了~
路由器表指令/bin/route
共77个文件
c:54个
h:13个
org:2个
需积分: 2 0 下载量 38 浏览量
2023-07-26
15:40:49
上传
评论
收藏 123KB RAR 举报
温馨提示
路由器表指令,eg: /bin/route add -net netaddr dev ifname metric 11 /bin/route del -net netaddr dev ifname /bin/route -A -net6 add ::/0 gw remoteIPv6AddrStr dev wanif
资源推荐
资源详情
资源评论
收起资源包目录
route.rar (77个子文件)
route
include
interface.h 3KB
ipx.h 610B
mii.h 2KB
util-ank.h 2KB
sockets.h 130B
lib
setroute.c 2KB
inet6_sr.c 4KB
ppp_ac.c 1KB
netrom_sr.c 880B
irda.c 2KB
frame.c 1KB
ppp.c 1KB
hw.c 5KB
inet.c 10KB
af.c 6KB
ax25_gr.c 2KB
net-features.h 4KB
proc.h 170B
inet_gr.c 12KB
proc.c 2KB
hippi.c 4KB
Makefile 695B
getargs.c 2KB
ipx.c 4KB
ipx_sr.c 692B
rose.c 4KB
util.c 969B
fddi.c 3KB
loopback.c 2KB
net-support.h 8KB
nstrcmp.c 619B
ddp.c 2KB
util.h 335B
sit.c 1KB
ash.c 2KB
inet6_gr.c 8KB
masq_info.c 6KB
slip_ac.c 3KB
getroute.c 3KB
Makefile.org 2KB
netrom.c 5KB
inet_sr.c 8KB
activate.c 2KB
interface.c 11KB
arcnet.c 3KB
sockets.c 2KB
inet6.c 4KB
tr.c 3KB
slip.c 2KB
util-ank.c 6KB
ddp_gr.c 468B
ether.c 4KB
rose_gr.c 2KB
hdlclapb.c 2KB
netrom_gr.c 2KB
ax25.c 5KB
tunnel.c 763B
econet.c 2KB
pathnames.h 2KB
unix.c 2KB
ipx_gr.c 2KB
README 3KB
Makefile 1KB
netstat.c 49KB
mii-tool.c 13KB
arp.c 20KB
README.ipv6 1KB
config.h 1KB
INSTALLING 1KB
Makefile.org 7KB
version.h 33B
ABOUT-NLS 9KB
route.c 7KB
intl.h 216B
ifconfig.c 27KB
TODO 1KB
COPYING 18KB
共 77 条
- 1
资源评论
kevin_0903
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功