Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 1 | // -*- 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 Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame^] | 26 | NS_LOG_COMPONENT_DEFINE ("CcnxL4Protocol"); |
| 27 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 28 | namespace ns3 { |
| 29 | |
| 30 | NS_OBJECT_ENSURE_REGISTERED (CcnxL4Protocol); |
| 31 | |
| 32 | TypeId |
| 33 | CcnxL4Protocol::GetTypeId (void) |
| 34 | { |
| 35 | static TypeId tid = TypeId ("ns3::CcnxL4Protocol") |
| 36 | .SetParent<Object> () |
| 37 | ; |
| 38 | return tid; |
| 39 | } |
| 40 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame^] | 41 | CcnxL4Protocol::CcnxL4Protocol () |
| 42 | { |
| 43 | NS_LOG_FUNCTION_NOARGS (); |
| 44 | } |
| 45 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 46 | CcnxL4Protocol::~CcnxL4Protocol () |
| 47 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame^] | 48 | NS_LOG_FUNCTION_NOARGS (); |
| 49 | } |
| 50 | |
| 51 | void |
| 52 | CcnxL4Protocol::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 | */ |
| 62 | void |
| 63 | CcnxL4Protocol::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 | |
| 85 | void |
| 86 | CcnxL4Protocol::DoDispose (void) |
| 87 | { |
| 88 | NS_LOG_FUNCTION_NOARGS (); |
| 89 | |
| 90 | m_node = 0; |
| 91 | m_downTarget.Nullify (); |
| 92 | CcnxL4Protocol::DoDispose (); |
| 93 | } |
| 94 | |
| 95 | void |
| 96 | SetDownTarget (DownTargetCallback cb) |
| 97 | { |
| 98 | m_downTarget = cb; |
| 99 | } |
| 100 | |
| 101 | DownTargetCallback |
| 102 | GetDownTarget (void) const |
| 103 | { |
| 104 | retur m_downTarget; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | } //namespace ns3 |