source: source/ariba/tidy/AribaModule.cpp@ 2378

Last change on this file since 2378 was 2378, checked in by Christoph Mayer, 15 years ago

Renamed remotely

File size: 4.8 KB
Line 
1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#include "AribaModule.h"
40
41// boost/std includes
42#include <assert.h>
43#include <boost/regex.hpp>
44
45// ariba includes
46#include "ariba/utility/misc/Helper.h"
47
48// hack includes
49#include "ariba/interface/UnderlayAbstraction.h"
50#include "ariba/communication/EndpointDescriptor.h"
51#include "ariba/communication/modules/network/NetworkLocator.h"
52
53using namespace ariba::utility::Helper;
54using ariba::interface::UnderlayAbstraction;
55
56namespace ariba {
57
58AribaModule::AribaModule() {
59
60 // init with default values
61 this->underlay_abs = NULL;
62 this->ip_addr = NULL;
63 this->tcp_port = 41402;
64 this->udp_port = 41402;
65 this->started = false;
66}
67
68AribaModule::~AribaModule() {
69}
70
71SpoVNetID AribaModule::getSpoVNetId(const char* name, int len) const {
72 return SpoVNetID::UNSPECIFIED;
73}
74
75string AribaModule::getBootstrapHints(const Name& spoVNetName) const {
76
77}
78
79void AribaModule::addBootstrapHints(string boot_info) {
80 string str = boot_info;
81 static ::boost::regex boot_expr("<([^>:]+)[:]?([0-9]+)?>([^<]+)(.*)");
82 ::boost::smatch what;
83 while (::boost::regex_match(str, what, boot_expr)) {
84 std::cout << what[1].str() << ":" << what[2].str() << "=" << what[3]
85 << std::endl;
86 str = what[4].str();
87 }
88}
89
90void AribaModule::addBootstrapNode(const Name& spovnet, const Name& node,
91 communication::EndpointDescriptor* desc) {
92
93}
94
95const communication::EndpointDescriptor* AribaModule::getBootstrapNode(
96 const Name& spovnet) {
97 return NULL;
98}
99
100// @see Module.h
101void AribaModule::initialize() {
102
103 // preconditions
104 assert(!started);
105
106 // init variables
107 underlay_abs = NULL;
108}
109
110// @see Module.h
111void AribaModule::start() {
112
113 // preconditions
114 assert(underlay_abs == NULL);
115 assert(!started);
116
117 // create the base communication component
118 started = true;
119 underlay_abs = new interface::UnderlayAbstraction();
120}
121
122// @see Module.h
123void AribaModule::stop() {
124
125 // preconditions
126 assert(underlay_abs != NULL);
127 assert(started);
128
129 // delete base communication component
130 started = false;
131 delete underlay_abs;
132}
133
134// @see Module.h
135string AribaModule::getName() const {
136 return "ariba";
137}
138
139// @see Module.h
140void AribaModule::setProperty(string key, string value) {
141 if (key == "ip.addr") {
142 if (ip_addr != NULL) delete ip_addr;
143 communication::IPv4Locator* loc = new communication::IPv4Locator();
144 *loc = communication::IPv4Locator::fromString(value);
145 ip_addr = loc;
146 } else if (key == "tcp.port") tcp_port = stoi(value);
147 else if (key == "udp.port") udp_port = stoi(value);
148 else if (key == "bootstrap.hints") addBootstrapHints(value);
149}
150
151// @see Module.h
152const string AribaModule::getProperty(string key) const {
153 if (key == "ip.addr") return ip_addr->toString();
154 else if (key == "tcp.port") return ultos(tcp_port);
155 else if (key == "udp.port") return ultos(udp_port);
156 else if (key == "bootstrap.hints") return getBootstrapHints();
157}
158
159// @see Module.h
160const vector<string> AribaModule::getProperties() const {
161 vector<string> properties;
162 properties.push_back("ip.addr");
163 properties.push_back("tcp.port");
164 properties.push_back("udp.port");
165 properties.push_back("hints");
166 return properties;
167}
168
169} // namespace ariba
Note: See TracBrowser for help on using the repository browser.