1 /* $Id: upnpredirect.h,v 1.35 2012/09/27 15:47:15 nanard Exp $ */
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
12 #include <sys/types.h>
16 #ifdef ENABLE_LEASEFILE
17 int reload_from_lease_file(void);
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
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 */
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 */
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 */
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
68 upnp_delete_redirection(unsigned short eport
, const char * protocol
);
70 /* _upnp_delete_redir()
73 _upnp_delete_redir(unsigned short eport
, int proto
);
75 /* Periodic cleanup functions
81 struct rule_state
* next
;
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 */
91 get_upnp_rules_state_list(int max_rules_number_target
);
93 /* return the number of port mapping entries */
95 upnp_get_portmapping_number_of_entries(void);
97 /* remove_unused_rules() :
98 * also free the list */
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
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
114 write_ruleset_details(int s
);