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