blob: c1822076133b70547e58b2d02415ebdc6cf3e8c7 [file] [log] [blame]
Ilya Moiseenko171afe12011-08-23 16:02:16 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
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 * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
19 */
20
21#include "ccnx-interest-sender-helper.h"
22#include "ns3/inet-socket-address.h"
23#include "ns3/packet-socket-address.h"
24#include "ns3/string.h"
25#include "ns3/names.h"
26
27namespace ns3
28{
29
30CcnxInterestSenderHelper::CcnxInterestSenderHelper (Ptr<CcnxNameComponents> interestName)
31{
32 m_factory.SetTypeId ("ns3::CcnxInterestSender");
33 m_factory.Set ("InterestName", PointerValue (interestName));
34}
35
36void
37CcnxInterestSenderHelper::SetAttribute (std::string name, const AttributeValue &value)
38{
39 m_factory.Set (name, value);
40}
41
42ApplicationContainer
Ilya Moiseenko946b87b2011-08-23 17:37:54 -070043CcnxInterestSenderHelper::Install (Ptr<Node> node)
Ilya Moiseenko171afe12011-08-23 16:02:16 -070044{
45 return ApplicationContainer (InstallPriv (node));
46}
47
48ApplicationContainer
Ilya Moiseenko946b87b2011-08-23 17:37:54 -070049CcnxInterestSenderHelper::Install (std::string nodeName)
Ilya Moiseenko171afe12011-08-23 16:02:16 -070050{
51 Ptr<Node> node = Names::Find<Node> (nodeName);
52 return ApplicationContainer (InstallPriv (node));
53}
54
55ApplicationContainer
Ilya Moiseenko946b87b2011-08-23 17:37:54 -070056CcnxInterestSenderHelper::Install (NodeContainer c)
Ilya Moiseenko171afe12011-08-23 16:02:16 -070057{
58 ApplicationContainer apps;
59 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
60 {
61 apps.Add (InstallPriv (*i));
62 }
63
64 return apps;
65}
66
67Ptr<Application>
Ilya Moiseenko946b87b2011-08-23 17:37:54 -070068CcnxInterestSenderHelper::InstallPriv (Ptr<Node> node)
Ilya Moiseenko171afe12011-08-23 16:02:16 -070069{
Ilya Moiseenko946b87b2011-08-23 17:37:54 -070070 Ptr<CcnxLocalFace> localFace = Create<CcnxLocalFace> ();
71 localFace->SetNode(node);
72 localFace->SetUp();
73 m_factory.Set ("Face", PointerValue (localFace));
74
Ilya Moiseenko171afe12011-08-23 16:02:16 -070075 Ptr<Application> app = m_factory.Create<Application> ();
76 node->AddApplication (app);
77
78 return app;
79}
80}