Commit a3758ab2 authored by Guido Trotter's avatar Guido Trotter
Browse files

Add a magic fourcc code to confd packets

This will make it easier to change the protocol later on
Signed-off-by: default avatarGuido Trotter <>
Reviewed-by: default avatarMichael Hanselmann <>
parent c8eded0b
......@@ -69,8 +69,21 @@ class ConfdAsyncUDPServer(daemon.AsyncUDPSocket):
# this method is overriding a daemon.AsyncUDPSocket method
def handle_datagram(self, payload_in, ip, port):
payload_out = self.processor.ExecQuery(payload_in, ip, port)
if payload_out is not None:
if len(payload_in) < len(constants.CONFD_MAGIC_FOURCC):
logging.debug("Received a query which is too short to be true")
magic_number = payload_in[:4]
query = payload_in[4:]
if magic_number != constants.CONFD_MAGIC_FOURCC:
logging.debug("Received a query with an unknown magic number")
answer = self.processor.ExecQuery(query, ip, port)
if answer is not None:
payload_out = ''.join([constants.CONFD_MAGIC_FOURCC, answer])
self.enqueue_send(ip, port, payload_out)
......@@ -682,6 +682,12 @@ CONFD_CONFIG_RELOAD_TIMEOUT = 60
# to serve more requests.
# Magic number prepended to all confd queries.
# This allows us to distinguish different types of confd protocols and handle
# them. For example by changing this we can move the whole payload to be
# compressed, or move away from json.
# Maximum UDP datagram size.
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment