OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2009 University of Pennsylvania |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program 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 this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 */ |
| 18 |
| 19 //include(s) |
| 20 |
| 21 #include "chord-ipv4-helper.h" |
| 22 #include "ns3/chord-ipv4.h" |
| 23 #include "ns3/uinteger.h" |
| 24 #include "ns3/boolean.h" |
| 25 #include "ns3/names.h" |
| 26 |
| 27 namespace ns3 { |
| 28 |
| 29 ChordIpv4Helper::ChordIpv4Helper (Ipv4Address bootStrapIp, uint16_t bootStrapPor
t, Ipv4Address localIpAddress,uint16_t listeningPort, uint16_t applicationPort) |
| 30 { |
| 31 m_factory.SetTypeId (ChordIpv4::GetTypeId ()); |
| 32 SetAttribute ("BootStrapIp", Ipv4AddressValue(bootStrapIp)); |
| 33 SetAttribute ("BootStrapPort", UintegerValue(bootStrapPort)); |
| 34 SetAttribute ("LocalIpAddress", Ipv4AddressValue(localIpAddress)); |
| 35 SetAttribute ("ListeningPort", UintegerValue(listeningPort)); |
| 36 SetAttribute ("ApplicationPort", UintegerValue(applicationPort)); |
| 37 SetAttribute ("DHashEnable", BooleanValue(false)); |
| 38 } //Constructor |
| 39 |
| 40 ChordIpv4Helper::ChordIpv4Helper (Ipv4Address bootStrapIp, uint16_t bootStrapPor
t, Ipv4Address localIpAddress,uint16_t listeningPort, uint16_t applicationPort,
uint16_t dHashPort) |
| 41 { |
| 42 m_factory.SetTypeId (ChordIpv4::GetTypeId ()); |
| 43 SetAttribute ("BootStrapIp", Ipv4AddressValue(bootStrapIp)); |
| 44 SetAttribute ("BootStrapPort", UintegerValue(bootStrapPort)); |
| 45 SetAttribute ("LocalIpAddress", Ipv4AddressValue(localIpAddress)); |
| 46 SetAttribute ("ListeningPort", UintegerValue(listeningPort)); |
| 47 SetAttribute ("ApplicationPort", UintegerValue(applicationPort)); |
| 48 SetAttribute ("DHashPort", UintegerValue(dHashPort)); |
| 49 SetAttribute ("DHashEnable", BooleanValue(true)); |
| 50 } //Constructor· |
| 51 |
| 52 void· |
| 53 ChordIpv4Helper::SetAttribute ( |
| 54 std::string name,· |
| 55 const AttributeValue &value) |
| 56 { |
| 57 m_factory.Set (name, value); |
| 58 } |
| 59 |
| 60 ApplicationContainer |
| 61 ChordIpv4Helper::Install (Ptr<Node> node) const |
| 62 { |
| 63 return ApplicationContainer (InstallPriv (node)); |
| 64 } |
| 65 |
| 66 ApplicationContainer |
| 67 ChordIpv4Helper::Install (std::string nodeName) const |
| 68 { |
| 69 Ptr<Node> node = Names::Find<Node> (nodeName); |
| 70 return ApplicationContainer (InstallPriv (node)); |
| 71 } |
| 72 |
| 73 ApplicationContainer |
| 74 ChordIpv4Helper::Install (NodeContainer c) const |
| 75 { |
| 76 ApplicationContainer apps; |
| 77 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 78 { |
| 79 apps.Add (InstallPriv (*i)); |
| 80 } |
| 81 |
| 82 return apps; |
| 83 } |
| 84 |
| 85 Ptr<Application> |
| 86 ChordIpv4Helper::InstallPriv (Ptr<Node> node) const |
| 87 { |
| 88 Ptr<Application> app = m_factory.Create<ChordIpv4> (); |
| 89 node->AddApplication (app); |
| 90 ·· |
| 91 return app; |
| 92 } |
| 93 |
| 94 /* TODO: Add interface functions to chord running on a node */ |
| 95 |
| 96 } //namespace ns3 |
OLD | NEW |