⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dump_sockettab.c

📁 一款类linux的操作系统源码
💻 C
字号:
/* *  Roadrunner/pk *    Copyright (C) 1989-2002  Cornfed Systems, Inc. * *  The Roadrunner/pk operating system is free software; you can *  redistribute and/or modify it under the terms of the GNU General *  Public License, version 2, as published by the Free Software *  Foundation. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public *  License along with this program; if not, write to the Free *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, *  MA 02111-1307 USA * *  More information about the Roadrunner/pk operating system of *  which this file is a part is available on the World-Wide Web *  at: http://www.cornfed.com. * */#include <stdio.h>#include <string.h>#include <sys/socket.h>#include <fs/dump.h>#define SOCKET_HDR \    "sport  dst              dport  rcv       snd       state"static char *socket_states[] = {    "FREE",    "INUSE",    "BOUND",    "LISTEN",    "CONNECTING",    "CONNECTED",    "DISCONNECTING"};voiddump_sockettab(char *s){    socket_t socket;    char s1[32];    int i, j, len, socketcnt = 0;    for (i = 0; i < SOCKETS; i++)	if (sockettab[i].state > SS_FREE) {	    if (socketcnt++ == 0) {		sprintf(s, "%s\n", SOCKET_HDR);		s += strlen(SOCKET_HDR) + 1;	    }	    socket = &(sockettab[i]);	    sprintf(s1, "%u", socket->sport);	    sprintf(s, s1);	    len = strlen(s1);	    s += len;	    for (j = 0; j < 7 - len; j++)		sprintf(s++, " ");	    if (socket->state < SS_CONNECTED) {		sprintf(s, "-                -      ");		s += 24;	    } else {		ip2str(socket->dst, s1);		sprintf(s, s1);		len = strlen(s1);		s += len;		for (j = 0; j < 17 - len; j++)		    sprintf(s++, " ");		sprintf(s1, "%u", socket->dport);		sprintf(s, s1);		len = strlen(s1);		s += len;		for (j = 0; j < 7 - len; j++)		    sprintf(s++, " ");	    }	    sprintf(s1, "%d", socket->rcv_cc);	    sprintf(s, s1);	    len = strlen(s1);	    s += len;	    for (j = 0; j < 10 - len; j++)		sprintf(s++, " ");	    sprintf(s1, "%d", socket->snd_cc);	    sprintf(s, s1);	    len = strlen(s1);	    s += len;	    for (j = 0; j < 10 - len; j++)		sprintf(s++, " ");	    sprintf(s, "%s\n", socket_states[socket->state]);	    s += strlen(socket_states[socket->state]) + 1;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -