Skip to content

Commit

Permalink
Parse named services; require uri.services_full
Browse files Browse the repository at this point in the history
Fixes mirage#67. A new dependency on uri was added. mirage/ocaml-uri#74 tracks specific
packages for the IANA registries.
  • Loading branch information
dsheets committed May 12, 2015
1 parent c11a7a2 commit 9e2277e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Name.for_reverse has been replaced by Name.of_ipaddr
* Name.of_ipaddr accepts a Ipaddr.t and produces a name suitable for reverse DNS
* We now require >= ipaddr.2.6.0 to support Name.of_ipaddr
* Uri 1.9.0+ is now required for its uri.services_full service registry

0.14.1 (2015-03-29):
* Reduce namespace pollution in `name.ml` to avoid breaking with Cstruct 1.6.0+.
Expand Down
6 changes: 3 additions & 3 deletions _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.4
Name: dns
Version: 0.14.1
Version: 0.15.0
Authors: Anil Madhavapeddy, Tim Deegan, Richard Mortier, Haris Rotsos, David Sheets, Thomas Gazagnaire, Luke Dunstan
Maintainers: Anil Madhavapeddy <anil@recoil.org>
License: ISC
Expand Down Expand Up @@ -35,8 +35,8 @@ Library dns
Modules:
Hashcons, Loader, Name, Operators, Packet, Query, RR, Trie,
Zone, Zone_lexer, Zone_parser, Resolvconf, Buf, Protocol
BuildDepends: cstruct (>= 0.7.1), cstruct.syntax, re, re.str, ipaddr (>= 2.2.0), base64 (>= 2.0.0), bytes
XMetaRequires: cstruct, re, re.str, ipaddr, base64, bytes
BuildDepends: cstruct (>= 0.7.1), cstruct.syntax, re, re.str, ipaddr (>= 2.2.0), base64 (>= 2.0.0), bytes, uri.services_full
XMetaRequires: cstruct, re, re.str, ipaddr, base64, bytes, uri.services_full

Library "dns-lwt"
Path: lwt
Expand Down
19 changes: 12 additions & 7 deletions lib/zone_parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ let parse_wks proto services =
(*
try (getservbyname s (getprotobynumber proto).p_name).s_port
*)
try raise Not_found
with Not_found ->
parse_error ("unknown service \"" ^ s ^ "\" for protocol "
^ (string_of_int (Cstruct.byte_to_int proto)));
raise Parsing.Parse_error
let proto, ports = match Cstruct.byte_to_int proto with
| 6 -> "tcp", Uri_services_full.tcp_port_of_service s
| 17 -> "udp", Uri_services_full.udp_port_of_service s
| n -> string_of_int n, []
in
match ports with
| port::_ -> port
| [] ->
parse_error ("unknown service \"" ^ s ^ "\" for protocol " ^ proto);
raise Parsing.Parse_error
in let addport bitmap n =
let byte = n/8 in
let bit = 128 lsr (n mod 8) in
Expand Down Expand Up @@ -303,8 +308,8 @@ proto: charstring
/*
{ try (getprotobyname $1).p_proto
*/
{ try raise Not_found
with Not_found -> try parse_byte $1
{ match $1 with "tcp" -> char_of_int 6 | "udp" -> char_of_int 17 | _ ->
try parse_byte $1
with Parsing.Parse_error ->
parse_error ($1 ^ " is not a known IP protocol");
raise Parsing.Parse_error }
Expand Down
1 change: 1 addition & 0 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ depends: [
"re"
"cmdliner"
"ipaddr" {>= "2.6.0"}
"uri" {>= "1.9.0"}
"base64" {>= "2.0.0"}
"ounit"
"pcap-format" {test}
Expand Down

0 comments on commit 9e2277e

Please sign in to comment.