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