/*
* Copyright (c) 1996 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/*
* Portions copyright (c) 1999, 2000
* Intel Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
*
* This product includes software developed by Intel Corporation and
* its contributors.
*
* 4. Neither the name of Intel Corporation or its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* Based on the Dynamic DNS reference implementation by Viraj Bais
* <viraj_bais@ccm.fm.intel.com>
*/
#endif /* not lint */
#include <errno.h>
#include <limits.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include "res_config.h"
/*
* Form update packets.
* Returns the size of the resulting packet if no error
* On error,
* portion for update packets
* -2 if length of buffer passed is insufficient
* -3 if zone section is not the first section in
* the linked list, or section order has a problem
* -4 on a number overflow
* -5 unknown operation or no records
*/
int
return (-1);
}
/*
* Initialize header fields.
*/
return (-1);
if (rrecp_start == NULL)
return (-5);
return (-3);
numrrs++;
return (-1);
if (counts[i])
return (-3);
/* overload class and type */
rttl = 0;
case YXDOMAIN:
break;
case NXDOMAIN:
break;
case NXRRSET:
break;
case YXRRSET:
break;
default:
"res_mkupdate: incorrect opcode: %d\n",
return (-1);
}
case DELETE:
break;
case ADD:
break;
default:
"res_mkupdate: incorrect opcode: %d\n",
return (-1);
}
}
/*
* XXX appending default domain to owner name is omitted,
* fqdn must be provided
*/
lastdnptr)) < 0)
return (-1);
cp += n;
return (-3);
continue;
}
return (-1);
else {
continue;
}
}
/* XXX this should be done centrally. */
case T_A:
return (-1);
return (-1);
break;
case T_CNAME:
case T_MB:
case T_MG:
case T_MR:
case T_NS:
case T_PTR:
return (-1);
if (n < 0)
return (-1);
cp += n;
ShrinkBuffer(n);
break;
case T_MINFO:
case T_SOA:
case T_RP:
for (i = 0; i < 2; i++) {
endp))
return (-1);
if (n < 0)
return (-1);
cp += n;
ShrinkBuffer(n);
}
startp++;
if (*startp == '(') {
multiline = 1;
startp++;
} else
multiline = 0;
/* serial, refresh, retry, expire, minimum */
for (i = 0; i < 5; i++) {
if (soanum < 0)
return (-1);
}
if (multiline) {
startp++;
if (*startp != ')')
return (-1);
}
}
break;
case T_MX:
case T_AFSDB:
case T_RT:
if (n < 0)
return (-1);
return (-1);
if (n < 0)
return (-1);
cp += n;
ShrinkBuffer(n);
break;
case T_PX:
if (n < 0)
return (-1);
for (i = 0; i < 2; i++) {
endp))
return (-1);
if (n < 0)
return (-1);
cp += n;
ShrinkBuffer(n);
}
break;
case T_WKS:
case T_HINFO:
case T_TXT:
case T_X25:
case T_ISDN:
case T_NSAP:
case T_LOC:
/* XXX - more fine tuning needed here */
break;
default:
return (-1);
} /*switch*/
} /*for*/
}
/*
* Get a whitespace delimited word from a string (not file)
* into buf. modify the start pointer to point after the
* word in the string.
*/
static int
char *cp;
int c;
c = **startpp;
if (isspace(c) || c == '\0') {
break;
else { /* leading whitespace */
(*startpp)++;
continue;
}
}
(*startpp)++;
break;
}
*cp = '\0';
}
/*
* Get a whitespace delimited number from a string (not file) into buf
* update the start pointer to point after the number in the string.
*/
static int
int c;
int n;
int seendigit = 0;
int m = 0;
c = **startpp;
if (isspace(c) || c == '\0') {
if (seendigit) /* trailing whitespace */
break;
else { /* leading whitespace */
(*startpp)++;
continue;
}
}
if (c == ';') {
((c = **startpp) != '\n'))
(*startpp)++;
if (seendigit)
break;
continue;
}
if (!isdigit(c)) {
if (c == ')' && seendigit) {
(*startpp)--;
break;
}
return (-1);
}
(*startpp)++;
n = n * 10 + (c - '0');
seendigit = 1;
}
return (n + m);
}
/*
* Allocate a resource record buffer & save rr info.
*/
return (NULL);
return (rrecp);
}
/*
* Free a resource record buffer created by res_mkupdrec.
*/
void
/* Note: freeing r_dp is the caller's responsibility. */
}