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 ding(void *u, char *msg)
54 if(strstr(msg, "alarm"))
60 /* notify a slave that an area has changed. */
62 send_notify(char *slave, RR *soa, Request *req)
64 int i, len, n, reqno, status, fd;
65 uchar obuf[Maxudp+OUdphdrsize];
66 uchar ibuf[Maxudp+OUdphdrsize];
68 OUdphdr *up = (OUdphdr*)obuf;
72 /* create the request */
74 n = mkreq(soa->owner, Cin, obuf, Fauth | Onotify, reqno);
77 if(strcmp(ipattr(slave), "ip") == 0) {
78 parseip(up->raddr, slave);
80 rp = dnresolve(slave, Cin, Ta, req, nil, 0, 1, 1, &status);
83 parseip(up->raddr, rp->ip->name);
93 /* send 3 times or until we get anything back */
94 for(i = 0; i < 3; i++){
95 syslog(0, logfile, "sending %d byte notify to %s/%I.%d about %s", n, slave, up->raddr, nhgets(up->rport), soa->owner->name);
96 if(udpwrite(fd, (OUdphdr*)obuf, obuf+OUdphdrsize, n) != n)
99 len = udpread(fd, (Udphdr*)ibuf, ibuf+OUdphdrsize, Maxudp);
101 if(len <= OUdphdrsize)
103 err = convM2DNS(&ibuf[OUdphdrsize], len, &repmsg);
106 if(repmsg.id == reqno && (repmsg.flags & Omask) == Onotify)
113 /* send notifies for any updated areas */
115 notify_areas(Area *a, Request *req)
119 for(; a != nil; a = a->next){
123 /* send notifies to all slaves */
124 for(s = a->soarr->soa->slaves; s != nil; s = s->next)
125 send_notify(s->name, a->soarr, req);
131 * process to notify other servers of changes
132 * (also reads in new databases)
143 switch(rfork(RFPROC|RFNOTEG|RFMEM|RFNOWAIT)){
152 req.isslave = 1; /* son't fork off subprocesses */
156 notify_areas(owned, &req);