~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to thirdparty/libportfwd/src/main.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

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