res_nupdate()--Build and Send Dynamic Updates


  Syntax
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/nameser.h>
 #include <resolv.h>

 int res_nupdate(state* res,
              ns_updrec *update_record  
              ns_tsig_key *key)


  Service Program Name: QSOSRV2

  Default Public Authority: *USE

  Threadsafe: Yes

The res_nupdate() function separates the linked list of update records into groups so that all records in a group will belong to a single zone on the nameserver. It creates a dynamic update packet for each zone and sends it to the nameservers for that zone.

Parameters

res
(Input) The pointer to the state structure.

update_record
(Input) The pointer to the linked list of update records.

key
(Input) The pointer to the key to use for authentication. If it is NULL, no authentication will be done.

The ns_updrec structure is defined in <arpa/nameser.h>.

struct ns_updrec {
   struct {
      struct ns_updrec *prev, *next;
   } r_link, r_glink;
   ns_sect                r_section;
   char *                 r_dname;
   ns_class               r_class;
   ns_type                r_type;
   uint32                 r_ttl;
   unsigned char *        r_data;
   uint32                 r_size;
   int32                  r_opcode;
/* The following fields are ignored by the resolver routines  */
   struct databuf *       r_dp;
   struct databuf *       r_deldp;
   uint32                 r_zone;
};

typedef struct ns_updrec ns_updrec;
r_link and r_glink
Doubly linked lists of ns_updrec records. res_nupdate() uses r_link as its list of records to process and ignores r_glink. res_nmkupdate() uses r_glink as its list of records to process and ignores r_link.

r_section
See the ns_sect enums in <arpa/nameser.h> for allowed values.

r_dname,r_class,r_type, r_ttl,r_data, and r_size
Identify the resource record to the DNS

r_opcode
Type of update operation. Valid operations are ns_uop_delete or ns_uop_add

These fields are ignored by the resolver: r_dp, r_deldp, r_zone.

Authorities

No authorization is required.


Return Value

res_nupdate() returns an integer. Possible values are:


Error Conditions

When the res_nupdate() function fails, res_nupdate() can set errno to one of the following:

[ECONVERT]

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.

[EFAULT]

The system detected a pointer that was invalid while attempting to access an input pointer.

[EINVAL]

One of the following reasons:

Notes:

  1. No attempt is made to initialize the res structure if it was initialized previous to the res_nupdate() being issued.

  2. res_nupdate() calls res_findzonecut(), res_nmkupdate() and res_nsend() or res_nsendsigned() so errnos from those routines may also be set.


Usage Notes

  1. res_nupdate() calls res_ninit() if the res structure has not been initialized.

  2. res_nupdate() calls res_findzonecut() to find the zone and name server to be updated for each input record and sorts the records by zone. Then it makes a zone record for each zone and prepends it to the update records. It calls res_nmkupdate() to make the update packet and then calls either res_nsend() or res_nsendsigned() to send the packet. Note that since res_nupdate() prepends a new zone record, the input records must only contain pre-requisite and update records, not zone records.

  3. res_nupdate() 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.

  4. res_nupdate() will not use the local cache. It will always send the packet to the server.

  5. 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 ns_r_badtime.

Related Information



API introduced: V5R1

[ Back to top | UNIX-Type APIs | APIs by category ]