312 lines
8.2 KiB
HTML
312 lines
8.2 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>rpcb_getaddr()--Find the Universal Address of a Service</title>
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- RPCMST SCRIPT A converted by B2H R4.1 (346) (CMS) by PMHALL at -->
|
||
|
<!-- RCHVMW2 on 7 Oct 1998 at 23:43:14 -->
|
||
|
<!-- Edited by Kersten Feb 02 -->
|
||
|
<!--End Header Records -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<!-- Java sync-link -->
|
||
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
||
|
</script>
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
<h2>rpcb_getaddr()--Find the Universal Address of a Service</h2>
|
||
|
|
||
|
<div class="box" style="width: 60%;">
|
||
|
<br>
|
||
|
Syntax<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
<pre>
|
||
|
#include <rpc/rpc.h>
|
||
|
#include <netconfig.h>
|
||
|
|
||
|
bool_t rpcb_getaddr(const u_long <em>prognum</em>,
|
||
|
const u_long <em>versnum</em>,
|
||
|
const struct netconfig *<em>netconf</em>,
|
||
|
struct netbuf *<em>svcaddr</em>,
|
||
|
const char *<em>host</em>);
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
Service Program Name: QZNFTRPC<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: No<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The <strong>rpcb_getaddr()</strong> function is an interface to the RPC
|
||
|
service package (RPCBind). The function finds the address of the service on the
|
||
|
<em>host</em> that is registered with program number <em>prognum</em> and
|
||
|
version <em>versnum</em>, and uses the transport protocol that is associated
|
||
|
with <em>netconf</em>.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>prognum</strong> (Input) </dt>
|
||
|
|
||
|
<dd>The program number of the remote program.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>vernum</strong> (Input) </dt>
|
||
|
|
||
|
<dd>The version number of the remote program.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>netconf</strong> (Input) </dt>
|
||
|
|
||
|
<dd>The transport protocol.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>svcaddr</strong> (Output) </dt>
|
||
|
|
||
|
<dd>A pointer to the address of the requested service on the remote
|
||
|
<em>host</em> machine.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>host</strong> (Input) </dt>
|
||
|
|
||
|
<dd>The name of the remote host where the server is located.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Authorities</h3>
|
||
|
|
||
|
<p>The caller of the <strong>rpcb_getaddr()</strong> API must have execute (*X)
|
||
|
authority to the /etc directory and must have read (*R) authority to the
|
||
|
netconfig file.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="15 85" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>TRUE (1)</em></td>
|
||
|
<td align="left" valign="top"><strong>rpcb_getaddr()</strong> was successful.
|
||
|
The address of the remote service in the <em>svcaddr</em> parameter was
|
||
|
returned.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>FALSE (0)</em></td>
|
||
|
<td align="left" valign="top"><strong>rpcb_getaddr()</strong> was
|
||
|
unsuccessful.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Error Conditions</h3>
|
||
|
|
||
|
<p>Upon failure, <strong>rpcb_getaddr()</strong> sets the global structure
|
||
|
<em>rpc_createerr</em>. The <em>rpc_createerr.cf_stat</em> variable contains a
|
||
|
status value, which indicates the error reason. The
|
||
|
<em>rpc_createerr.cf_error.re_errno</em> variable is meaningful when some
|
||
|
status values are set.</p>
|
||
|
|
||
|
<p>The <em>rpc_createerr.cf_stat</em> variable can be set to one of the
|
||
|
following values:</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="30 70" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_FAILED]</em></td>
|
||
|
<td align="left" valign="top">The buffer referenced by the <em>svcaddr</em>
|
||
|
parameter does not have enough space. re_errno field is set to ENOBUFS.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_INTR]</em></td>
|
||
|
<td align="left" valign="top">Interrupted RPC call. An exception has occurred
|
||
|
in the RPC API. The <em>rpc_createerr.cf_error.re_errno</em> is set to
|
||
|
EUNKNOWN.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_N2AXLATEFAILURE]</em></td>
|
||
|
<td align="left" valign="top">Name-to-address translation failed.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_PROGNOTREGISTERED]</em></td>
|
||
|
<td align="left" valign="top">Remote program is not registered.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_RPCBFAILURE]</em></td>
|
||
|
<td align="left" valign="top">Unable to contact the RPCBind daemon.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_UNKNOWNADDR]</em></td>
|
||
|
<td align="left" valign="top">Unknown address. The <em>svcaddr</em> is
|
||
|
invalid.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_UNKNOWNHOST]</em></td>
|
||
|
<td align="left" valign="top">Unknown host. The
|
||
|
<em>rpc_createerr.cf_error.re_errno</em> variable is not applicable.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>[RPC_UNKNOWNPROTO]</em></td>
|
||
|
<td align="left" valign="top">Unknown client/server protocol. The
|
||
|
<em>rpc_createerr.cf_error.re_errno</em> is set with errno value returned from
|
||
|
the <strong>setnetconfig()</strong> or <strong>getnetconfig()</strong>
|
||
|
call.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>This API calls <strong>clnt_tli_create()</strong> and
|
||
|
<strong>clnt_call()</strong> APIs. It inherits RPC_SYSTEMERROR from
|
||
|
<strong>clnt_tli_create()</strong> API and it inherits all error conditions
|
||
|
from <strong>clnt_call()</strong> API except RPC_TIMEDOUT,
|
||
|
RPC_PROGNOTREGISTERED, RPC_PROGVERSMISMATCH, and RPC_FAILED.</p>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Error Messages</h3>
|
||
|
|
||
|
<table width="100%" cellpadding="5">
|
||
|
<!-- cols="15 85" -->
|
||
|
<tr>
|
||
|
<th align="left" valign="top">Message ID</th>
|
||
|
<th align="left" valign="top">Error Message Text</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td width="15%" valign="top">CPIA1B1 I</td>
|
||
|
<td width="85%" valign="top">A problem was encountered in the RPC client.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">CPIA1B2 I</td>
|
||
|
<td align="left" valign="top">TI-RPC encountered a problem in the transport
|
||
|
protocol.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">CPIA1B8 I</td>
|
||
|
<td align="left" valign="top">A problem occurred while trying to contact the
|
||
|
RPCBind daemon.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">CPE3418 E</td>
|
||
|
<td align="left" valign="top">Possible APAR condition or hardware failure.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">CPF3CF2 E</td>
|
||
|
<td align="left" valign="top">Error(s) occurred during running of &1
|
||
|
API.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">CPF9872 E</td>
|
||
|
<td align="left" valign="top">Program or service program &1 in library
|
||
|
&2 ended. Reason code &3.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Example</h3>
|
||
|
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
|
||
|
<p>The following example shows how <strong>rpcb_getaddr</strong> is used:</p>
|
||
|
|
||
|
<pre>
|
||
|
/* Define remote program number and version */
|
||
|
#define RMTPROGNUM (u_long)0x3fffffffL
|
||
|
#define RMTPROGVER (u_long)0x1
|
||
|
#define ADDBUFSIZE 100
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <rpc/rpc.h>
|
||
|
#include <netconfig.h>
|
||
|
|
||
|
main()
|
||
|
{
|
||
|
struct netconfig *nconf;
|
||
|
struct netbuf *svcaddr;
|
||
|
char addrbuf[ADDRBUFSIZE];
|
||
|
...
|
||
|
|
||
|
svcaddr.len = 0;
|
||
|
svcaddr.maxlen = ADDRBUFSIZE;
|
||
|
svcaddr.buf = addrbuf;
|
||
|
|
||
|
/* Returns a pointer to nconf corresponding to NETCONF */
|
||
|
if ((nconf = getnetconfigent("UDP")) ==
|
||
|
(struct netconfig *)NULL) {
|
||
|
fprintf(stderr, "Cannot get netconfig entry for UDP\n");
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
...
|
||
|
|
||
|
if (!<strong>rpcb_getaddr</strong>(RMTPROGNUM, RMTPROGVER, nconf,
|
||
|
svcaddr, "as400.somewhere.ibm.com")){
|
||
|
fprintf(stderr, "<strong>rpcb_getaddr</strong> failed!!\n");
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
...
|
||
|
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
<hr>
|
||
|
API introduced: V4R2
|
||
|
|
||
|
<hr>
|
||
|
<table cellpadding="2" cellspacing="2" align="center">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
||
|
"rpc1.htm">Remote Procedure Call (RPC) APIs</a> | <a href="aplist.htm">APIs by
|
||
|
category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</body>
|
||
|
</html>
|
||
|
|