/**********************************************************************
* ONC RPC for WIN32.
* 1997 by WD Klotz
* ESRF, BP 220, F-38640 Grenoble, CEDEX
* klotz-tech@esrf.fr
*
* SUN's ONC RPC for Windows NT and Windows 95. Ammended port from
* Martin F.Gergeleit's distribution. This version has been modified
* and cleaned, such as to be compatible with Windows NT and Windows 95.
* Compiler: MSVC++ version 4.2 and 5.0.
*
* Users may use, copy or modify Sun RPC for the Windows NT Operating
* System according to the Sun copyright below.
* RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
* WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
* USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
**********************************************************************/
/*********************************************************************
* RPC for the Windows NT Operating System
* 1993 by Martin F. Gergeleit
* Users may use, copy or modify Sun RPC for the Windows NT Operating
* System according to the Sun copyright below.
*
* RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
* WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
* USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
*********************************************************************/
/*
* Copyright (C) 1986, Sun Microsystems, Inc.
*/
/*
* rpcinfo: ping a particular rpc program
* or dump the portmapper
*/
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
*
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
*
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
*
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
*
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
#include <rpc/rpc.h>
#include <stdio.h>
#ifdef WIN32
#include <rpc/pmap_pro.h>
#include <rpc/pmap_cln.h>
#include "getopt.c"
#else
#include <sys/socket.h>
#include <netdb.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <signal.h>
#include <ctype.h>
#endif
#define MAXHOSTLEN 256
#define MIN_VERS ((u_long) 0)
#define MAX_VERS ((u_long) 4294967295L)
static void udpping(/*u_short portflag, int argc, char **argv*/);
static void tcpping(/*u_short portflag, int argc, char **argv*/);
static int pstatus(/*CLIENT *client, u_long prognum, u_long vers*/);
static void pmapdump(/*int argc, char **argv*/);
static bool_t reply_proc(/*void *res, struct sockaddr_in *who*/);
static void brdcst(/*int argc, char **argv*/);
static void deletereg(/* int argc, char **argv */) ;
static void usage(/*void*/);
static u_long getprognum(/*char *arg*/);
static u_long getvers(/*char *arg*/);
static void get_inet_address(/*struct sockaddr_in *addr, char *host*/);
#ifndef WIN32
extern u_long inet_addr(); /* in 4.2BSD, arpa/inet.h called that a in_addr */
extern char *inet_ntoa();
#endif
/*
* Functions to be performed.
*/
#define NONE 0 /* no function */
#define PMAPDUMP 1 /* dump portmapper registrations */
#define TCPPING 2 /* ping TCP service */
#define UDPPING 3 /* ping UDP service */
#define BRDCST 4 /* ping broadcast UDP service */
#define DELETES 5 /* delete registration for the service */
/* stuff added to allow arbitrary procedure calling,
modified getvers() and all its uses to pick-up an optional
proc. number */
u_long anyproc = NULLPROC;
int
main(argc, argv)
int argc;
char **argv;
{
register int c;
extern char *optarg;
extern int optind;
int errflg;
int function;
u_short portnum;
#ifdef WIN32
rpc_nt_init();
#endif
function = NONE;
portnum = 0;
errflg = 0;
while ((c = getopt(argc, argv, "cptubdn:")) != EOF) {
switch (c) {
case 'p':
if (function != NONE)
errflg = 1;
else
function = PMAPDUMP;
break;
case 't':
if (function != NONE)
errflg = 1;
else
function = TCPPING;
break;
case 'u':
if (function != NONE)
errflg = 1;
else
function = UDPPING;
break;
case 'b':
if (function != NONE)
errflg = 1;
else
function = BRDCST;
break;
case 'n':
portnum = (u_short) atoi(optarg); /* hope we don't get bogus # */
break;
case 'd':
if (function != NONE)
errflg = 1;
else
function = DELETES;
break;
case '?':
errflg = 1;
}
}
if (errflg || function == NONE) {
usage();
return (1);
}
switch (function) {
case PMAPDUMP:
if (portnum != 0) {
usage();
return (1);
}
pmapdump(argc - optind, argv + optind);
break;
case UDPPING:
udpping(portnum, argc - optind, argv + optind);
break;
case TCPPING:
tcpping(portnum, argc - optind, argv + optind);
break;
case BRDCST:
if (portnum != 0) {
usage();
return (1);
}
brdcst(argc - optind, argv + optind);
break;
case DELETES:
deletereg(argc - optind, argv + optind);
break;
}
#ifdef WIN32
rpc_nt_exit();
#endif
return (0);
}
static void
udpping(portnum, argc, argv)
u_short portnum;
int argc;
char **argv;
{
struct timeval to;
struct sockaddr_in addr;
enum clnt_stat rpc_stat;
CLIENT *client;
u_long prognum, vers, minvers, maxvers;
int sock = RPC_ANYSOCK;
struct rpc_err rpcerr;
int failure;
if (argc < 2 || argc > 4) {
usage();
exit(1);
}
prognum = getprognum(argv[1]);
get_inet_address(&addr, argv[0]);
/* Open the socket here so it will survive calls to clnt_destroy */
sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock < 0) {
perror("rpcinfo: socket");
exit(1);
}
failure = 0;
if (argc == 2) {
/*
* A call to version 0 should fail with a program/version
* mismatch, and give us the range of versions supported.
*/
addr.sin_port = htons(portnum);
to.tv_sec = 5;
to.tv_usec = 0;
if ((client = clntudp_create(&addr, prognum, (u_long)0,
to, &sock)) == NULL) {
clnt_pcreateerror("rpcinfo");
printf("program %lu is not available\n",
prognum);
exit(1);
}
to.tv_sec = 10;
to.tv_usec = 0;
rpc_stat = clnt_call(client, anyproc, xdr_void, (char *)NULL,
xdr_void, (char *)NULL, to);
if (rpc_stat == RPC_PROGVERSMISMATCH) {
clnt_geterr(client, &rpcerr);
minvers = rpcerr.re_vers.low;
maxvers = rpcerr.re_vers.high;
} else if (rpc_stat == RPC_SUCCESS) {
/*
* Oh dear, it DOES support version 0.
* Let's try version MAX_VERS.
*/
addr.sin_port = htons(portnum);
to.tv_sec = 5;
to.tv_usec = 0;
if ((client = clntudp_create(&addr, prognum, MAX_VERS,
to, &sock)) == NULL) {
clnt_pcreateerror("rpcinfo");
printf("program %lu version %lu is not available\n",
prognum, MAX_VERS);
exit(1);
}
to.tv_sec = 10;
to.tv_usec = 0;
rpc_stat = clnt_call(client, anyproc, xdr_void,
(char *)NULL, xdr_void, (char *)NULL, to);
if (rpc_stat == RPC
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
onc/rpc源代码 (267个子文件)
oncrpc.001 8KB
portmap.001 3KB
oncrpc.bak 94KB
makefile.bc 2KB
makefile.bc 2KB
makefile.bc 1KB
makefile.bc 904B
rpcinfo.c 19KB
Xdr_rec.c 17KB
Clnt_tcp.c 15KB
Clnt_udp.c 15KB
Svc_udp.c 14KB
Svc.c 14KB
Pmap_rmt.c 13KB
Xdr.c 13KB
Svc_tcp.c 13KB
rpc_svco.c 12KB
portmap.c 12KB
rpc_main.c 12KB
rpc_pars.c 11KB
rpc_hout.c 10KB
portmap.c 10KB
rpc_scan.c 10KB
service.c 10KB
Auth_uni.c 10KB
rpc_util.c 9KB
xdr_floa.c 9KB
rpc_cout.c 9KB
rpc_prot.c 9KB
Clnt_per.c 8KB
clnt_raw.c 7KB
rpc_call.c 7KB
Getrpcen.c 6KB
xdr_stdi.c 6KB
Svc_simp.c 6KB
Xdr_arra.c 6KB
Svc_autu.c 6KB
xdr_mem.c 6KB
svc_raw.c 6KB
pmap_pro.c 5KB
svc_auth.c 5KB
Xdr_refe.c 5KB
rpc_clnt.c 5KB
clnt_sim.c 5KB
clnt_gen.c 5KB
Pmap_cln.c 5KB
Auth_non.c 5KB
Get_myad.c 4KB
pmap_get.c 4KB
Bindresv.c 4KB
pmap_gma.c 4KB
Svc_run.c 4KB
authunix.c 3KB
pmap_pr.c 3KB
Getrpcpo.c 3KB
rpc_comm.c 3KB
inst_pm.c 3KB
Xdr_strarr.c 3KB
nt.c 2KB
getopt.c 2KB
bcopy.c 2KB
oncbcimp.def 2KB
oncrpc.def 1KB
oncrpc.dll 256KB
oncrpc.dsp 8KB
oncrpc_static.dsp 5KB
inst_pm.dsp 4KB
portmap.dsp 3KB
portmap.dsw 1KB
oncrpc.dsw 750B
inst_pm.exe 152KB
portmap.exe 122KB
portmap.exe 122KB
inst_pm.exe 96KB
inst_pm.exe 96KB
rpcgen.exe 81KB
rpcgen.exe 81KB
rpcinfo.exe 56KB
rpcinfo.exe 56KB
COU_svc.exe 41KB
do_cou.exe 39KB
oncrpc.exp 10KB
portmap.exp 776B
rpcinfo.exp 526B
xdr.h 11KB
clnt.h 10KB
svc.h 10KB
auth.h 7KB
rpc_msg.h 6KB
rpc_pars.h 5KB
Rpc.h 5KB
Pmap_pro.h 5KB
rpc_util.h 4KB
Pmap_cln.h 4KB
auth_uni.h 4KB
rpc_scan.h 4KB
types.h 4KB
Netdb.h 3KB
pmap_rmt.h 3KB
svc_auth.h 3KB
共 267 条
- 1
- 2
- 3
songshengjin
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页