Skip to content
This repository
tag: v1367
Fetching contributors…

Cannot retrieve contributors at this time

file 114 lines (91 sloc) 3.659 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
val string_of_in_addr_t : Stubsnatpmp.in_addr_t -> string ;;
val string_of_in_addr : Stubsnatpmp.in_addr -> string ;;

val get_gateway_of_natpmp_t : Stubsnatpmp.natpmp_t -> Stubsnatpmp.in_addr_t ;;
val generate_in_addr : unit -> Stubsnatpmp.in_addr ;;

val in_addr_of_string : string -> Stubsnatpmp.in_addr ;;
val pretty_string_of_in_addr : Stubsnatpmp.in_addr -> string ;;

val generate_natpmp_t : unit -> Stubsnatpmp.natpmp_t ;;

type natpmp_err =
  | NATPMP_ERR_INVALIDARGS
  | NATPMP_ERR_SOCKETERROR
  | NATPMP_ERR_CANNOTGETGATEWAY
  | NATPMP_ERR_CLOSEERR
  | NATPMP_ERR_RECVFROM
  | NATPMP_ERR_NOPENDINGREQ
  | NATPMP_ERR_NOGATEWAYSUPPORT
  | NATPMP_ERR_CONNECTERR
  | NATPMP_ERR_WRONGPACKETSOURCE
  | NATPMP_ERR_SENDERR
  | NATPMP_ERR_FCNTLERROR
  | NATPMP_ERR_GETTIMEOFDAYERR
  | NATPMP_ERR_UNSUPPORTEDVERSION
  | NATPMP_ERR_UNSUPPORTEDOPCODE
  | NATPMP_ERR_UNDEFINEDERROR
  | NATPMP_ERR_NOTAUTHORIZED
  | NATPMP_ERR_NETWORKFAILURE
  | NATPMP_ERR_OUTOFRESOURCES
  | NATPMP_TRYAGAIN ;;

val string_of_natpmp_err : natpmp_err -> string ;;

exception NATPMP_ERR of (int * natpmp_err) ;;

val string_of_exn_natpmp_err : exn -> string ;;

(*
* NATPMP_ERR_INVALIDARGS
* NATPMP_ERR_SOCKETERROR
* NATPMP_ERR_FCNTLERROR
* NATPMP_ERR_CANNOTGETGATEWAY
* NATPMP_ERR_CONNECTERR *)
val initnatpmp : Stubsnatpmp.in_addr_t option -> Stubsnatpmp.natpmp_t ;;

(*
* 0 = OK
* NATPMP_ERR_INVALIDARGS
* NATPMP_ERR_CLOSEERR *)
val closenatpmp : Stubsnatpmp.natpmp_t -> unit ;;

(*
* 2 = OK (size of the request)
* NATPMP_ERR_INVALIDARGS
* NATPMP_ERR_SENDERR *)
val sendpublicaddressrequest : Stubsnatpmp.natpmp_t -> Stubsnatpmp.natpmp_t ;;

(* 0 = OK
* NATPMP_ERR_INVALIDARGS
* NATPMP_ERR_GETTIMEOFDAYERR
* NATPMP_ERR_NOPENDINGREQ *)
val getnatpmprequesttimeout : Stubsnatpmp.natpmp_t -> Stubsnatpmp.natpmp_t * Stubsnatpmp.timeval ;;


(*
* 12 = OK (size of the request)
* NATPMP_ERR_INVALIDARGS
* NATPMP_ERR_SENDERR *)
val sendnewportmappingrequest : Stubsnatpmp.natpmp_t -> Stubsnatpmp.switch_protocol -> Stubsnatpmp.uint16_t -> Stubsnatpmp.uint16_t -> Stubsnatpmp.uint32_t -> Stubsnatpmp.natpmp_t ;;

(* 0 = OK
* NATPMP_TRYAGAIN
* NATPMP_ERR_INVALIDARGS
* NATPMP_ERR_NOPENDINGREQ
* NATPMP_ERR_NOGATEWAYSUPPORT
* NATPMP_ERR_RECVFROM
* NATPMP_ERR_WRONGPACKETSOURCE
* NATPMP_ERR_UNSUPPORTEDVERSION
* NATPMP_ERR_UNSUPPORTEDOPCODE
* NATPMP_ERR_NOTAUTHORIZED
* NATPMP_ERR_NETWORKFAILURE
* NATPMP_ERR_OUTOFRESOURCES
* NATPMP_ERR_UNSUPPORTEDOPCODE
* NATPMP_ERR_UNDEFINEDERROR *)
val readnatpmpresponseorretry : Stubsnatpmp.natpmp_t -> Stubsnatpmp.natpmp_t * Stubsnatpmp.natpmpresp_t ;;

module Helpers : sig

  type result = Correct of int (* public port *) | Wrong of (int * natpmp_err) ;;

  val open_a_port : ?forced_gateway:Stubsnatpmp.in_addr_t -> protocol:Stubsnatpmp.switch_protocol
    -> private_port:int -> public_port:int -> lifetime:int32 -> result ;;

  val close_a_port : protocol:Stubsnatpmp.switch_protocol -> private_port:int -> public_port:int -> bool ;;

end ;;
Something went wrong with that request. Please try again.