[packages] gpsd: update to v2.90
[openwrt/svn-archive/archive.git] / net / djbdns / patches / 030-srv-records-and-axfrget.patch
1 From: Michael Handler <handler@sub-rosa.com>
2 To: dns@list.cr.yp.to
3 Subject: tinydns-data SRV & axfr-get SRV/PTR patches
4 Date: Thu, 14 Sep 2000 20:37:50 -0400
5
6 Here's a combined patch that:
7
8 a) adds a native SRV type to tinydns-data
9
10 Sfqdn:ip:x:port:weight:priority:ttl:timestamp
11
12 Standard rules for ip, x, ttl, and timestamp apply. Port, weight, and
13 priority all range from 0-65535. Weight and priority are optional; they
14 default to zero if not provided.
15
16 Sconsole.zoinks.example.com:1.2.3.4:rack102-con1:2001:69:7:300:
17
18 b) makes axfr-get decompose SRV and PTR records and write them out in
19 native format, rather than opaque. Again, this is necessary because if the
20 DNAME fields in the records reference the same zone as fqdn, they can have
21 compression pointers that are bogus outside the context of that specific
22 packet, and which can't be correctly loaded into data.cdb by tinydns-data.
23
24 --michael
25
26 Laurent G. Bercot <ska-djbdns@skarnet.org> updated it for djbdns-1.05:
27
28 --- a/axfr-get.c
29 +++ b/axfr-get.c
30 @@ -209,6 +209,26 @@ unsigned int doit(char *buf,unsigned int
31 if (!stralloc_cats(&line,".:")) return 0;
32 if (!stralloc_catulong0(&line,dist,0)) return 0;
33 }
34 + else if (byte_equal(data,2,DNS_T_SRV)) {
35 + uint16 dist, weight, port;
36 + if (!stralloc_copys(&line,"S")) return 0;
37 + if (!dns_domain_todot_cat(&line,d1)) return 0;
38 + if (!stralloc_cats(&line,"::")) return 0;
39 + pos = x_copy(buf,len,pos,data,2);
40 + uint16_unpack_big(data,&dist);
41 + pos = x_copy(buf,len,pos,data,2);
42 + uint16_unpack_big(data,&weight);
43 + pos = x_copy(buf,len,pos,data,2);
44 + uint16_unpack_big(data,&port);
45 + x_getname(buf,len,pos,&d1);
46 + if (!dns_domain_todot_cat(&line,d1)) return 0;
47 + if (!stralloc_cats(&line,".:")) return 0;
48 + if (!stralloc_catulong0(&line,dist,0)) return 0;
49 + if (!stralloc_cats(&line,":")) return 0;
50 + if (!stralloc_catulong0(&line,weight,0)) return 0;
51 + if (!stralloc_cats(&line,":")) return 0;
52 + if (!stralloc_catulong0(&line,port,0)) return 0;
53 + }
54 else if (byte_equal(data,2,DNS_T_A) && (dlen == 4)) {
55 char ipstr[IP4_FMT];
56 if (!stralloc_copys(&line,"+")) return 0;
57 @@ -217,6 +237,14 @@ unsigned int doit(char *buf,unsigned int
58 x_copy(buf,len,pos,data,4);
59 if (!stralloc_catb(&line,ipstr,ip4_fmt(ipstr,data))) return 0;
60 }
61 + else if (byte_equal(data,2,DNS_T_PTR)) {
62 + if (!stralloc_copys(&line,"^")) return 0;
63 + if (!dns_domain_todot_cat(&line,d1)) return 0;
64 + if (!stralloc_cats(&line,":")) return 0;
65 + x_getname(buf,len,pos,&d1);
66 + if (!dns_domain_todot_cat(&line,d1)) return 0;
67 + if (!stralloc_cats(&line,".")) return 0;
68 + }
69 else {
70 unsigned char ch;
71 unsigned char ch2;
72 --- a/dns.h
73 +++ b/dns.h
74 @@ -20,6 +20,7 @@
75 #define DNS_T_SIG "\0\30"
76 #define DNS_T_KEY "\0\31"
77 #define DNS_T_AAAA "\0\34"
78 +#define DNS_T_SRV "\0\41"
79 #define DNS_T_AXFR "\0\374"
80 #define DNS_T_ANY "\0\377"
81
82 --- a/tinydns-data.c
83 +++ b/tinydns-data.c
84 @@ -196,6 +196,7 @@ int main()
85 char type[2];
86 char soa[20];
87 char buf[4];
88 + char srv[6];
89
90 umask(022);
91
92 @@ -369,6 +370,43 @@ int main()
93 rr_finish(d2);
94 }
95 break;
96 +
97 + case 'S':
98 + if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();
99 + if (!stralloc_0(&f[6])) nomem();
100 + if (!scan_ulong(f[6].s,&ttl)) ttl = TTL_POSITIVE;
101 + ttdparse(&f[7],ttd);
102 + locparse(&f[8],loc);
103 +
104 + if (!stralloc_0(&f[1])) nomem();
105 +
106 + if (byte_chr(f[2].s,f[2].len,'.') >= f[2].len) {
107 + if (!stralloc_cats(&f[2],".srv.")) nomem();
108 + if (!stralloc_catb(&f[2],f[0].s,f[0].len)) nomem();
109 + }
110 + if (!dns_domain_fromdot(&d2,f[2].s,f[2].len)) nomem();
111 +
112 + if (!stralloc_0(&f[4])) nomem();
113 + if (!scan_ulong(f[4].s,&u)) u = 0;
114 + uint16_pack_big(srv,u);
115 + if (!stralloc_0(&f[5])) nomem();
116 + if (!scan_ulong(f[5].s,&u)) u = 0;
117 + uint16_pack_big(srv + 2,u);
118 + if (!stralloc_0(&f[3])) nomem();
119 + if (!scan_ulong(f[3].s,&u)) nomem();
120 + uint16_pack_big(srv + 4,u);
121 +
122 + rr_start(DNS_T_SRV,ttl,ttd,loc);
123 + rr_add(srv,6);
124 + rr_addname(d2);
125 + rr_finish(d1);
126 +
127 + if (ip4_scan(f[1].s,ip)) {
128 + rr_start(DNS_T_A,ttl,ttd,loc);
129 + rr_add(ip,4);
130 + rr_finish(d2);
131 + }
132 + break;
133
134 case '^': case 'C':
135 if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem();