summaryrefslogtreecommitdiff
path: root/dns/renderer.py
diff options
context:
space:
mode:
Diffstat (limited to 'dns/renderer.py')
-rw-r--r--dns/renderer.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/dns/renderer.py b/dns/renderer.py
index 07bce98..ef53899 100644
--- a/dns/renderer.py
+++ b/dns/renderer.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007 Nominum, Inc.
+# Copyright (C) 2001-2009 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -202,7 +202,7 @@ class Renderer(object):
raise dns.exception.TooBig
self.counts[section] += n
- def add_edns(self, edns, ednsflags, payload):
+ def add_edns(self, edns, ednsflags, payload, options=None):
"""Add an EDNS OPT record to the message.
@param edns: The EDNS level to use.
@@ -212,6 +212,8 @@ class Renderer(object):
@param payload: The EDNS sender's payload field, which is the maximum
size of UDP datagram the sender can handle.
@type payload: int
+ @param options: The EDNS options list
+ @type options: list of dns.edns.Option instances
@see: RFC 2671
"""
@@ -222,6 +224,25 @@ class Renderer(object):
before = self.output.tell()
self.output.write(struct.pack('!BHHIH', 0, dns.rdatatype.OPT, payload,
ednsflags, 0))
+ if not options is None:
+ lstart = self.output.tell()
+ for opt in options:
+ stuff = struct.pack("!HH", opt.otype, 0)
+ self.output.write(stuff)
+ start = self.output.tell()
+ opt.to_wire(self.output)
+ end = self.output.tell()
+ assert end - start < 65536
+ self.output.seek(start - 2)
+ stuff = struct.pack("!H", end - start)
+ self.output.write(stuff)
+ self.output.seek(0, 2)
+ lend = self.output.tell()
+ assert lend - lstart < 65536
+ self.output.seek(lstart - 2)
+ stuff = struct.pack("!H", lend - lstart)
+ self.output.write(stuff)
+ self.output.seek(0, 2)
after = self.output.tell()
if after >= self.max_size:
self._rollback(before)