blob: 9cdd0a18a92f5c642580fa4e464c4206fb7020a5 [file] [log] [blame]
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07001// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
2//
3// Copyright (c) 2006 Georgia Tech Research Corporation
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:
19//
20
21
22#include "ccnx-l4-protocol.h"
23
24#include "ns3/uinteger.h"
25
Alexander Afanasyev98256102011-08-14 01:00:02 -070026NS_LOG_COMPONENT_DEFINE ("CcnxL4Protocol");
27
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070028namespace ns3 {
29
30NS_OBJECT_ENSURE_REGISTERED (CcnxL4Protocol);
31
32TypeId
33CcnxL4Protocol::GetTypeId (void)
34{
35 static TypeId tid = TypeId ("ns3::CcnxL4Protocol")
36 .SetParent<Object> ()
37 ;
38 return tid;
39}
40
Alexander Afanasyev98256102011-08-14 01:00:02 -070041CcnxL4Protocol::CcnxL4Protocol ()
42{
43 NS_LOG_FUNCTION_NOARGS ();
44}
45
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070046CcnxL4Protocol::~CcnxL4Protocol ()
47{
Alexander Afanasyev98256102011-08-14 01:00:02 -070048 NS_LOG_FUNCTION_NOARGS ();
49}
50
51void
52CcnxL4Protocol::SetNode (Ptr<Node> node)
53{
54 m_node = node;
55}
56
57/*
58 * This method is called by AddAgregate and completes the aggregation
59 * by setting the node in the udp stack and link it to the ipv4 object
60 * present in the node along with the socket factory
61 */
62void
63CcnxL4Protocol::NotifyNewAggregate ()
64{
65 if (m_node == 0)
66 {
67 Ptr<Node> node = this->GetObject<Node> ();
68 if (node != 0)
69 {
70 Ptr<Ccnx> ccnx = this->GetObject<Ccnx> ();
71 if (ccnx != 0)
72 {
73 this->SetNode (node);
74 ccnx->Insert (this);
75 // Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
76 // udpFactory->SetUdp (this);
77 // node->AggregateObject (udpFactory);
78 this->SetDownTarget (MakeCallback (&Ccnx::Send, ccnx));
79 }
80 }
81 }
82 Object::NotifyNewAggregate ();
83}
84
85void
86CcnxL4Protocol::DoDispose (void)
87{
88 NS_LOG_FUNCTION_NOARGS ();
89
90 m_node = 0;
91 m_downTarget.Nullify ();
92 CcnxL4Protocol::DoDispose ();
93}
94
95void
96SetDownTarget (DownTargetCallback cb)
97{
98 m_downTarget = cb;
99}
100
101DownTargetCallback
102GetDownTarget (void) const
103{
104 retur m_downTarget;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700105}
106
107} //namespace ns3