8 /* get a notification from another system of a changed zone */
10 dnnotify(DNSmsg *reqp, DNSmsg *repp, Request *r)
16 /* move one question from reqp to repp */
17 memset(repp, 0, sizeof(*repp));
23 repp->flags = Fresp | Onotify | Fauth;
26 if(zonerefreshprogram == nil)
29 /* make sure its the right type */
30 if(repp->qd->type != Tsoa)
33 syslog(0, logfile, "notification for %s", repp->qd->owner->name);
35 /* is it something we care about? */
36 a = inmyarea(repp->qd->owner->name);
40 syslog(0, logfile, "serial old %lud new %lud", a->soarr->soa->serial, repp->qd->soa->serial);
42 /* do nothing if it didn't change */
43 if(a->soarr->soa->serial== repp->qd->soa->serial)
50 * this isn't going to work as a thread!
54 ding(void *u, char *msg)
58 if(strstr(msg, "alarm"))
64 /* notify a slave that an area has changed. */
66 send_notify(char *slave, RR *soa, Request *req)
68 int i, len, n, reqno, status, fd;
69 uchar obuf[Maxudp+Udphdrsize];
70 uchar ibuf[Maxudp+Udphdrsize];
72 Udphdr *up = (Udphdr*)obuf;
76 /* create the request */
78 n = mkreq(soa->owner, Cin, obuf, Fauth | Onotify, reqno);
81 if(strcmp(ipattr(slave), "ip") == 0) {
82 parseip(up->raddr, slave);
84 rp = dnresolve(slave, Cin, Ta, req, nil, 0, 1, 1, &status);
87 parseip(up->raddr, rp->ip->name);
97 /* send 3 times or until we get anything back */
98 for(i = 0; i < 3; i++){
99 syslog(0, logfile, "sending %d byte notify to %s/%I.%d about %s", n, slave, up->raddr, nhgets(up->rport), soa->owner->name);
100 if(udpwrite(fd, (Udphdr*)obuf, obuf+Udphdrsize, n) != n)
103 len = udpread(fd, (Udphdr*)ibuf, ibuf+Udphdrsize, Maxudp);
105 if(len <= Udphdrsize)
107 err = convM2DNS(&ibuf[Udphdrsize], len, &repmsg);
110 if(repmsg.id == reqno && (repmsg.flags & Omask) == Onotify)
117 /* send notifies for any updated areas */
119 notify_areas(Area *a, Request *req)
123 for(; a != nil; a = a->next){
127 /* send notifies to all slaves */
128 for(s = a->soarr->soa->slaves; s != nil; s = s->next)
129 send_notify(s->name, a->soarr, req);
135 * process to notify other servers of changes
136 * (also reads in new databases)
147 notify_areas(owned, &req);