Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 18 commits
  • 3 files changed
  • 0 comments
  • 1 contributor
Aug 18, 2013
rwall Branching to 'ad-cd-6680'
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39625 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
e6104b8
rwall Add the authenticData parameter.
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39626 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
b804f22
rwall Add the checkingDisabled parameter.
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39627 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
1a67e6f
rwall encoding and decoding of the authenticData bit
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39628 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
671e815
rwall encoding and decoding of the checkingDisabled bit
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39629 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
ceac4ae
rwall docstrings
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39630 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
340e508
rwall rewrap long lines
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39631 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
cef0424
rwall rename duplicate test method.
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39632 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
3feba3b
rwall move authenticData and checkingDisabled to the end of the argument list.
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39633 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
6ea175e
rwall newsfile
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39634 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
3bdb59f
Aug 22, 2013
rwall Add missing word in id docstring
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39673 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
5e96d67
rwall remove ungrammatical commas
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39674 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
e772ac9
rwall clearer documentation of the TC flag
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39675 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
5b4d972
rwall Clearer documentation of the authenticData and checkingDisabled flags
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39676 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
5e0457f
rwall replace assertIdentical with assertEqual
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39677 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
6a3f04f
rwall remove positional argument tests
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39678 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
93d48eb
Aug 23, 2013
rwall replace remaining cases of assertIdentical with assertEqual
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39680 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
edad180
rwall move test message bytes to a global variable.
git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/branches/ad-cd-6680@39684 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
c80b2f9
106 twisted/names/dns.py
@@ -1914,9 +1914,33 @@ class Message:
1914 1914 L{Message} contains all the information represented by a single
1915 1915 DNS request or response.
1916 1916
1917   - @ivar rCode: A response code, used to indicate success or failure in a
1918   - message which is a response from a server to a client request.
1919   - @type rCode: C{0 <= int < 16}
  1917 + @ivar id: See L{__init__}
  1918 + @ivar answer: See L{__init__}
  1919 + @ivar opCode: See L{__init__}
  1920 + @ivar recDes: See L{__init__}
  1921 + @ivar recAv: See L{__init__}
  1922 + @ivar auth: See L{__init__}
  1923 + @ivar rCode: See L{__init__}
  1924 + @ivar trunc: See L{__init__}
  1925 + @ivar maxSize: See L{__init__}
  1926 + @ivar authenticData: See L{__init__}
  1927 + @ivar checkingDisabled: See L{__init__}
  1928 +
  1929 + @ivar queries: The queries which are being asked of or answered by
  1930 + DNS server.
  1931 + @type queries: L{list} of L{Query}
  1932 +
  1933 + @ivar answers: Records containing the answers to C{queries} if
  1934 + this is a response message.
  1935 + @type answers: L{list} of L{RRHeader}
  1936 +
  1937 + @ivar authority: Records containing information about the
  1938 + authoritative DNS servers for the names in C{queries}.
  1939 + @type authority: L{list} of L{RRHeader}
  1940 +
  1941 + @ivar additional: Records containing IP addresses of host names
  1942 + in C{answers} and C{authority}.
  1943 + @type additional: L{list} of L{RRHeader}
1920 1944 """
1921 1945 headerFmt = "!H2B4H"
1922 1946 headerSize = struct.calcsize(headerFmt)
@@ -1925,7 +1949,68 @@ class Message:
1925 1949 queries = answers = add = ns = None
1926 1950
1927 1951 def __init__(self, id=0, answer=0, opCode=0, recDes=0, recAv=0,
1928   - auth=0, rCode=OK, trunc=0, maxSize=512):
  1952 + auth=0, rCode=OK, trunc=0, maxSize=512,
  1953 + authenticData=0, checkingDisabled=0):
  1954 + """
  1955 + @param id: A 16 bit identifier assigned by the program that
  1956 + generates any kind of query. This identifier is copied to
  1957 + the corresponding reply and can be used by the requester
  1958 + to match up replies to outstanding queries.
  1959 + @type id: L{int}
  1960 +
  1961 + @param answer: A one bit field that specifies whether this
  1962 + message is a query (0), or a response (1).
  1963 + @type answer: L{int}
  1964 +
  1965 + @param opCode: A four bit field that specifies kind of query in
  1966 + this message. This value is set by the originator of a query
  1967 + and copied into the response.
  1968 + @type opCode: L{int}
  1969 +
  1970 + @param recDes: Recursion Desired - this bit may be set in a
  1971 + query and is copied into the response. If RD is set, it
  1972 + directs the name server to pursue the query recursively.
  1973 + Recursive query support is optional.
  1974 + @type recDes: L{int}
  1975 +
  1976 + @param recAv: Recursion Available - this bit is set or cleared
  1977 + in a response and denotes whether recursive query support
  1978 + is available in the name server.
  1979 + @type recAv: L{int}
  1980 +
  1981 + @param auth: Authoritative Answer - this bit is valid in
  1982 + responses and specifies that the responding name server
  1983 + is an authority for the domain name in question section.
  1984 + @type auth: L{int}
  1985 +
  1986 + @ivar rCode: A response code, used to indicate success or failure in a
  1987 + message which is a response from a server to a client request.
  1988 + @type rCode: C{0 <= int < 16}
  1989 +
  1990 + @param trunc: A flag indicating that this message was
  1991 + truncated due to length greater than that permitted on the
  1992 + transmission channel.
  1993 + @type trunc: L{int}
  1994 +
  1995 + @param maxSize: The requestor's UDP payload size is the number
  1996 + of octets of the largest UDP payload that can be
  1997 + reassembled and delivered in the requestor's network
  1998 + stack.
  1999 + @type maxSize: L{int}
  2000 +
  2001 + @param authenticData: A flag indicating in a response that all
  2002 + the data included in the answer and authority portion of
  2003 + the response has been authenticated by the server
  2004 + according to the policies of that server.
  2005 + See U{RFC2535 section-6.1<https://tools.ietf.org/html/rfc2535#section-6.1>}.
  2006 + @type authenticData: L{int}
  2007 +
  2008 + @param checkingDisabled: A flag indicating in a query that
  2009 + pending (non-authenticated) data is acceptable to the
  2010 + resolver sending the query.
  2011 + See U{RFC2535 section-6.1<https://tools.ietf.org/html/rfc2535#section-6.1>}.
  2012 + @type authenticData: L{int}
  2013 + """
1929 2014 self.maxSize = maxSize
1930 2015 self.id = id
1931 2016 self.answer = answer
@@ -1935,6 +2020,9 @@ def __init__(self, id=0, answer=0, opCode=0, recDes=0, recAv=0,
1935 2020 self.recDes = recDes
1936 2021 self.recAv = recAv
1937 2022 self.rCode = rCode
  2023 + self.authenticData = authenticData
  2024 + self.checkingDisabled = checkingDisabled
  2025 +
1938 2026 self.queries = []
1939 2027 self.answers = []
1940 2028 self.authority = []
@@ -1979,6 +2067,8 @@ def encode(self, strio):
1979 2067 | ((self.trunc & 1 ) << 1 )
1980 2068 | ( self.recDes & 1 ) )
1981 2069 byte4 = ( ( (self.recAv & 1 ) << 7 )
  2070 + | ((self.authenticData & 1) << 5)
  2071 + | ((self.checkingDisabled & 1) << 4)
1982 2072 | (self.rCode & 0xf ) )
1983 2073
1984 2074 strio.write(struct.pack(self.headerFmt, self.id, byte3, byte4,
@@ -1998,6 +2088,8 @@ def decode(self, strio, length=None):
1998 2088 self.trunc = ( byte3 >> 1 ) & 1
1999 2089 self.recDes = byte3 & 1
2000 2090 self.recAv = ( byte4 >> 7 ) & 1
  2091 + self.authenticData = ( byte4 >> 5 ) & 1
  2092 + self.checkingDisabled = ( byte4 >> 4 ) & 1
2001 2093 self.rCode = byte4 & 0xf
2002 2094
2003 2095 self.queries = []
@@ -2009,7 +2101,11 @@ def decode(self, strio, length=None):
2009 2101 return
2010 2102 self.queries.append(q)
2011 2103
2012   - items = ((self.answers, nans), (self.authority, nns), (self.additional, nadd))
  2104 + items = (
  2105 + (self.answers, nans),
  2106 + (self.authority, nns),
  2107 + (self.additional, nadd))
  2108 +
2013 2109 for (l, n) in items:
2014 2110 self.parseRecords(l, n, strio)
2015 2111
114 twisted/names/test/test_dns.py
@@ -200,8 +200,8 @@ def test_unknown(self):
200 200 b'\x01\x00' # Message ID
201 201 b'\x00' # answer bit, opCode nibble, auth bit, trunc bit, recursive
202 202 # bit
203   - b'\x00' # recursion bit, empty bit, empty bit, empty bit, response
204   - # code nibble
  203 + b'\x00' # recursion bit, empty bit, authenticData bit,
  204 + # checkingDisabled bit, response code nibble
205 205 b'\x00\x01' # number of queries
206 206 b'\x00\x01' # number of answers
207 207 b'\x00\x00' # number of authorities
@@ -571,11 +571,110 @@ def test_TXT(self):
571 571
572 572
573 573
  574 +MESSAGE_AUTHENTIC_DATA_BYTES = (
  575 + b'\x00\x00' # ID
  576 + b'\x00' #
  577 + b'\x20' # RA, Z, AD=1, CD, RCODE
  578 + b'\x00\x00' # Query count
  579 + b'\x00\x00' # Answer count
  580 + b'\x00\x00' # Authority count
  581 + b'\x00\x00' # Additional count
  582 +)
  583 +
  584 +
  585 +
  586 +MESSAGE_CHECKING_DISABLED_BYTES = (
  587 + b'\x00\x00' # ID
  588 + b'\x00' #
  589 + b'\x10' # RA, Z, AD, CD=1, RCODE
  590 + b'\x00\x00' # Query count
  591 + b'\x00\x00' # Answer count
  592 + b'\x00\x00' # Authority count
  593 + b'\x00\x00' # Additional count
  594 +)
  595 +
  596 +
  597 +
574 598 class MessageTestCase(unittest.SynchronousTestCase):
575 599 """
576 600 Tests for L{twisted.names.dns.Message}.
577 601 """
578 602
  603 + def test_authenticDataDefault(self):
  604 + """