nres_rcv.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1993,1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* Taken from 4.1.3 ypserv resolver code. */
/*
* Send query to name server and wait for reply.
*/
#include <syslog.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <resolv.h>
#include "nres.h"
#include "prnt.h"
int
{
register int n;
int resplen;
char *cp;
int s;
int truncated = 0;
char junk[512];
s = tnr->udp_socket;
return (-1);
}
/*
* response from old query, ignore it
*/
if (verbose && verbose_out)
return (0); /* wait again */
}
/*
* get rest of answer
*/
return (-1);
}
return (1);
} else {
/* tcp case */
s = tnr->tcp_socket;
/*
* Receive length & response
*/
len = sizeof (short);
cp += n;
len -= n;
}
if (n <= 0) {
(void) close(s);
return (-1);
}
truncated = 1;
} else
cp += n;
len -= n;
}
if (n <= 0) {
(void) close(s);
return (-1);
}
if (truncated) {
/*
* Flush rest of answer so connection stays in synch.
*/
while (len != 0) {
len -= n;
else
break;
}
}
/*
* response from old query, ignore it
*/
if (verbose && verbose_out)
return (0); /* wait again */
}
return (1);
}
}