TOR: fix compilation
[tomato.git] / release / src / router / miniupnpd / upnpredirect.h
blobb549824ed5a080d497ff996a551cdd2e36c40f95
1 /* $Id: upnpredirect.h,v 1.35 2012/09/27 15:47:15 nanard Exp $ */
2 /* MiniUPnP project
3 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 * (c) 2006-2012 Thomas Bernard
5 * This software is subject to the conditions detailed
6 * in the LICENCE file provided within the distribution */
8 #ifndef UPNPREDIRECT_H_INCLUDED
9 #define UPNPREDIRECT_H_INCLUDED
11 /* for u_int64_t */
12 #include <sys/types.h>
14 #include "config.h"
16 #ifdef ENABLE_LEASEFILE
17 int reload_from_lease_file(void);
18 #endif
20 /* upnp_redirect()
21 * calls OS/fw dependant implementation of the redirection.
22 * protocol should be the string "TCP" or "UDP"
23 * returns: 0 on success
24 * -1 failed to redirect
25 * -2 already redirected
26 * -3 permission check failed
28 int
29 upnp_redirect(const char * rhost, unsigned short eport,
30 const char * iaddr, unsigned short iport,
31 const char * protocol, const char * desc,
32 unsigned int leaseduration);
34 /* upnp_redirect_internal()
35 * same as upnp_redirect() without any check */
36 int
37 upnp_redirect_internal(const char * rhost, unsigned short eport,
38 const char * iaddr, unsigned short iport,
39 int proto, const char * desc,
40 unsigned int timestamp);
42 /* upnp_get_redirection_infos()
43 * returns : 0 on success
44 * -1 failed to get the port mapping entry or no entry exists */
45 int
46 upnp_get_redirection_infos(unsigned short eport, const char * protocol,
47 unsigned short * iport, char * iaddr, int iaddrlen,
48 char * desc, int desclen,
49 char * rhost, int rhostlen,
50 unsigned int * leaseduration);
52 /* upnp_get_redirection_infos_by_index()
53 * returns : 0 on success
54 * -1 failed to get the port mapping or index out of range */
55 int
56 upnp_get_redirection_infos_by_index(int index,
57 unsigned short * eport, char * protocol,
58 unsigned short * iport,
59 char * iaddr, int iaddrlen,
60 char * desc, int desclen,
61 char * rhost, int rhostlen,
62 unsigned int * leaseduration);
64 /* upnp_delete_redirection()
65 * returns: 0 on success
66 * -1 on failure*/
67 int
68 upnp_delete_redirection(unsigned short eport, const char * protocol);
70 /* _upnp_delete_redir()
71 * same as above */
72 int
73 _upnp_delete_redir(unsigned short eport, int proto);
75 /* Periodic cleanup functions
77 struct rule_state
79 u_int64_t packets;
80 u_int64_t bytes;
81 struct rule_state * next;
82 unsigned short eport;
83 unsigned char proto;
84 unsigned char to_remove;
87 /* return a linked list of all rules
88 * or an empty list if there are not enough
89 * As a "side effect", delete rules which are expired */
90 struct rule_state *
91 get_upnp_rules_state_list(int max_rules_number_target);
93 /* return the number of port mapping entries */
94 int
95 upnp_get_portmapping_number_of_entries(void);
97 /* remove_unused_rules() :
98 * also free the list */
99 void
100 remove_unused_rules(struct rule_state * list);
102 /* upnp_get_portmappings_in_range()
103 * return a list of all "external" ports for which a port
104 * mapping exists */
105 unsigned short *
106 upnp_get_portmappings_in_range(unsigned short startport,
107 unsigned short endport,
108 const char * protocol,
109 unsigned int * number);
111 /* stuff for responding to miniupnpdctl */
112 #ifdef USE_MINIUPNPDCTL
113 void
114 write_ruleset_details(int s);
115 #endif
117 #endif