mor1/ocaml-dns — pull request #3 by crotsos (2012-05-20 15:43:08+00:00)
Title: a couple of fixes to support TXT rr parsing from multicast dns and the cache flush bit. 

Did a couple of edits in the source code to support the following:

1) added an option on the resolver method in order to allow application to choose the port to which it connects to the dns server. This is required by signpost as the iodine server appends some additional bit in the response packet which break the ocaml dns parsing code. This way I can direct the resolver to connect to port 5353 where the original signpost dns server listens and avoid any packet processing by the iodine server.

2) TXT rr multiple strings.

In multicast dns the TXT rr type containts multiple string as labels. The difference with traditional labels is the fact that the label can have a length longer than 64 bytes and the zero length last label is not used. In order to fix this, I added an option in parse_label function which can turn off the label length check during parsing. This is used in the code only when a TXT rr is parsed. Also in the bitstring parsing, I added an additional match which will terminate parsing when the bitstring parsed is zero length. Otherwise the code will result in an infinite recursion looking for a zero length label.

3) In the mdns, it appears that the ietf draft reduces the length of the class field in each rr and uses the first bit as a cache flush flag. This is used to force other computers to discard any state they have for the specific rr and accept informations contained in packet.

this modification though, creates a problem in the int_to_rr_class method which is not aware of this bit usage. In order to avoid any parsing failures, in the bitmatch I ignore the first bit of the class field.

you can read the details on the cache flush bit in section 6.6
http://tools.ietf.org/html/draft-cheshire-dnsext-multicastdns-04

I think that this modification is not backwards compatible with existing dns parsing rules and so I am not sure if you want to add them in the main branch.