File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / miniupnpd / upnpredirect.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:55:57 2012 UTC (12 years, 1 month ago) by misho
Branches: miniupnpd, elwix, MAIN
CVS tags: v1_6elwix, HEAD
miniupnpd 1.6+patches

    1: /* $Id: upnpredirect.h,v 1.1.1.2 2012/05/29 12:55:57 misho Exp $ */
    2: /* MiniUPnP project
    3:  * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
    4:  * (c) 2006-2011 Thomas Bernard 
    5:  * This software is subject to the conditions detailed
    6:  * in the LICENCE file provided within the distribution */
    7: 
    8: #ifndef __UPNPREDIRECT_H__
    9: #define __UPNPREDIRECT_H__
   10: 
   11: /* for u_int64_t */
   12: #include <sys/types.h>
   13: 
   14: #include "config.h"
   15: 
   16: #ifdef ENABLE_LEASEFILE
   17: int reload_from_lease_file(void);
   18: #endif
   19: 
   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
   27:  */
   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);
   33: 
   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);
   41: 
   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);
   51: 
   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);
   63: 
   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);
   69: 
   70: /* _upnp_delete_redir()
   71:  * same as above */
   72: int
   73: _upnp_delete_redir(unsigned short eport, int proto);
   74: 
   75: /* Periodic cleanup functions
   76:  */
   77: struct rule_state
   78: {
   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; 
   85: };
   86: 
   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);
   92: 
   93: /* return the number of port mapping entries */
   94: int
   95: upnp_get_portmapping_number_of_entries(void);
   96: 
   97: /* remove_unused_rules() :
   98:  * also free the list */
   99: void
  100: remove_unused_rules(struct rule_state * list);
  101: 
  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);
  110: 
  111: #ifdef ENABLE_6FC_SERVICE
  112: /* function to be used by WANIPv6_FirewallControl implementation */
  113: 
  114: /* retreive outbound pinhole timeout*/
  115: int
  116: upnp_check_outbound_pinhole(int proto, int * timeout);
  117: 
  118: /* add an inbound pinehole
  119:  * return value :
  120:  *  1 = success
  121:  * -1 = Pinhole space exhausted
  122:  * .. = error */
  123: int
  124: upnp_add_inboundpinhole(const char * raddr, unsigned short rport,
  125:               const char * iaddr, unsigned short iport,
  126:               const char * protocol, const char * leaseTime, int * uid);
  127: 
  128: int
  129: upnp_add_inboundpinhole_internal(const char * raddr, unsigned short rport,
  130:                        const char * iaddr, unsigned short iport,
  131:                        const char * proto, int * uid);
  132: 
  133: /*
  134:  * return values :
  135:  *  -4 not found
  136:  *  -5 in another table
  137:  *  -6 in another chain
  138:  *  -7 in a chain but not a rule. (chain policy)
  139:  * */
  140: int
  141: upnp_get_pinhole_info(const char * raddr, unsigned short rport, char * iaddr, unsigned short * iport, char * proto, const char * uid, char * lt);
  142: 
  143: /* update the lease time */
  144: int
  145: upnp_update_inboundpinhole(const char * uid, const char * leasetime);
  146: 
  147: /* remove the inbound pinhole */
  148: int
  149: upnp_delete_inboundpinhole(const char * uid);
  150: 
  151: /* ... */
  152: int
  153: upnp_check_pinhole_working(const char * uid, char * eaddr, char * iaddr, unsigned short * eport, unsigned short * iport, char * protocol, int * rulenum_used);
  154: 
  155: /* number of packets that went through the pinhole */
  156: int
  157: upnp_get_pinhole_packets(const char * uid, int * packets);
  158: 
  159: /* ? */
  160: int
  161: upnp_clean_expiredpinhole(void);
  162: 
  163: #endif /* ENABLE_6FC_SERVICE */
  164: 
  165: /* stuff for responding to miniupnpdctl */
  166: #ifdef USE_MINIUPNPDCTL
  167: void
  168: write_ruleset_details(int s);
  169: #endif
  170: 
  171: #endif
  172: 
  173: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>