* Copyright (c) 1986 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)ns_sort.c 4.5 (Berkeley) 1/14/89";
#include <arpa/nameser.h>
extern char *p_type(), *p_class();
struct sockaddr_in
*from
;
extern struct netinfo
*nettab
, netloop
;
if (from
->sin_addr
.s_addr
== netloop
.my_addr
.s_addr
)
for (ntp
= nettab
; ntp
!= NULL
; ntp
= ntp
->next
) {
if (ntp
->net
== (from
->sin_addr
.s_addr
& ntp
->mask
))
sort_response(cp
, ancount
, lp
, eom
)
register struct netinfo
*ntp
;
extern struct netinfo
*nettab
;
fprintf(ddt
,"sort_response(%d)\n", ancount
);
if (sort_rr(cp
, ancount
, lp
, eom
))
for (ntp
= nettab
; ntp
!= NULL
; ntp
= ntp
->next
) {
if ((ntp
->net
== lp
->net
) && (ntp
->mask
== lp
->mask
))
if (sort_rr(cp
, ancount
, ntp
, eom
))
sort_rr(cp
, count
, ntp
, eom
)
register struct netinfo
*ntp
;
int type
, class, dlen
, n
, c
;
inaddr
.s_addr
= ntp
->net
;
fprintf(ddt
,"sort_rr( x%x, %d, %s)\n",cp
, count
,
for (c
= count
; c
> 0; --c
) {
n
= dn_skipname(cp
, eom
);
return (1); /* bogus, stop processing */
return (1); /* bogus, stop processing */
bcopy(cp
, (char *)&inaddr
, sizeof(inaddr
));
if ((ntp
->mask
& inaddr
.s_addr
) == ntp
->net
) {
fprintf(ddt
,"net %s best choice\n",
bcopy(rr1
, cp
, sizeof(inaddr
));
bcopy((char *)&inaddr
, rr1
, sizeof(inaddr
));