merge
This commit is contained in:
commit
1984f6813c
5 changed files with 90 additions and 99 deletions
|
@ -49,7 +49,7 @@ query, ipquery, mkhash, mkdb, mkhosts, cs, csquery, dns, dnstcp, dnsquery, dnsde
|
||||||
.B -s
|
.B -s
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
.I server
|
.I /net/cs
|
||||||
[
|
[
|
||||||
.I addr...
|
.I addr...
|
||||||
]
|
]
|
||||||
|
@ -91,6 +91,8 @@ query, ipquery, mkhash, mkdb, mkhosts, cs, csquery, dns, dnstcp, dnsquery, dnsde
|
||||||
.B ndb/dnsquery
|
.B ndb/dnsquery
|
||||||
[
|
[
|
||||||
.B -x
|
.B -x
|
||||||
|
] [
|
||||||
|
.I /net/dns
|
||||||
]
|
]
|
||||||
.br
|
.br
|
||||||
.B ndb/dnsdebug
|
.B ndb/dnsdebug
|
||||||
|
|
|
@ -535,7 +535,7 @@ mathemu(Ureg *ureg, void*)
|
||||||
case FPinit:
|
case FPinit:
|
||||||
fpinit();
|
fpinit();
|
||||||
index = up->fpstate >> FPindexs;
|
index = up->fpstate >> FPindexs;
|
||||||
if(index < 0 || index > FPindexm)
|
if(index < 0 || index > (FPindexm>>FPindexs))
|
||||||
panic("fpslot index overflow: %d", index);
|
panic("fpslot index overflow: %d", index);
|
||||||
if(userureg(ureg)){
|
if(userureg(ureg)){
|
||||||
if(index != 0)
|
if(index != 0)
|
||||||
|
@ -684,7 +684,7 @@ procsave(Proc *p)
|
||||||
* emulation fault to activate the FPU.
|
* emulation fault to activate the FPU.
|
||||||
*/
|
*/
|
||||||
fpsave(p->fpsave);
|
fpsave(p->fpsave);
|
||||||
p->fpstate = FPinactive | (p->fpstate & (FPpush|FPnouser|FPkernel|FPindexm));
|
p->fpstate = FPinactive | (p->fpstate & ~FPactive);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,7 +729,8 @@ fpurestore(int ostate)
|
||||||
if((astate & ~(FPnouser|FPkernel|FPindexm)) == FPactive)
|
if((astate & ~(FPnouser|FPkernel|FPindexm)) == FPactive)
|
||||||
_stts();
|
_stts();
|
||||||
up->fpsave = up->fpslot[ostate>>FPindexs];
|
up->fpsave = up->fpslot[ostate>>FPindexs];
|
||||||
ostate = FPinactive | (ostate & (FPillegal|FPpush|FPnouser|FPkernel|FPindexm));
|
if(ostate & FPactive)
|
||||||
|
ostate = FPinactive | (ostate & ~FPactive);
|
||||||
}
|
}
|
||||||
up->fpstate = ostate;
|
up->fpstate = ostate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,9 +542,9 @@ awaitack(int fd, int block)
|
||||||
if (Debug)
|
if (Debug)
|
||||||
syslog(dbg, flog, "tftpd %d read ack of %d bytes "
|
syslog(dbg, flog, "tftpd %d read ack of %d bytes "
|
||||||
"for block %d", pid, al, ackblock);
|
"for block %d", pid, al, ackblock);
|
||||||
if(ackblock == block)
|
if(ackblock == (block & 0xffff))
|
||||||
return Ackok; /* for block just sent */
|
return Ackok; /* for block just sent */
|
||||||
else if(ackblock == block + 1) /* intel pxe eof bug */
|
else if(ackblock == (block + 1 & 0xffff)) /* intel pxe eof bug */
|
||||||
return Ackok;
|
return Ackok;
|
||||||
else if(ackblock == 0xffff)
|
else if(ackblock == 0xffff)
|
||||||
return Ackrexmit;
|
return Ackrexmit;
|
||||||
|
|
|
@ -121,6 +121,32 @@ longtime(long t)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* convert address into a reverse lookup address
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
mkptrname(char *ip, char *rip, int rlen)
|
||||||
|
{
|
||||||
|
uchar a[IPaddrlen];
|
||||||
|
char *p, *e;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if(cistrstr(ip, "in-addr.arpa") || cistrstr(ip, "ip6.arpa") || parseip(a, ip) == -1)
|
||||||
|
snprint(rip, rlen, "%s", ip);
|
||||||
|
else if(isv4(a))
|
||||||
|
snprint(rip, rlen, "%ud.%ud.%ud.%ud.in-addr.arpa",
|
||||||
|
a[15], a[14], a[13], a[12]);
|
||||||
|
else{
|
||||||
|
p = rip;
|
||||||
|
e = rip + rlen;
|
||||||
|
for(i = 15; i >= 0; i--){
|
||||||
|
p = seprint(p, e, "%ux.", a[i]&0xf);
|
||||||
|
p = seprint(p, e, "%ux.", a[i]>>4);
|
||||||
|
}
|
||||||
|
seprint(p, e, "ip6.arpa");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
prettyrrfmt(Fmt *f)
|
prettyrrfmt(Fmt *f)
|
||||||
{
|
{
|
||||||
|
@ -372,7 +398,6 @@ void
|
||||||
doquery(char *name, char *tstr)
|
doquery(char *name, char *tstr)
|
||||||
{
|
{
|
||||||
int len, type, rooted;
|
int len, type, rooted;
|
||||||
char *p, *np;
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
RR *rr, *rp;
|
RR *rr, *rp;
|
||||||
Request req;
|
Request req;
|
||||||
|
@ -387,6 +412,13 @@ doquery(char *name, char *tstr)
|
||||||
else
|
else
|
||||||
tstr = "ip";
|
tstr = "ip";
|
||||||
|
|
||||||
|
/* look it up */
|
||||||
|
type = rrtype(tstr);
|
||||||
|
if(type < 0){
|
||||||
|
print("!unknown type %s\n", tstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* if name end in '.', remove it */
|
/* if name end in '.', remove it */
|
||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
if(len > 0 && name[len-1] == '.'){
|
if(len > 0 && name[len-1] == '.'){
|
||||||
|
@ -396,34 +428,10 @@ doquery(char *name, char *tstr)
|
||||||
rooted = 0;
|
rooted = 0;
|
||||||
|
|
||||||
/* inverse queries may need to be permuted */
|
/* inverse queries may need to be permuted */
|
||||||
|
if(type == Tptr)
|
||||||
|
mkptrname(name, buf, sizeof buf);
|
||||||
|
else
|
||||||
strncpy(buf, name, sizeof buf);
|
strncpy(buf, name, sizeof buf);
|
||||||
if(strcmp("ptr", tstr) == 0 && cistrstr(name, ".arpa") == nil){
|
|
||||||
/* TODO: reversing v6 addrs is harder */
|
|
||||||
for(p = name; *p; p++)
|
|
||||||
;
|
|
||||||
*p = '.';
|
|
||||||
np = buf;
|
|
||||||
len = 0;
|
|
||||||
while(p >= name){
|
|
||||||
len++;
|
|
||||||
p--;
|
|
||||||
if(*p == '.'){
|
|
||||||
memmove(np, p+1, len);
|
|
||||||
np += len;
|
|
||||||
len = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memmove(np, p+1, len);
|
|
||||||
np += len;
|
|
||||||
strcpy(np, "in-addr.arpa"); /* TODO: ip6.arpa for v6 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* look it up */
|
|
||||||
type = rrtype(tstr);
|
|
||||||
if(type < 0){
|
|
||||||
print("!unknown type %s\n", tstr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&req, 0, sizeof req);
|
memset(&req, 0, sizeof req);
|
||||||
getactivity(&req, 0);
|
getactivity(&req, 0);
|
||||||
|
|
|
@ -6,35 +6,6 @@
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "ip.h"
|
#include "ip.h"
|
||||||
|
|
||||||
static int domount;
|
|
||||||
static char *mtpt, *dns, *srv;
|
|
||||||
|
|
||||||
static int
|
|
||||||
setup(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
if(argc == 1){
|
|
||||||
domount = 0;
|
|
||||||
mtpt = argv[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = open(dns, ORDWR);
|
|
||||||
if(fd < 0){
|
|
||||||
if(domount == 0)
|
|
||||||
sysfatal("can't open %s: %r", dns);
|
|
||||||
fd = open(srv, ORDWR);
|
|
||||||
if(fd < 0)
|
|
||||||
sysfatal("can't open %s: %r", srv);
|
|
||||||
if(mount(fd, -1, mtpt, MBEFORE, "") < 0)
|
|
||||||
sysfatal("can't mount(%s, %s): %r", srv, mtpt);
|
|
||||||
fd = open(dns, ORDWR);
|
|
||||||
if(fd < 0)
|
|
||||||
sysfatal("can't open %s: %r", dns);
|
|
||||||
}
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
querydns(int fd, char *line, int n)
|
querydns(int fd, char *line, int n)
|
||||||
{
|
{
|
||||||
|
@ -52,11 +23,37 @@ querydns(int fd, char *line, int n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* convert address into a reverse lookup address
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
mkptrname(char *ip, char *rip, int rlen)
|
||||||
|
{
|
||||||
|
uchar a[IPaddrlen];
|
||||||
|
char *p, *e;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if(cistrstr(ip, "in-addr.arpa") || cistrstr(ip, "ip6.arpa") || parseip(a, ip) == -1)
|
||||||
|
snprint(rip, rlen, "%s", ip);
|
||||||
|
else if(isv4(a))
|
||||||
|
snprint(rip, rlen, "%ud.%ud.%ud.%ud.in-addr.arpa",
|
||||||
|
a[15], a[14], a[13], a[12]);
|
||||||
|
else{
|
||||||
|
p = rip;
|
||||||
|
e = rip + rlen;
|
||||||
|
for(i = 15; i >= 0; i--){
|
||||||
|
p = seprint(p, e, "%ux.", a[i]&0xf);
|
||||||
|
p = seprint(p, e, "%ux.", a[i]>>4);
|
||||||
|
}
|
||||||
|
seprint(p, e, "ip6.arpa");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
query(int fd)
|
query(int fd)
|
||||||
{
|
{
|
||||||
int n, len;
|
int n;
|
||||||
char *lp, *p, *np;
|
char *lp;
|
||||||
char buf[1024], line[1024];
|
char buf[1024], line[1024];
|
||||||
Biobuf in;
|
Biobuf in;
|
||||||
|
|
||||||
|
@ -84,31 +81,10 @@ query(int fd)
|
||||||
n += 3;
|
n += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* inverse queries may need to be permuted */
|
if(n > 4 && strcmp(" ptr", &line[n-4]) == 0){
|
||||||
if(n > 4 && strcmp(" ptr", &line[n-4]) == 0 &&
|
line[n-4] = 0;
|
||||||
cistrstr(line, ".arpa") == nil){
|
mkptrname(line, buf, sizeof buf);
|
||||||
/* TODO: reversing v6 addrs is harder */
|
n = snprint(line, sizeof line, "%s ptr", buf);
|
||||||
for(p = line; *p; p++)
|
|
||||||
if(*p == ' '){
|
|
||||||
*p = '.';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
np = buf;
|
|
||||||
len = 0;
|
|
||||||
while(p >= line){
|
|
||||||
len++;
|
|
||||||
p--;
|
|
||||||
if(*p == '.'){
|
|
||||||
memmove(np, p+1, len);
|
|
||||||
np += len;
|
|
||||||
len = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memmove(np, p+1, len);
|
|
||||||
np += len;
|
|
||||||
strcpy(np, "in-addr.arpa ptr"); /* TODO: ip6.arpa for v6 */
|
|
||||||
strcpy(line, buf);
|
|
||||||
n = strlen(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
querydns(fd, line, n);
|
querydns(fd, line, n);
|
||||||
|
@ -119,21 +95,25 @@ query(int fd)
|
||||||
void
|
void
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
mtpt = "/net";
|
char *dns = "/net/dns";
|
||||||
dns = "/net/dns";
|
int fd;
|
||||||
srv = "/srv/dns";
|
|
||||||
domount = 1;
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'x':
|
case 'x':
|
||||||
mtpt = "/net.alt";
|
|
||||||
dns = "/net.alt/dns";
|
dns = "/net.alt/dns";
|
||||||
srv = "/srv/dns_net.alt";
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprint(2, "usage: %s [-x] [dns-mount-point]\n", argv0);
|
fprint(2, "usage: %s [-x] [/net/dns]\n", argv0);
|
||||||
exits("usage");
|
exits("usage");
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
query(setup(argc, argv));
|
if(argc > 0)
|
||||||
|
dns = argv[0];
|
||||||
|
|
||||||
|
fd = open(dns, ORDWR);
|
||||||
|
if(fd < 0)
|
||||||
|
sysfatal("can't open %s: %r", dns);
|
||||||
|
|
||||||
|
query(fd);
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue