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) 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 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 20 | */ |
| 21 | |
| 22 | ///< #CCN_PR_SCOPE0 (0x20) local scope, |
| 23 | ///< #CCN_PR_SCOPE1 (0x40) this host, |
| 24 | ///< #CCN_PR_SCOPE2 (0x80) immediate neighborhood |
| 25 | |
| 26 | #include "ccnx-interest-header.h" |
| 27 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 28 | #include "ns3/log.h" |
| 29 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 30 | NS_LOG_COMPONENT_DEFINE ("CcnxInterestHeader"); |
| 31 | |
| 32 | namespace ns3 |
| 33 | { |
| 34 | |
| 35 | NS_OBJECT_ENSURE_REGISTERED (CcnxInterestHeader); |
| 36 | |
| 37 | TypeId |
| 38 | CcnxInterestHeader::GetTypeId (void) |
| 39 | { |
| 40 | static TypeId tid = TypeId ("ns3::CcnxInterestHeader") |
| 41 | .SetParent<Header> () |
| 42 | .AddConstructor<CcnxInterestHeader> () |
| 43 | ; |
| 44 | return tid; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | CcnxInterestHeader::CcnxInterestHeader () |
| 49 | : m_minSuffixComponents (-1) |
| 50 | , m_maxSuffixComponents (-1) |
| 51 | , m_childSelector (false) |
| 52 | , m_answerOriginKind (false) |
| 53 | , m_scope (-1) |
| 54 | , m_interestLifetime (-1) |
| 55 | , m_nonce (0) |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | CcnxInterestHeader::SetName (const Ptr<Name::Components> &name) |
| 61 | { |
| 62 | m_name = name; |
| 63 | } |
| 64 | |
| 65 | const Name::Components& |
| 66 | CcnxInterestHeader::GetName () const |
| 67 | { |
| 68 | return *m_name; |
| 69 | } |
| 70 | |
| 71 | void |
| 72 | CcnxInterestHeader::SetMinSuffixComponents (int32_t value) |
| 73 | { |
| 74 | m_minSuffixComponents = value; |
| 75 | } |
| 76 | |
| 77 | int32_t |
| 78 | CcnxInterestHeader::GetMinSuffixComponents () const |
| 79 | { |
| 80 | return m_minSuffixComponents; |
| 81 | } |
| 82 | |
| 83 | void |
| 84 | CcnxInterestHeader::SetMaxSuffixComponents (int32_t value) |
| 85 | { |
| 86 | m_maxSuffixComponents = value; |
| 87 | } |
| 88 | |
| 89 | int32_t |
| 90 | CcnxInterestHeader::GetMaxSuffixComponents () const |
| 91 | { |
| 92 | return m_maxSuffixComponents; |
| 93 | } |
| 94 | |
| 95 | void |
| 96 | CcnxInterestHeader::SetExclude (const Ptr<Name::Components> &exclude) |
| 97 | { |
| 98 | m_exclude = exclude; |
| 99 | } |
| 100 | |
| 101 | const Name::Components& |
| 102 | CcnxInterestHeader::GetExclude () const |
| 103 | { |
| 104 | return *m_exclude; |
| 105 | } |
| 106 | |
| 107 | void |
| 108 | CcnxInterestHeader::EnableChildSelector () |
| 109 | { |
| 110 | m_childSelector = true; |
| 111 | } |
| 112 | |
| 113 | bool |
| 114 | CcnxInterestHeader::IsEnabledChildSelector () const |
| 115 | { |
| 116 | return m_childSelector; |
| 117 | } |
| 118 | |
| 119 | void |
| 120 | CcnxInterestHeader::EnableAnswerOriginKind () |
| 121 | { |
| 122 | m_answerOriginKind = true; |
| 123 | } |
| 124 | |
| 125 | bool |
| 126 | CcnxInterestHeader::IsEnabledAnswerOriginKind () const |
| 127 | { |
| 128 | return m_answerOriginKind; |
| 129 | } |
| 130 | |
| 131 | void |
| 132 | CcnxInterestHeader::SetScope (int8_t scope) |
| 133 | { |
| 134 | m_scope = scope; |
| 135 | } |
| 136 | |
| 137 | int8_t |
| 138 | CcnxInterestHeader::GetScope () const |
| 139 | { |
| 140 | return m_scope; |
| 141 | } |
| 142 | |
| 143 | void |
| 144 | CcnxInterestHeader::SetInterestLifetime (intmax_t lifetime) |
| 145 | { |
| 146 | m_interestLifetime = lifetime; |
| 147 | } |
| 148 | |
| 149 | intmax_t |
| 150 | CcnxInterestHeader::GetInterestLifetime () const |
| 151 | { |
| 152 | return m_interestLifetime; |
| 153 | } |
| 154 | |
| 155 | void |
| 156 | CcnxInterestHeader::SetNonce (uint32_t nonce) |
| 157 | { |
| 158 | m_nonce = nonce; |
| 159 | } |
| 160 | |
| 161 | uint32_t |
| 162 | CcnxInterestHeader::GetNonce () const |
| 163 | { |
| 164 | return m_nonce; |
| 165 | } |
| 166 | |
| 167 | uint32_t |
| 168 | CcnxInterestHeader::GetSerializedSize (void) const |
| 169 | { |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | void |
| 174 | CcnxInterestHeader::Serialize (Buffer::Iterator start) const |
| 175 | { |
| 176 | return; |
| 177 | } |
| 178 | |
| 179 | uint32_t |
| 180 | CcnxInterestHeader::Deserialize (Buffer::Iterator start) |
| 181 | { |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | TypeId |
| 186 | CcnxInterestHeader::GetInstanceTypeId (void) const |
| 187 | { |
| 188 | return GetTypeId (); |
| 189 | } |
| 190 | |
| 191 | void |
| 192 | CcnxInterestHeader::Print (std::ostream &os) const |
| 193 | { |
| 194 | os << "Interest: " << *m_name; |
| 195 | } |
| 196 | |
| 197 | } |