~comnets/openwns-ip/ip--main--1.0

« back to all changes in this revision

Viewing changes to src/tunnel/TunnelEntryComponent.cpp

  • Committer: Maciej Muehleisen
  • Date: 2009-01-12 21:51:19 UTC
  • Revision ID: mue@comnets.rwth-aachen.de-20090112215119-ivapqgbzx580xx5c
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * This file is part of openWNS (open Wireless Network Simulator)
 
3
 * _____________________________________________________________________________
 
4
 *
 
5
 * Copyright (C) 2004-2007
 
6
 * Chair of Communication Networks (ComNets)
 
7
 * Kopernikusstr. 5, D-52074 Aachen, Germany
 
8
 * phone: ++49-241-80-27910,
 
9
 * fax: ++49-241-80-22242
 
10
 * email: info@openwns.org
 
11
 * www: http://www.openwns.org
 
12
 * _____________________________________________________________________________
 
13
 *
 
14
 * openWNS is free software; you can redistribute it and/or modify it under the
 
15
 * terms of the GNU Lesser General Public License version 2 as published by the
 
16
 * Free Software Foundation;
 
17
 *
 
18
 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
 
19
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 
20
 * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 
21
 * details.
 
22
 *
 
23
 * You should have received a copy of the GNU Lesser General Public License
 
24
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
25
 *
 
26
 ******************************************************************************/
 
27
 
 
28
#include <IP/tunnel/TunnelEntryComponent.hpp>
 
29
 
 
30
using namespace ip::tunnel;
 
31
 
 
32
STATIC_FACTORY_REGISTER_WITH_CREATOR(
 
33
        TunnelEntryComponent,
 
34
        wns::node::component::Interface,
 
35
        "ip.tunnelEntry",
 
36
        wns::node::component::ConfigCreator);
 
37
 
 
38
TunnelEntryComponent::TunnelEntryComponent(wns::node::Interface* _node, const wns::pyconfig::View& _pyco) :
 
39
        wns::node::component::Component(_node, _pyco),
 
40
        ipService(NULL),
 
41
        log(_pyco.get("logger"))
 
42
{
 
43
}
 
44
 
 
45
void
 
46
TunnelEntryComponent::doStartup()
 
47
{
 
48
        this->tunnelEntryAddress = wns::service::nl::Address(getConfig().get<std::string>("tunnelEntryAddress"));
 
49
        this->tunnelExitAddress = wns::service::nl::Address(getConfig().get<std::string>("tunnelExitAddress"));
 
50
 
 
51
        // We are a DLL, I got the transmission with me!
 
52
        addService(getConfig().get<std::string>("dataTransmission"), this);
 
53
}
 
54
 
 
55
TunnelEntryComponent::~TunnelEntryComponent()
 
56
{
 
57
}
 
58
 
 
59
void
 
60
TunnelEntryComponent::onNodeCreated()
 
61
{
 
62
        MESSAGE_SINGLE(NORMAL, log, "Retrieving IP service to inject tunneled packets.");
 
63
        std::string ipname = getConfig().get<std::string>("ipService");
 
64
        this->ipService = getService<wns::service::nl::Service*>(ipname);
 
65
        assure(this->ipService, "No IP Service could be found!");
 
66
}
 
67
 
 
68
void
 
69
TunnelEntryComponent::onWorldCreated()
 
70
{
 
71
}
 
72
 
 
73
void
 
74
TunnelEntryComponent::onShutdown()
 
75
{
 
76
}
 
77
 
 
78
void
 
79
TunnelEntryComponent::sendData(const wns::service::dll::UnicastAddress&,
 
80
                                                           const wns::osi::PDUPtr& data,
 
81
                                                           wns::service::dll::protocolNumber)
 
82
{
 
83
        MESSAGE_SINGLE(NORMAL, log, "Tunneling a packet.");
 
84
        assure(this->ipService, "No IP Service could be found!");
 
85
        this->ipService->sendData(this->tunnelEntryAddress, this->tunnelExitAddress, data, wns::service::nl::IP);
 
86
}
 
87
 
 
88
wns::service::dll::UnicastAddress
 
89
TunnelEntryComponent::getMACAddress() const
 
90
{
 
91
        MESSAGE_SINGLE(NORMAL, log, "getMACAddress called");
 
92
        return wns::service::dll::UnicastAddress();
 
93
}