/thirdparty/libportfwd/include/portfwd/portfwd.h

http://github.com/tomahawk-player/tomahawk · C Header · 63 lines · 33 code · 12 blank · 18 comment · 0 complexity · 4e086c0b508bdd1ae1731bfaf832f52f MD5 · raw file

  1. /*
  2. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  3. *
  4. * Tomahawk is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * Tomahawk is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef LIBPORTFWD_PORTFWD_H
  18. #define LIBPORTFWD_PORTFWD_H
  19. #include "portfwddllmacro.h"
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <cstdio>
  24. #include <list>
  25. #include <iostream>
  26. struct UPNPUrls;
  27. struct IGDdatas;
  28. class PORTFWDDLLEXPORT Portfwd
  29. {
  30. public:
  31. Portfwd();
  32. ~Portfwd();
  33. /// timeout: milliseconds to wait for a router to respond
  34. /// 2000 is typically enough.
  35. bool init( unsigned int timeout );
  36. void get_status();
  37. bool add( unsigned short port, unsigned short internal_port );
  38. bool remove( unsigned short port );
  39. void addBlockedDevice( const std::string& ip );
  40. const std::string& external_ip() const { return m_externalip; }
  41. const std::string& lan_ip() const { return m_lanip; }
  42. unsigned int max_upstream_bps() const { return m_upbps; }
  43. unsigned int max_downstream_bps() const { return m_downbps; }
  44. protected:
  45. struct UPNPUrls* m_urls;
  46. struct IGDdatas* m_data;
  47. std::list<std::string> m_blockedips;
  48. std::string m_lanip, m_externalip;
  49. unsigned int m_upbps, m_downbps;
  50. };
  51. #endif