Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 115 lines (91 sloc) 3.659 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 val string_of_in_addr_t : Stubsnatpmp.in_addr_t -> string ;;
19 val string_of_in_addr : Stubsnatpmp.in_addr -> string ;;
20
21 val get_gateway_of_natpmp_t : Stubsnatpmp.natpmp_t -> Stubsnatpmp.in_addr_t ;;
22 val generate_in_addr : unit -> Stubsnatpmp.in_addr ;;
23
24 val in_addr_of_string : string -> Stubsnatpmp.in_addr ;;
25 val pretty_string_of_in_addr : Stubsnatpmp.in_addr -> string ;;
26
27 val generate_natpmp_t : unit -> Stubsnatpmp.natpmp_t ;;
28
29 type natpmp_err =
30 | NATPMP_ERR_INVALIDARGS
31 | NATPMP_ERR_SOCKETERROR
32 | NATPMP_ERR_CANNOTGETGATEWAY
33 | NATPMP_ERR_CLOSEERR
34 | NATPMP_ERR_RECVFROM
35 | NATPMP_ERR_NOPENDINGREQ
36 | NATPMP_ERR_NOGATEWAYSUPPORT
37 | NATPMP_ERR_CONNECTERR
38 | NATPMP_ERR_WRONGPACKETSOURCE
39 | NATPMP_ERR_SENDERR
40 | NATPMP_ERR_FCNTLERROR
41 | NATPMP_ERR_GETTIMEOFDAYERR
42 | NATPMP_ERR_UNSUPPORTEDVERSION
43 | NATPMP_ERR_UNSUPPORTEDOPCODE
44 | NATPMP_ERR_UNDEFINEDERROR
45 | NATPMP_ERR_NOTAUTHORIZED
46 | NATPMP_ERR_NETWORKFAILURE
47 | NATPMP_ERR_OUTOFRESOURCES
48 | NATPMP_TRYAGAIN ;;
49
50 val string_of_natpmp_err : natpmp_err -> string ;;
51
52 exception NATPMP_ERR of (int * natpmp_err) ;;
53
54 val string_of_exn_natpmp_err : exn -> string ;;
55
56 (*
57 * NATPMP_ERR_INVALIDARGS
58 * NATPMP_ERR_SOCKETERROR
59 * NATPMP_ERR_FCNTLERROR
60 * NATPMP_ERR_CANNOTGETGATEWAY
61 * NATPMP_ERR_CONNECTERR *)
62 val initnatpmp : Stubsnatpmp.in_addr_t option -> Stubsnatpmp.natpmp_t ;;
63
64 (*
65 * 0 = OK
66 * NATPMP_ERR_INVALIDARGS
67 * NATPMP_ERR_CLOSEERR *)
68 val closenatpmp : Stubsnatpmp.natpmp_t -> unit ;;
69
70 (*
71 * 2 = OK (size of the request)
72 * NATPMP_ERR_INVALIDARGS
73 * NATPMP_ERR_SENDERR *)
74 val sendpublicaddressrequest : Stubsnatpmp.natpmp_t -> Stubsnatpmp.natpmp_t ;;
75
76 (* 0 = OK
77 * NATPMP_ERR_INVALIDARGS
78 * NATPMP_ERR_GETTIMEOFDAYERR
79 * NATPMP_ERR_NOPENDINGREQ *)
80 val getnatpmprequesttimeout : Stubsnatpmp.natpmp_t -> Stubsnatpmp.natpmp_t * Stubsnatpmp.timeval ;;
81
82
83 (*
84 * 12 = OK (size of the request)
85 * NATPMP_ERR_INVALIDARGS
86 * NATPMP_ERR_SENDERR *)
87 val sendnewportmappingrequest : Stubsnatpmp.natpmp_t -> Stubsnatpmp.switch_protocol -> Stubsnatpmp.uint16_t -> Stubsnatpmp.uint16_t -> Stubsnatpmp.uint32_t -> Stubsnatpmp.natpmp_t ;;
88
89 (* 0 = OK
90 * NATPMP_TRYAGAIN
91 * NATPMP_ERR_INVALIDARGS
92 * NATPMP_ERR_NOPENDINGREQ
93 * NATPMP_ERR_NOGATEWAYSUPPORT
94 * NATPMP_ERR_RECVFROM
95 * NATPMP_ERR_WRONGPACKETSOURCE
96 * NATPMP_ERR_UNSUPPORTEDVERSION
97 * NATPMP_ERR_UNSUPPORTEDOPCODE
98 * NATPMP_ERR_NOTAUTHORIZED
99 * NATPMP_ERR_NETWORKFAILURE
100 * NATPMP_ERR_OUTOFRESOURCES
101 * NATPMP_ERR_UNSUPPORTEDOPCODE
102 * NATPMP_ERR_UNDEFINEDERROR *)
103 val readnatpmpresponseorretry : Stubsnatpmp.natpmp_t -> Stubsnatpmp.natpmp_t * Stubsnatpmp.natpmpresp_t ;;
104
105 module Helpers : sig
106
107 type result = Correct of int (* public port *) | Wrong of (int * natpmp_err) ;;
108
109 val open_a_port : ?forced_gateway:Stubsnatpmp.in_addr_t -> protocol:Stubsnatpmp.switch_protocol
110 -> private_port:int -> public_port:int -> lifetime:int32 -> result ;;
111
112 val close_a_port : protocol:Stubsnatpmp.switch_protocol -> private_port:int -> public_port:int -> bool ;;
113
114 end ;;
Something went wrong with that request. Please try again.