/*
* 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.27 1999/04/20 14:28:14 philip Exp $
*
* Authors: Fred Baumgarten, <[email protected]>
* Fred N. van Kempen, <[email protected]>
* Phil Packer, <[email protected]>
* Johannes Stille, <[email protected]>
* Bernd Eckenfels, <[email protected]>
* Phil Blundell <[email protected]>
* Tuan Hoang <[email protected]>
*
* Tuned for NET3 by:
* Alan Cox, <[email protected]>
* 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.
*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 <[email protected]>.
* 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 <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"
#define PROGNAME_WIDTH 20
#if !defined(s6_addr32) && defined(in6a_words)
#define s6_addr32 in6a_words /* libinet6 */
#endif
/* prototypes for statistics.c */
void parsesnmp(int, int, int);
void inittab(void);
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.38 (1999-04-20)", *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;
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))
#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);
struct prg_node **pnp,*pn;
prg_cache_loaded=2;
for (pnp=prg_hash+hi;(pn=*pnp);pnp=&pn->next) {
if (pn->inode==inode) {
/* Some warning should be appropriate here
as we got multiple processe
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
net-tools-1.52.tar.gz_LINUX NET_linux 网络_net_net tools unix_net- (140个子文件)
hostname.1 6KB
hostname.1 5KB
hostname.1 5KB
hostname.1 5KB
ypdomainname.1 20B
domainname.1 20B
nisdomainname.1 20B
dnsdomainname.1 20B
ypdomainname.1 20B
domainname.1 20B
nisdomainname.1 20B
dnsdomainname.1 20B
ypdomainname.1 20B
domainname.1 20B
nisdomainname.1 20B
dnsdomainname.1 20B
ypdomainname.1 20B
domainname.1 20B
nisdomainname.1 20B
dnsdomainname.1 20B
ethers.5 1KB
ethers.5 1KB
ethers.5 944B
netstat.8 11KB
netstat.8 11KB
netstat.8 10KB
netstat.8 10KB
route.8 9KB
route.8 8KB
route.8 8KB
route.8 7KB
ifconfig.8 7KB
ifconfig.8 6KB
ifconfig.8 6KB
ifconfig.8 6KB
arp.8 5KB
arp.8 5KB
arp.8 5KB
arp.8 4KB
slattach.8 3KB
slattach.8 3KB
slattach.8 3KB
rarp.8 2KB
rarp.8 2KB
rarp.8 2KB
rarp.8 2KB
plipconfig.8 2KB
plipconfig.8 2KB
plipconfig.8 1KB
ABOUT-NLS 9KB
netstat.c 45KB
ifconfig.c 27KB
arp.c 20KB
slattach.c 15KB
iptunnel.c 14KB
inet_gr.c 12KB
interface.c 11KB
hostname.c 10KB
statistics.c 10KB
inet.c 9KB
ipmaddr.c 8KB
inet_sr.c 8KB
inet6_gr.c 8KB
rarp.c 7KB
route.c 7KB
af.c 6KB
masq_info.c 6KB
util-ank.c 6KB
hw.c 5KB
netrom.c 5KB
ax25.c 5KB
ipx.c 4KB
inet6_sr.c 4KB
rose.c 4KB
inet6.c 4KB
hippi.c 4KB
fddi.c 3KB
ether.c 3KB
plipconfig.c 3KB
arcnet.c 3KB
tr.c 3KB
getroute.c 3KB
slip_ac.c 3KB
setroute.c 2KB
irda.c 2KB
activate.c 2KB
getargs.c 2KB
unix.c 2KB
netrom_gr.c 2KB
ash.c 2KB
ipx_gr.c 2KB
econet.c 2KB
rose_gr.c 2KB
loopback.c 2KB
ax25_gr.c 2KB
slip.c 2KB
ddp.c 2KB
hdlclapb.c 2KB
proc.c 2KB
sockets.c 1KB
共 140 条
- 1
- 2
资源评论
weixin_42651887
- 粉丝: 79
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- unity控制对象移动.rar
- TortoiseSVN-1.14.3.29387-x64-svn-1.14.2
- jdk-8u411-macosx-aarch64.dmg
- docker安装.rar
- 美赛数学建模算法-使用Matlab实现常微分方程OridinaryDifferentialEquation-国赛-题解.zip
- FileUploadTestController.java
- 基于MATLAB的数字水印系统源码+GUI操作界面+全部数据资料+使用文档(高分课程设计).zip
- 美赛数学建模算法-使用Matlab实现非线性规划NonLinearProgramming-国赛-题解.zip
- linux安装java8环境资源包
- pcb问题和3D猴制作外壳.7z
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功