Skip to main content

Module notify

Module notify 

Source
Expand description

Zone change notification: NOTIFY (RFC 1996).

A primary tells its secondaries that a zone changed with a NOTIFY query (opcode 4, AA set) whose question is zone SOA class and whose answer section may carry the new SOA as a hint (RFC 1996 §3.7). The secondary acknowledges with a response echoing the ID and question (§4.7), then checks the primary’s SOA and transfers the zone.

use dnsbox::{Class, Message, MessageBuilder, NameBuf};
use dnsbox::notify::{self, NotifyMessage};

let zone: NameBuf = "example.com".parse()?;
let mut buf = [0u8; 512];
let mut b = MessageBuilder::new(&mut buf)?;
b.set_id(10);
notify::build_query(&mut b, &zone, Class::IN, None)?;
let query = b.finish();

let n = NotifyMessage::new(Message::parse_validated(query)?)?;
assert_eq!(n.zone().name(), zone.as_name());
let mut rbuf = [0u8; 512];
let mut r = MessageBuilder::new(&mut rbuf)?;
notify::build_response(&mut r, &n)?;
assert!(NotifyMessage::new(Message::parse(r.finish())?)?.is_response());

Structs§

NotifyMessage
A parsed NOTIFY message, query or response (RFC 1996 §3).

Functions§

build_query
Writes a NOTIFY query for zone into an empty builder (RFC 1996 §3.7): opcode NOTIFY, AA set, question zone SOA class, and, if soa is given as (ttl, soa), the new SOA in the answer section as a hint (§3.11). The ID is left as set on the builder.
build_response
Writes the response to a NOTIFY query into an empty builder (RFC 1996 §4.7): same ID, opcode NOTIFY, QR and AA set, the question echoed.