code: def add_edns(self, edns, ednsflags, payload, options=None):
          
  
          # make sure the EDNS version in ednsflags agrees with edns
          ednsflags &= 0xFF00FFFFL
          ednsflags |= (edns << 16)
          self._set_section(ADDITIONAL)
          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)
              raise dns.exception.TooBig
          self.counts[ADDITIONAL] += 1
docs: Add an EDNS OPT record to the message.
  
          @param edns: The EDNS level to use.
          @type edns: int
          @param ednsflags: EDNS flag values.
          @type ednsflags: int
          @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