An Overlay-based
Virtual Network Substrate
SpoVNet

source: sample/AribaTunnel/Tunnel.h @ 12457

Last change on this file since 12457 was 12457, checked in by hock@…, 9 years ago

added AribaTunnel? to the repo

File size: 3.3 KB
Line 
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2013 Mario Hock mails2013@omnifile.org
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 *
27 */
28
29#ifndef TUNNEL_H
30#define TUNNEL_H
31
32#include <ariba/ariba.h>
33#include "MessageSenderInterface.h"
34
35#include <boost/noncopyable.hpp>
36
37using namespace ariba;
38using boost::property_tree::ptree;
39
40class Tunnel : 
41    private boost::noncopyable,
42    public ariba::NodeListener,
43    public ariba::CommunicationListener,
44    public MessageSenderInterface
45{
46public:
47    Tunnel();
48    virtual ~Tunnel();
49
50    void init_ariba(ptree config);
51   
52    /*
53     * Sends a message via ariba.
54     *
55     * This function is intended to be called from an EXTERNAL THREAD.
56     * --> It synchronizes with the System Qeueue.
57     */
58    virtual void SendMessage(reboost::message_t msg);
59    virtual void SendMessage(reboost::shared_buffer_t msg);
60   
61    void register_udp_sender(MessageSenderInterface* udp_sender);
62
63protected:
64    /* [ariba] communication listener interface */
65    virtual void onMessage(reboost::shared_buffer_t message,
66        const NodeID& remote,
67        const LinkID& lnk,
68        const SequenceNumber& seqnum,
69        const ariba::overlay::OverlayMsg* overlay_msg);
70
71    virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
72    virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
73//     virtual bool onLinkRequest(const NodeID& remote);
74//     virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
75//     virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
76
77    /* [ariba] node listener interface */
78    virtual void onOverlayConnected( const SpoVNetID& vid );
79    virtual void onOverlayDisconnected( const SpoVNetID& vid );
80
81   
82private:
83    /*
84     * Sends a message via ariba.
85     *
86     * This function must be called within the ARIBA THREAD!
87     * It's the counterpart to Tunnel::SendMessage.
88     */
89    void send_message(reboost::message_t msg);
90   
91//     /// XXX this is only for debug output
92//     void print_message(const string& prefix, reboost::message_t msg);
93//     void print_message(const string& prefix, reboost::shared_buffer_t buf);
94
95public:
96    static const ariba::ServiceID TUNNEL_SERVICE_ID;
97   
98private:
99    ariba::Node node;
100    ariba::NodeID tunnel_endpoint;
101    std::vector<LinkID> links;
102    MessageSenderInterface* udp_sender;
103};
104
105#endif // TUNNEL_H
Note: See TracBrowser for help on using the repository browser.