}
parms.r_addr = NULL;
- parms.r_prog = program;
- parms.r_vers = version;
- parms.r_netid = nconf->nc_netid;
-
- /*
- * rpcbind ignores the r_owner field in GETADDR requests, but we
- * need to give xdr_rpcb something to gnaw on. Might as well make
- * it something human readable for when we see these in captures.
- */
- parms.r_owner = RPCB_OWNER_STRING;
/*
* Use default total timeout if no timeout is specified.
if (tp == NULL)
tp = &tottimeout;
- /* try rpcbind */
- /* Now the same transport is to be used to get the address */
- if (client && ((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
- (nconf->nc_semantics == NC_TPI_COTS))) {
- /* A CLTS type of client - destroy it */
- CLNT_DESTROY(client);
- client = NULL;
- }
-
- if (client == NULL) {
- client = getclnthandle(host, nconf, &parms.r_addr);
- if (client == NULL) {
- goto error;
- }
- }
- if (parms.r_addr == NULL) {
- /*LINTED const castaway*/
- parms.r_addr = (char *) &nullstring[0];
- }
-
- /* First try from start_vers(4) and then version 3 (RPCBVERS) */
-
- CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *) &rpcbrmttime);
- for (vers = start_vers; vers >= RPCBVERS; vers--) {
- /* Set the version */
- CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers);
- clnt_st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETADDR,
- (xdrproc_t) xdr_rpcb, (char *)(void *)&parms,
- (xdrproc_t) xdr_wrapstring, (char *)(void *) &ua, *tp);
- if (clnt_st == RPC_SUCCESS) {
- if ((ua == NULL) || (ua[0] == 0)) {
- /* address unknown */
- rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
- goto error;
- }
- address = uaddr2taddr(nconf, ua);
-#ifdef ND_DEBUG
- fprintf(stderr, "\tRemote address is [%s]\n", ua);
- if (!address)
- fprintf(stderr,
- "\tCouldn't resolve remote address!\n");
-#endif
- xdr_free((xdrproc_t)xdr_wrapstring,
- (char *)(void *)&ua);
-
- if (! address) {
- /* We don't know about your universal address */
- rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE;
- goto error;
- }
- CLNT_CONTROL(client, CLGET_SVC_ADDR,
- (char *)(void *)&servaddr);
- __rpc_fixup_addr(address, &servaddr);
- goto done;
- } else if (clnt_st == RPC_PROGVERSMISMATCH) {
- struct rpc_err rpcerr;
- clnt_geterr(client, &rpcerr);
- if (rpcerr.re_vers.low > RPCBVERS4)
- goto error; /* a new version, can't handle */
- } else if (clnt_st != RPC_PROGUNAVAIL) {
- /* Cant handle this error */
- rpc_createerr.cf_stat = clnt_st;
- clnt_geterr(client, &rpc_createerr.cf_error);
- goto error;
- }
- }
- /* if rpcbind requests failed -> try portmapper version 2 */
#ifdef PORTMAP
/* Try version 2 for TCP or UDP */
if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
if (clnt_st != RPC_SUCCESS) {
if ((clnt_st == RPC_PROGVERSMISMATCH) ||
(clnt_st == RPC_PROGUNAVAIL))
- goto error; /* All portmap/rpcbind versions failed */
+ goto try_rpcbind;
rpc_createerr.cf_stat = RPC_PMAPFAILURE;
clnt_geterr(client, &rpc_createerr.cf_error);
goto error;
goto done;
}
-
- //try_rpcbind:
+try_rpcbind:
#endif /* PORTMAP */
+ parms.r_prog = program;
+ parms.r_vers = version;
+ parms.r_netid = nconf->nc_netid;
+
+ /*
+ * rpcbind ignores the r_owner field in GETADDR requests, but we
+ * need to give xdr_rpcb something to gnaw on. Might as well make
+ * it something human readable for when we see these in captures.
+ */
+ parms.r_owner = RPCB_OWNER_STRING;
+
+ /* Now the same transport is to be used to get the address */
+ if (client && ((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
+ (nconf->nc_semantics == NC_TPI_COTS))) {
+ /* A CLTS type of client - destroy it */
+ CLNT_DESTROY(client);
+ client = NULL;
+ free(parms.r_addr);
+ parms.r_addr = NULL;
+ }
+
+ if (client == NULL) {
+ client = getclnthandle(host, nconf, &parms.r_addr);
+ if (client == NULL) {
+ goto error;
+ }
+ }
+ if (parms.r_addr == NULL) {
+ /*LINTED const castaway*/
+ parms.r_addr = (char *) &nullstring[0];
+ }
+
+ /* First try from start_vers(4) and then version 3 (RPCBVERS) */
+
+ CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *) &rpcbrmttime);
+ for (vers = start_vers; vers >= RPCBVERS; vers--) {
+ /* Set the version */
+ CLNT_CONTROL(client, CLSET_VERS, (char *)(void *)&vers);
+ clnt_st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETADDR,
+ (xdrproc_t) xdr_rpcb, (char *)(void *)&parms,
+ (xdrproc_t) xdr_wrapstring, (char *)(void *) &ua, *tp);
+ if (clnt_st == RPC_SUCCESS) {
+ if ((ua == NULL) || (ua[0] == 0)) {
+ /* address unknown */
+ rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
+ goto error;
+ }
+ address = uaddr2taddr(nconf, ua);
+#ifdef ND_DEBUG
+ fprintf(stderr, "\tRemote address is [%s]\n", ua);
+ if (!address)
+ fprintf(stderr,
+ "\tCouldn't resolve remote address!\n");
+#endif
+ xdr_free((xdrproc_t)xdr_wrapstring,
+ (char *)(void *)&ua);
+
+ if (! address) {
+ /* We don't know about your universal address */
+ rpc_createerr.cf_stat = RPC_N2AXLATEFAILURE;
+ goto error;
+ }
+ CLNT_CONTROL(client, CLGET_SVC_ADDR,
+ (char *)(void *)&servaddr);
+ __rpc_fixup_addr(address, &servaddr);
+ goto done;
+ } else if (clnt_st == RPC_PROGVERSMISMATCH) {
+ struct rpc_err rpcerr;
+ clnt_geterr(client, &rpcerr);
+ if (rpcerr.re_vers.low > RPCBVERS4)
+ goto error; /* a new version, can't handle */
+ } else if (clnt_st != RPC_PROGUNAVAIL) {
+ /* Cant handle this error */
+ rpc_createerr.cf_stat = clnt_st;
+ clnt_geterr(client, &rpc_createerr.cf_error);
+ goto error;
+ }
+ }
+
if ((address == NULL) || (address->len == 0)) {
rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
clnt_geterr(client, &rpc_createerr.cf_error);