PageRenderTime 71ms CodeModel.GetById 41ms app.highlight 3ms RepoModel.GetById 17ms app.codeStats 1ms

/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
18#ifndef LIBPORTFWD_PORTFWD_H
19#define LIBPORTFWD_PORTFWD_H
20
21#include "portfwddllmacro.h"
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <cstdio>
27#include <list>
28#include <iostream>
29
30struct UPNPUrls;
31struct IGDdatas;
32
33class PORTFWDDLLEXPORT Portfwd
34{
35    public:
36        Portfwd();
37        ~Portfwd();
38
39        /// timeout: milliseconds to wait for a router to respond
40        /// 2000 is typically enough.
41        bool init( unsigned int timeout );
42        void get_status();
43
44        bool add( unsigned short port, unsigned short internal_port );
45        bool remove( unsigned short port );
46
47        void addBlockedDevice( const std::string& ip );
48
49        const std::string& external_ip() const { return m_externalip; }
50        const std::string& lan_ip() const { return m_lanip; }
51        unsigned int max_upstream_bps() const { return m_upbps; }
52        unsigned int max_downstream_bps() const { return m_downbps; }
53
54    protected:
55        struct UPNPUrls* m_urls;
56        struct IGDdatas* m_data;
57
58        std::list<std::string> m_blockedips;
59        std::string m_lanip, m_externalip;
60        unsigned int m_upbps, m_downbps;
61};
62
63#endif