mike01/pypacker — pull request #7 by ainoniwa (2014-12-03 12:04:28+00:00)
Title: layer567/dns.py: add domain name encoder and decoder

Add function to assemble DNS name.
This patch will work as below.

```
>>> from pypacker.layer567 import dns
>>> dns.name_encode("www.example.com")
b'\x03www\x07example\x03com'
>>> dns.name_decode(b"\x03www\x07example\x03com")
'www.example.com.'
>>>
>>> dns_h = dns.DNS(queries=dns.DNS.Query(name=dns.name_encode("www.example.com")))
>>> dns_h
DNS(id=4660, flags=288, questions_amount=1, answers_amount=0, authrr_amount=0, addrr_amount=0, queries=[Query(name=[b'\x03www\x07example\x03com'], postfix=0, type=1, cls=1, bytes=b'')], answers=[], auths=[], addrecords=[], bytes=b'')
>>> dns_h.queries[0].name[0]
b'\x03www\x07example\x03com'
>>> dns.name_decode(dns_h.queries[0].name[0])
'www.example.com.'
```