/usr/include/ns3.17/ns3/ndisc-cache.h is in libns3-dev 3.17+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007-2009 Strasbourg University
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
*/
#ifndef NDISC_CACHE_H
#define NDISC_CACHE_H
#include <stdint.h>
#include <list>
#include "ns3/packet.h"
#include "ns3/nstime.h"
#include "ns3/net-device.h"
#include "ns3/ipv6-address.h"
#include "ns3/ptr.h"
#include "ns3/timer.h"
#include "ns3/sgi-hashmap.h"
namespace ns3
{
class NetDevice;
class Ipv6Interface;
/**
* \class NdiscCache
* \brief IPv6 Neighbor Discovery cache.
*/
class NdiscCache : public Object
{
public:
class Entry;
/**
* \brief Get the type ID
* \return type ID
*/
static TypeId GetTypeId ();
/**
* \brief Default value for unres qlen.
*/
static const uint32_t DEFAULT_UNRES_QLEN = 3;
/**
* \brief Constructor.
*/
NdiscCache ();
/**
* \brief Destructor.
*/
~NdiscCache ();
/**
* \brief Get the NetDevice associated with this cache.
* \return NetDevice
*/
Ptr<NetDevice> GetDevice () const;
/**
* \brief Get the Ipv6Interface associated with this cache.
*/
Ptr<Ipv6Interface> GetInterface () const;
/**
* \brief Lookup in the cache.
* \param dst destination address
* \return the entry if found, 0 otherwise
*/
NdiscCache::Entry* Lookup (Ipv6Address dst);
/**
* \brief Add an entry.
* \param to address to add
* \return an new Entry
*/
NdiscCache::Entry* Add (Ipv6Address to);
/**
* \brief Delete an entry.
* \param entry pointer to delete from the list.
*/
void Remove (NdiscCache::Entry* entry);
/**
* \brief Flush the cache.
*/
void Flush ();
/**
* \brief Set the max number of waiting packet.
* \param unresQlen value to set
*/
void SetUnresQlen (uint32_t unresQlen);
/**
* \brief Get the max number of waiting packet.
* \return max number
*/
uint32_t GetUnresQlen ();
/**
* \brief Set the device and interface.
* \param device the device
* \param interface the IPv6 interface
*/
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
/**
* \class Entry
* \brief A record that holds information about an NdiscCache entry.
*/
class Entry
{
public:
/**
* \brief Constructor.
* \param nd The NdiscCache this entry belongs to.
*/
Entry (NdiscCache* nd);
/**
* \brief Changes the state to this entry to INCOMPLETE.
* \param p packet that wait to be sent
*/
void MarkIncomplete (Ptr<Packet> p);
/**
* \brief Changes the state to this entry to REACHABLE.
* \param mac MAC address
* \return the list of packet waiting
*/
std::list<Ptr<Packet> > MarkReachable (Address mac);
/**
* \brief Changes the state to this entry to PROBE.
*/
void MarkProbe ();
/**
* \brief Changes the state to this entry to STALE.
* \param mac L2 address
* \return the list of packet waiting
*/
std::list<Ptr<Packet> > MarkStale (Address mac);
/**
* \brief Changes the state to this entry to STALE.
*/
void MarkStale ();
/**
* \brief Changes the state to this entry to REACHABLE.
*/
void MarkReachable ();
/**
* \brief Change the state to this entry to DELAY.
*/
void MarkDelay ();
/**
* \brief Add a packet (or replace old value) in the queue.
* \param p packet to add
*/
void AddWaitingPacket (Ptr<Packet> p);
/**
* \brief Clear the waiting packet list.
*/
void ClearWaitingPacket ();
/**
* \brief Is the entry STALE
* \return true if the entry is in STALE state, false otherwise
*/
bool IsStale () const;
/**
* \brief Is the entry REACHABLE
* \return true if the entry is in REACHABLE state, false otherwise
*/
bool IsReachable () const;
/**
* \brief Is the entry DELAY
* \return true if the entry is in DELAY state, false otherwise
*/
bool IsDelay () const;
/**
* \brief Is the entry INCOMPLETE
* \return true if the entry is in INCOMPLETE state, false otherwise
*/
bool IsIncomplete () const;
/**
* \brief Is the entry PROBE
* \return true if the entry is in PROBE state, false otherwise
*/
bool IsProbe () const;
/**
* \brief Get the MAC address of this entry.
* \return the L2 address
*/
Address GetMacAddress () const;
/**
* \brief Set the MAC address of this entry.
* \param mac the MAC address to set
*/
void SetMacAddress (Address mac);
/**
* \brief If the entry is a host or a router.
* \return true if the node is a router, 0 if it is a host
*/
bool IsRouter () const;
/**
* \brief Set the node type.
* \param router true is a router, false means a host
*/
void SetRouter (bool router);
/**
* \brief Get the number of NS retransmit.
* \return number of NS that have been retransmit
*/
uint8_t GetNSRetransmit () const;
/**
* \brief Increment NS retransmit.
*/
void IncNSRetransmit ();
/**
* \brief Reset NS retransmit (=0).
*/
void ResetNSRetransmit ();
/**
* \brief Get the time of last reachability confirmation.
* \return time
*/
Time GetLastReachabilityConfirmation () const;
/**
* \brief Update the time of last reachability confirmation.
*/
void UpdateLastReachabilityconfirmation ();
/**
* \brief Start the reachable timer.
*/
void StartReachableTimer ();
/**
* \brief Stop the reachable timer.
*/
void StopReachableTimer ();
/**
* \brief Start retransmit timer.
*/
void StartRetransmitTimer ();
/**
* \brief Stop retransmit timer.
*/
void StopRetransmitTimer ();
/**
* \brief Start probe timer.
*/
void StartProbeTimer ();
/**
* \brief Stop probe timer.
*/
void StopProbeTimer ();
/**
* \brief Start delay timer.
*/
void StartDelayTimer ();
/**
* \brief Stop delay timer.
*/
void StopDelayTimer ();
/**
* \brief Function called when reachable timer timeout.
*/
void FunctionReachableTimeout ();
/**
* \brief Function called when retransmit timer timeout.
* It verify that the NS retransmit has reached the max so discard the entry
* otherwise it retransmit a NS.
*/
void FunctionRetransmitTimeout ();
/**
* \brief Function called when probe timer timeout.
*/
void FunctionProbeTimeout ();
/**
* \brief Function called when delay timer timeout.
*/
void FunctionDelayTimeout ();
/**
* \brief Set the IPv6 address.
* \param ipv6Address IPv6 address
*/
void SetIpv6Address (Ipv6Address ipv6Address);
private:
/**
* \brief The IPv6 address.
*/
Ipv6Address m_ipv6Address;
/**
* \brief The Entry state enumeration.
*/
enum NdiscCacheEntryState_e
{
INCOMPLETE, /**< No mapping between IPv6 and L2 addresses */
REACHABLE, /**< Mapping exists between IPv6 and L2 addresses */
STALE, /**< Mapping is stale */
DELAY, /**< Try to wait contact from remote host */
PROBE /**< Try to contact IPv6 address to know again its L2 address */
};
/**
* \brief The state of the entry.
*/
NdiscCacheEntryState_e m_state;
/**
* \brief the NdiscCache associated.
*/
NdiscCache* m_ndCache;
/**
* \brief The MAC address.
*/
Address m_macAddress;
/**
* \brief The list of packet waiting.
*/
std::list<Ptr<Packet> > m_waiting;
/**
* \brief Type of node (router or host).
*/
bool m_router;
/**
* \brief Reachable timer (used for NUD in REACHABLE state).
*/
Timer m_reachableTimer;
/**
* \brief Retransmission timer (used for NUD in INCOMPLETE state).
*/
Timer m_retransTimer;
/**
* \brief Probe timer (used for NUD in PROBE state).
*/
Timer m_probeTimer;
/**
* \brief Delay timer (used for NUD when in DELAY state).
*/
Timer m_delayTimer;
/**
* \brief Last time we see a reachability confirmation.
*/
Time m_lastReachabilityConfirmation;
/**
* \brief Number of NS retransmission.
*/
uint8_t m_nsRetransmit;
};
private:
typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash> Cache;
typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator CacheI;
/**
* \brief Copy constructor.
* \param a cache to copy
*/
NdiscCache (NdiscCache const &a);
/**
* \brief Equal operator.
* \param a cache to copy
*/
NdiscCache& operator= (NdiscCache const &a);
/**
* \brief Dispose this object.
*/
void DoDispose ();
/**
* \brief The NetDevice.
*/
Ptr<NetDevice> m_device;
/**
* \brief the interface.
*/
Ptr<Ipv6Interface> m_interface;
/**
* \brief A list of Entry.
*/
Cache m_ndCache;
/**
* \brief Max number of packet stored in m_waiting.
*/
uint32_t m_unresQlen;
};
} /* namespace ns3 */
#endif /* NDISC_CACHE_H */
|