389 lines
10 KiB
HTML
389 lines
10 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>res_nsendsigned()--Send Authenticated Domain Query</title>
|
|
<!-- 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. -->
|
|
<!-- Begin Header Records ========================================== -->
|
|
<!-- Unix8 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- Edited by Kersten Feb 02 -->
|
|
<!--End Header Records -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<a name="Top_Of_Page"></a>
|
|
<!-- Java sync-link -->
|
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
|
</script>
|
|
|
|
<h2>res_nsendsigned()--Send Authenticated Domain Query or Update</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/nameser.h>
|
|
#include <resolv.h>
|
|
|
|
int res_nsendsigned(state* <em>res</em>,
|
|
const unsigned char *<em>query_buffer</em>,
|
|
int <em>query_buffer_length</em>,
|
|
ns_tsig_key * <em>key</em>,
|
|
unsigned char *<em>answer_buffer</em>,
|
|
int <em>answer_buffer_length</em>)
|
|
|
|
</pre>
|
|
|
|
<br>
|
|
Service Program Name: QSOSRV2<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <em>res_nsendsigned()</em> function is similar to <em>res_nsend()</em>
|
|
but it uses the specified key to create a transaction signature (TSIG) to sign
|
|
the query or update packet and to authenticate the response.</p>
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong>res</strong></dt>
|
|
|
|
<dd>(Input) The pointer to the <strong>state</strong> structure.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>query_buffer</strong></dt>
|
|
|
|
<dd>(Input) The pointer to the query or update message.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>query_buffer_length</strong></dt>
|
|
|
|
<dd>(Input) The length of <em>query_buffer</em>.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>key</strong></dt>
|
|
|
|
<dd>(Input) The pointer to the key to use for authentication. This key must
|
|
exist on the name server.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>answer_buffer</strong></dt>
|
|
|
|
<dd>(Output) The pointer to where the response is stored.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong>answer_buffer_length</strong></dt>
|
|
|
|
<dd>(Input) The size of the answer_buffer.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Authorities</h3>
|
|
|
|
<p>No authorization is required.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<p><em>res_nsendsigned()</em> returns an integer. Possible values are:</p>
|
|
|
|
<ul>
|
|
<li>n (successful), where n is the actual size of the answer returned.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>-1 (unsuccessful)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>-ns_r_badkey (unsuccessful) The key was invalid or the signing failed.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>NS_TSIG_ERROR_NO_SPACE (unsuccessful) The message buffer was too small to
|
|
add the TSIG.</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
<p>When the <em>res_nsendsigned()</em> function fails,
|
|
<em>res_nsendsigned()</em> can set <em>errno</em> to one of the following:</p>
|
|
<dl>
|
|
|
|
<dt><em>[ECONNREFUSED]</em></dt>
|
|
<dd><p>Not able to connect to a server.</p></dd>
|
|
|
|
|
|
<dt><em>[ECONVERT]</em></dt>
|
|
<dd><p>Either the input packet could not be translated
|
|
to ASCII or the answer received could not be translated to the coded character
|
|
set identifier (CCSID) currently in effect for the job.</p></dd>
|
|
|
|
<dt><em>[EFAULT]</em></dt>
|
|
<dd><p>The system detected a pointer that was invalid
|
|
while attempting to access an input pointer.</p></dd>
|
|
|
|
|
|
<dt><em>[EINVAL]</em></dt>
|
|
<dd><p>One of the following reasons:</p>
|
|
<ul>
|
|
<li><p>An invalid length or NULL pointer was passed to <em>res_nsendsigned()</em></p></li>
|
|
<li><p>The <strong>res</strong> appears to be initialized but the reserved field
|
|
is not set to zeros.</p></li>
|
|
</ul>
|
|
|
|
<p><strong>Note</strong>: No attempt is made to initialize the
|
|
<strong>res</strong> structure if it was initialized previous to the
|
|
<em>res_nsendsigned()</em> being issued.</p></dd>
|
|
|
|
|
|
<dt><em>[EMSGSIZE]</em></dt>
|
|
<dd><p>The message buffer was too small to add the TSIG.
|
|
The return value was NS_TSIG_ERROR_NO_SPACE.</p></dd>
|
|
|
|
|
|
<dt><em>[ENOTTY]</em></dt>
|
|
<dd><p>The message or reply couldn't be verified. See
|
|
<em>extended_error</em> in the <strong>res</strong> structure:</p>
|
|
<dl>
|
|
<dt><em>NS_TSIG_ERROR_FORMERR</em></dt>
|
|
<dd><p>The message is malformed.</p></dd>
|
|
|
|
|
|
<dt><em>NS_TSIG_ERROR_NO_TSIG</em></dt>
|
|
<dd><p>The message does not contain a TSIG record.</p></dd>
|
|
|
|
|
|
<dt><em>NS_TSIG_ERROR_ID_MISMATCH</em></dt>
|
|
<dd><p>The TSIG original ID field does not match the
|
|
message ID.</p></dd>
|
|
|
|
<dt><em>(-ns_r_badkey)</em></dt>
|
|
<dd><p>Verification failed due to an invalid key.</p></dd>
|
|
|
|
|
|
<dt><em>(-ns_r_badsig)</em></dt>
|
|
<dd><p>Verification failed due to an invalid
|
|
signature.</p></dd>
|
|
|
|
|
|
<dt><em>(-ns_r_badtime)</em></dt>
|
|
<dd><p>Verification failed due to an invalid
|
|
timestamp.</p></dd>
|
|
|
|
|
|
<dt><em>ns_r_badkey</em></dt>
|
|
<dd><p>Verification succeeded but the message had an
|
|
error (rcode) of <em>ns_r_badkey</em>.</p></dd>
|
|
|
|
|
|
<dt><em>ns_r_badsig</em></dt>
|
|
<dd><p>Verification succeeded but the message had an
|
|
error (rcode) of <em>ns_r_badsig</em>.</p></dd>
|
|
|
|
|
|
<dt><em>ns_r_badtime</em></dt>
|
|
<dd><p>Verification succeeded but the message had an
|
|
error (rcode) of <em>ns_r_badtime</em>.</p></dd>
|
|
</dl>
|
|
|
|
<br>
|
|
|
|
<dt><em>[ETIMEDOUT]</em></dt>
|
|
<dd><p>A timeout received from a connected server.</p></dd>
|
|
|
|
|
|
<dd>When the <em>res_nsearch()</em> function fails, <em>h_errno</em> (defined in
|
|
<strong><netdb.h></strong>) can also be set to one of the following:</p>
|
|
<dl>
|
|
<dt><em>HOST_NOT_FOUND</em></dt>
|
|
<dd><p>Either the input packet could not be translated
|
|
to ASCII or the answer received could not be translated to the coded character
|
|
set identifier (CCSID) currently in effect for the job.</p></dd>
|
|
|
|
|
|
<dt><em>NO_RECOVERY</em></dt>
|
|
<dd><p>An invalid length or NULL pointer was passed to
|
|
<em>res_nsendsigned()</em> or the <strong>res</strong> could not be initialized
|
|
properly.</p></dd>
|
|
</dl></dd></dl>
|
|
<p><strong>Notes</strong>:</p>
|
|
|
|
<ul>
|
|
<li>No attempt is made to initialize the
|
|
<strong>res</strong> structure if it was initialized previous to the
|
|
<em>res_nsendsigned()</em> being issued.<br><br></li>
|
|
<li>There are numerous other values that <em>errno</em>
|
|
can be set to by the sockets functions that <em>res_nsendsigned()</em> calls.
|
|
The above values are the only values that <em>res_nsendsigned()</em> can
|
|
specifically set. Refer to other sockets functions for the other values.
|
|
<em>errno</em> is always set in an error condition, but <em>h_errno</em> is not
|
|
necessarily set.
|
|
|
|
<p>After receiving an error reply packet, <em>res_nsendsigned()</em> will set
|
|
the <em>extended_error</em> field in the <em>state</em> structure to the last
|
|
reply return code from the DNS server. See <arpa/nameser.h> for all
|
|
possible values of <em>ns_rcode</em>.</p></li>
|
|
</ul>
|
|
|
|
|
|
|
|
<br>
|
|
<h3>Usage Notes</h3>
|
|
|
|
<ol>
|
|
<li><em>res_nsendsigned()</em> sends the query or update to the local name
|
|
server and handles all timeouts and retries. The response packet is stored in
|
|
<em>answer_buffer</em>.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><em>res_nsendsigned()</em> calls <em>res_ninit()</em> if the
|
|
<strong>res</strong> structure has not been initialized.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><em>res_nsendsigned()</em> uses the UDP protocol, except for the following
|
|
cases in which it uses TCP to send the packet.<br>
|
|
|
|
|
|
<ul>
|
|
<li>If the RES_USEVC or RES_STAYOPEN bits are set in the options field of the
|
|
<strong>res</strong> structure.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>If the configuration from Change TCP/IP Domain (CHGTCPDMN) specifies that
|
|
the server protocol is TCP.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>If the truncation bit is set in the packet header on the response from a
|
|
UDP packet, and RES_IGNTC is not set in the <strong>res</strong>
|
|
structure.</li>
|
|
</ul>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li><em>res_nsendsigned()</em> does not perform iterative queries and expects
|
|
the name server to handle recursion.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><em>res_nsendsigned()</em> assumes that the data passed to it is EBCDIC and
|
|
is in the default coded character set identifier (CCSID) currently in effect
|
|
for the job. It translates the data from the default CCSID currently in effect
|
|
for the job to ASCII (CCSID 819) before the data is sent out to a name server.
|
|
The response that it receives from the name server is returned in the default
|
|
CCSID currently in effect for the job.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><em>res_nsendsigned()</em> will not use the local cache. It will always
|
|
send the packet to the server.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>When using TSIG, it is important that the QUTCOFFSET system value is set
|
|
correctly for the local time zone. The resolver system and name server
|
|
timestamps must be within 5 minutes of each other (adjusted by the UTC offset)
|
|
or the authentication will fail with <em>ns_r_badtime</em>.</li>
|
|
</ol>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li><a href="hstrerror.htm">hstrerror()</a>--Retrieve Resolver Error
|
|
Message<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resnclose.htm">res_nclose()</a>--Close Socket and Reset res
|
|
Structure<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resfindzonecut.htm">res_findzonecut()</a>--Find the Enclosing Zone and
|
|
Servers<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="reshostalias.htm">res_hostalias()</a>--Retrieve the host alias<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resninit.htm">res_ninit()</a>--Initialize res Structure<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resnmkquery.htm">res_nmkquery()</a>--Place Domain Query in
|
|
Buffer<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resnmkupdate.htm">res_nmkupdate()</a>--Construct an Update
|
|
Packet<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resnquery.htm">res_nquery()</a>--Send Domain Query<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resnsearch.htm">res_nsearch()</a>--Search for Domain Name<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resnsend.htm">res_nsend()</a>--Send Buffered Domain Query<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resnupdate.htm">res_nupdate()</a>--Build and Send Dynamic
|
|
Updates<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="resxlt.htm">res_xlate()</a>--Translate DNS Packets</li>
|
|
</ul>
|
|
|
|
<br>
|
|
|
|
|
|
<hr>
|
|
API introduced: V5R1
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a> </td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|