Exemplo n.º 1
0
def dumpRR(u):
    name, type, klass, ttl, rdlength = u.getRRheader()
    typename = Type.typestr(type)
    print('name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
        % (name,
           type, typename,
           klass, Class.classstr(klass),
           ttl))
    mname = 'get%sdata' % typename
    if hasattr(u, mname):
        print('  formatted rdata:', getattr(u, mname)())
    else:
        print('  binary rdata:', u.getbytes(rdlength))
Exemplo n.º 2
0
 def storeRR(self, u):
     r = {}
     r['name'], r['type'], r['class'], r[
         'ttl'], r['rdlength'] = u.getRRheader()
     r['typename'] = Type.typestr(r['type'])
     r['classstr'] = Class.classstr(r['class'])
     # print 'name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
     #      % (name,
     #        type, typename,
     #        klass, Class.classstr(class),
     #        ttl)
     mname = 'get%sdata' % r['typename']
     if hasattr(u, mname):
         r['data'] = getattr(u, mname)()
     else:
         r['data'] = u.getbytes(r['rdlength'])
     return r
Exemplo n.º 3
0
def dumpQ(u):
    qname, qtype, qclass = u.getQuestion()
    print('qname=%s, qtype=%d(%s), qclass=%d(%s)' \
        % (qname,
           qtype, Type.typestr(qtype),
           qclass, Class.classstr(qclass)))
Exemplo n.º 4
0
 def storeQ(self, u):
     q = {}
     q['qname'], q['qtype'], q['qclass'] = u.getQuestion()
     q['qtypestr'] = Type.typestr(q['qtype'])
     q['qclassstr'] = Class.classstr(q['qclass'])
     return q