sockcmd.c
资源名称:export.zip [点击查看]
上传用户:hepax88
上传日期:2007-01-03
资源大小:1101k
文件大小:1k
源码类别:
TCP/IP协议栈
开发平台:
Visual C++
- /* Socket status display code
- * Copyright 1991 Phil Karn, KA9Q
- */
- #include <stdio.h>
- #include "global.h"
- #include "mbuf.h"
- #include "proc.h"
- #include "lzw.h"
- #include "usock.h"
- #include "socket.h"
- #include "commands.h"
- /* Socket status display command */
- int
- dosock(argc,argv,p)
- int argc;
- char *argv[];
- void *p;
- {
- register struct usock *up;
- int s,i,n;
- struct sockaddr fsock;
- struct socklink *sp;
- char *cp;
- if(argc < 2){
- printf("S# Type PCB Remote socket Ownern");
- for(n=0;n<Nsock;n++){
- s = _mk_fd(n,_FL_SOCK);
- up = itop(s);
- if(up == NULL)
- continue;
- i = sizeof(fsock);
- if(getpeername(s,&fsock,&i) == 0 && i != 0)
- cp = psocket(&fsock);
- else
- cp = "";
- printf("%4d %-8s%-9p %-22s%-9p %-10sn",
- s,Socktypes[up->type],up->cb.p,cp,
- up->owner,up->owner->name);
- }
- return 0;
- }
- s = atoi(argv[1]);
- if(_fd_type(s) != _FL_SOCK){
- printf("Not a valid socketn");
- return 1;
- }
- up = itop(s);
- if(up == NULL){
- printf("Socket not in usen");
- return 1;
- }
- sp = up->sp;
- printf("%s %pn",Socktypes[up->type],up->cb.p);
- if(up->cb.p == NULL)
- return 0;
- if(sp->status != NULL)
- (*sp->status)(up);
- return 0;
- }