/thirdparty/libportfwd/src/main.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 48 lines · 26 code · 6 blank · 16 comment · 2 complexity · 3fd28a4fdd5174c49b629d87b0439be1 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. #include "portfwd/portfwd.h"
  18. int main(int argc, char** argv)
  19. {
  20. if(argc!=2)
  21. {
  22. printf("Usage: %s <port>\n", argv[0]);
  23. return 1;
  24. }
  25. int port = atoi(argv[1]);
  26. Portfwd pf;
  27. if(!pf.init(2000))
  28. {
  29. printf("Portfwd.init() failed.\n");
  30. return 2;
  31. }
  32. printf("External IP: %s\n", pf.external_ip().c_str());
  33. printf("LAN IP: %s\n", pf.lan_ip().c_str());
  34. printf("Max upstream: %d bps, max downstream: %d bps\n",
  35. pf.max_upstream_bps(), pf.max_downstream_bps() );
  36. printf("%s\n", ((pf.add( port ))?"Added":"Failed to add") );
  37. printf("Any key to exit...\n");
  38. char foo;
  39. scanf("%c",&foo);
  40. printf("%s\n", ((pf.remove( port ))?"Removed.":"Failed to remove") );
  41. return 0;
  42. }