* 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.4 (Berkeley) 6/18/88";
#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
));
register struct namebuf
*np
;
register struct databuf
*dp
;
extern char *inet_ntoa(), *p_protocal(), *p_service();
if ((fp
= fopen("/usr/tmp/namebuf", "a")) == NULL
)
for (dp
= np
->n_data
; dp
!= NULL
; dp
= dp
->d_next
) {
if (dp
->d_ttl
<= tt
.tv_sec
)
fprintf(fp
, "%s\t", np
->n_dname
);
if (strlen(np
->n_dname
) < 8)
fprintf(fp
, "%d\t", dp
->d_ttl
- tt
.tv_sec
);
else if (dp
->d_ttl
> zones
[dp
->d_zone
].z_minimum
)
fprintf(fp
, "%d\t", dp
->d_ttl
);
fprintf(fp
, "%s\t%s\t", p_class(dp
->d_class
),
* Print type specific data
inet_ntoa(*(struct in_addr
*)&n
));
fprintf(fp
, "%s.\n", cp
);
fprintf(fp
, "\t; %d", dp
->d_nstime
);
fprintf(fp
, "\"%.*s\"", n
, cp
);
fprintf(fp
, " \"%.*s\"", n
, cp
);
fprintf(fp
, " %s. (\n", cp
);
fprintf(fp
, "\t\t%d", _getlong(cp
));
fprintf(fp
, " %d", _getlong(cp
));
fprintf(fp
, " %d", _getlong(cp
));
fprintf(fp
, " %d", _getlong(cp
));
fprintf(fp
, " %d )\n", _getlong(cp
));
fprintf(fp
,"%d", _getshort(cp
));
fprintf(fp
," %s.\n", cp
);
fprintf(fp
, "\"%s\"\n", cp
);
if (dp
->d_size
== sizeof(u_long
)) {
fprintf(fp
, "%d\n", _getlong(cp
));
addr
= htonl(_getlong(cp
));
inet_ntoa(*(struct in_addr
*)&addr
));
proto
= p_protocal(*cp
); /* protocal */
fprintf(fp
, "%s ", proto
);
while(cp
< dp
->d_data
+ dp
->d_size
) {