PageRenderTime 145ms CodeModel.GetById 70ms app.highlight 4ms RepoModel.GetById 67ms app.codeStats 0ms

/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
18#include "portfwd/portfwd.h"
19
20int 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