2012-05-01 20:25:30 +00:00
|
|
|
/* $Id: upnpredirect.h,v 1.34 2012/05/01 20:08:23 nanard Exp $ */
|
2011-09-28 19:13:20 +00:00
|
|
|
/* MiniUPnP project
|
|
|
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
2012-04-20 22:09:52 +00:00
|
|
|
* (c) 2006-2012 Thomas Bernard
|
2011-09-28 19:13:20 +00:00
|
|
|
* This software is subject to the conditions detailed
|
|
|
|
* in the LICENCE file provided within the distribution */
|
|
|
|
|
|
|
|
#ifndef __UPNPREDIRECT_H__
|
|
|
|
#define __UPNPREDIRECT_H__
|
|
|
|
|
|
|
|
/* for u_int64_t */
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifdef ENABLE_LEASEFILE
|
|
|
|
int reload_from_lease_file(void);
|
|
|
|
#endif
|
|
|
|
|
2012-03-01 01:44:38 +00:00
|
|
|
/* upnp_redirect()
|
2011-09-28 19:13:20 +00:00
|
|
|
* calls OS/fw dependant implementation of the redirection.
|
|
|
|
* protocol should be the string "TCP" or "UDP"
|
|
|
|
* returns: 0 on success
|
|
|
|
* -1 failed to redirect
|
|
|
|
* -2 already redirected
|
|
|
|
* -3 permission check failed
|
|
|
|
*/
|
|
|
|
int
|
2012-03-01 01:44:38 +00:00
|
|
|
upnp_redirect(const char * rhost, unsigned short eport,
|
2011-09-28 19:13:20 +00:00
|
|
|
const char * iaddr, unsigned short iport,
|
|
|
|
const char * protocol, const char * desc,
|
|
|
|
unsigned int leaseduration);
|
|
|
|
|
|
|
|
/* upnp_redirect_internal()
|
|
|
|
* same as upnp_redirect() without any check */
|
|
|
|
int
|
|
|
|
upnp_redirect_internal(const char * rhost, unsigned short eport,
|
|
|
|
const char * iaddr, unsigned short iport,
|
|
|
|
int proto, const char * desc,
|
|
|
|
unsigned int timestamp);
|
|
|
|
|
|
|
|
/* upnp_get_redirection_infos()
|
|
|
|
* returns : 0 on success
|
|
|
|
* -1 failed to get the port mapping entry or no entry exists */
|
|
|
|
int
|
|
|
|
upnp_get_redirection_infos(unsigned short eport, const char * protocol,
|
|
|
|
unsigned short * iport, char * iaddr, int iaddrlen,
|
|
|
|
char * desc, int desclen,
|
|
|
|
char * rhost, int rhostlen,
|
|
|
|
unsigned int * leaseduration);
|
|
|
|
|
|
|
|
/* upnp_get_redirection_infos_by_index()
|
|
|
|
* returns : 0 on success
|
|
|
|
* -1 failed to get the port mapping or index out of range */
|
|
|
|
int
|
|
|
|
upnp_get_redirection_infos_by_index(int index,
|
|
|
|
unsigned short * eport, char * protocol,
|
2012-03-01 01:44:38 +00:00
|
|
|
unsigned short * iport,
|
2011-09-28 19:13:20 +00:00
|
|
|
char * iaddr, int iaddrlen,
|
|
|
|
char * desc, int desclen,
|
|
|
|
char * rhost, int rhostlen,
|
|
|
|
unsigned int * leaseduration);
|
|
|
|
|
|
|
|
/* upnp_delete_redirection()
|
|
|
|
* returns: 0 on success
|
|
|
|
* -1 on failure*/
|
|
|
|
int
|
|
|
|
upnp_delete_redirection(unsigned short eport, const char * protocol);
|
|
|
|
|
|
|
|
/* _upnp_delete_redir()
|
|
|
|
* same as above */
|
|
|
|
int
|
|
|
|
_upnp_delete_redir(unsigned short eport, int proto);
|
|
|
|
|
|
|
|
/* Periodic cleanup functions
|
|
|
|
*/
|
|
|
|
struct rule_state
|
|
|
|
{
|
|
|
|
u_int64_t packets;
|
|
|
|
u_int64_t bytes;
|
|
|
|
struct rule_state * next;
|
|
|
|
unsigned short eport;
|
|
|
|
unsigned char proto;
|
2012-03-01 01:44:38 +00:00
|
|
|
unsigned char to_remove;
|
2011-09-28 19:13:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* return a linked list of all rules
|
|
|
|
* or an empty list if there are not enough
|
|
|
|
* As a "side effect", delete rules which are expired */
|
|
|
|
struct rule_state *
|
|
|
|
get_upnp_rules_state_list(int max_rules_number_target);
|
|
|
|
|
|
|
|
/* return the number of port mapping entries */
|
|
|
|
int
|
|
|
|
upnp_get_portmapping_number_of_entries(void);
|
|
|
|
|
|
|
|
/* remove_unused_rules() :
|
|
|
|
* also free the list */
|
|
|
|
void
|
|
|
|
remove_unused_rules(struct rule_state * list);
|
|
|
|
|
|
|
|
/* upnp_get_portmappings_in_range()
|
|
|
|
* return a list of all "external" ports for which a port
|
|
|
|
* mapping exists */
|
|
|
|
unsigned short *
|
|
|
|
upnp_get_portmappings_in_range(unsigned short startport,
|
|
|
|
unsigned short endport,
|
|
|
|
const char * protocol,
|
|
|
|
unsigned int * number);
|
|
|
|
|
|
|
|
/* stuff for responding to miniupnpdctl */
|
|
|
|
#ifdef USE_MINIUPNPDCTL
|
|
|
|
void
|
|
|
|
write_ruleset_details(int s);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|