This file is indexed.

/usr/include/ns3.26/ns3/ipv6-address.h is in libns3-dev 3.26+dfsg-1.

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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2007-2008 Louis Pasteur 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 IPV6_ADDRESS_H
#define IPV6_ADDRESS_H

#include <stdint.h>
#include <cstring>

#include <ostream>

#include "ns3/attribute-helper.h"
#include "ns3/address.h"
#include "ns3/ipv4-address.h"
#include "ns3/deprecated.h"

namespace ns3 { 

class Ipv6Prefix;
class Mac16Address;
class Mac48Address;
class Mac64Address;

/**
 * \ingroup address
 * \class Ipv6Address
 * \brief Describes an IPv6 address.
 * \see Ipv6Prefix
 * \see attribute_Ipv6Address
 */
class Ipv6Address
{
public:
  /**
   * \brief Default constructor.
   */
  Ipv6Address ();

  /**
   * \brief Constructs an Ipv6Address by parsing the input C-string.
   * \param address the C-string containing the IPv6 address (e.g. 2001:660:4701::1).
   */
  Ipv6Address (char const* address);

  /**
   * \brief Constructs an Ipv6Address by using the input 16 bytes.
   * \param address the 128-bit address
   * \warning the parameter must point on a 16 bytes integer array!
   */
  Ipv6Address (uint8_t address[16]);

  /**
   * \brief Copy constructor.
   * \param addr Ipv6Address object
   */
  Ipv6Address (Ipv6Address const & addr);

  /**
   * \brief Copy constructor.
   * \param addr Ipv6Address pointer
   */
  Ipv6Address (Ipv6Address const* addr);

  /**
   * \brief Destructor.
   */
  ~Ipv6Address ();

  /**
   * \brief Sets an Ipv6Address by parsing the input C-string.
   * \param address the C-string containing the IPv6 address (e.g. 2001:660:4701::1).
   */
  void Set (char const* address);

  /**
   * \brief Set an Ipv6Address by using the input 16 bytes.
   *
   * \param address the 128-bit address
   * \warning the parameter must point on a 16 bytes integer array!
   */
  void Set (uint8_t address[16]);

  /**
   * \brief Comparison operation between two Ipv6Addresses.
   *
   * \param other the IPv6 address to which to compare thisaddress
   * \return true if the addresses are equal, false otherwise
   */
  bool IsEqual (const Ipv6Address& other) const;

  /**
   * \brief Serialize this address to a 16-byte buffer.
   * \param buf the output buffer to which this address gets overwritten with this
   * Ipv6Address
   */
  void Serialize (uint8_t buf[16]) const;

  /**
   * \brief Deserialize this address.
   * \param buf buffer to read address from
   * \return an Ipv6Address
   */
  static Ipv6Address Deserialize (const uint8_t buf[16]);

  /**
   * \brief Make the solicited IPv6 address.
   * \param addr the IPv6 address
   * \return Solicited IPv6 address
   */
  static Ipv6Address MakeSolicitedAddress (Ipv6Address addr);

  /**
   * \brief Make the Ipv4-mapped IPv6 address.
   * \param addr the IPv4 address
   * \return Ipv4-mapped IPv6 address
   */
  static Ipv6Address MakeIpv4MappedAddress (Ipv4Address addr);

  /**
   * \brief Return the Ipv4 address.
   * \return Ipv4 address
   */
  Ipv4Address GetIpv4MappedAddress () const;

  /**
   * \brief Make the autoconfigured IPv6 address with Mac16Address.
   * \param addr the MAC address (16 bits).
   * \param prefix the IPv6 prefix
   * \return autoconfigured IPv6 address
   */
  static Ipv6Address MakeAutoconfiguredAddress (Mac16Address addr, Ipv6Address prefix);

  /**
   * \brief Make the autoconfigured IPv6 address with Mac48Address.
   * \param addr the MAC address (48 bits).
   * \param prefix the IPv6 prefix
   * \return autoconfigured IPv6 address
   */
  static Ipv6Address MakeAutoconfiguredAddress (Mac48Address addr, Ipv6Address prefix);

  /**
   * \brief Make the autoconfigured IPv6 address with Mac48Address.
   * \param addr the MAC address (64 bits).
   * \param prefix the IPv6 prefix
   * \return autoconfigured IPv6 address
   */
  static Ipv6Address MakeAutoconfiguredAddress (Mac64Address addr, Ipv6Address prefix);

  /**
   * \brief Make the autoconfigured link-local IPv6 address with Mac16Address.
   * \param mac the MAC address (16 bits).
   * \return autoconfigured link-local IPv6 address
   */
  static Ipv6Address MakeAutoconfiguredLinkLocalAddress (Mac16Address mac);

  /**
   * \brief Make the autoconfigured link-local IPv6 address with Mac48Address.
   * \param mac the MAC address (48 bits).
   * \return autoconfigured link-local IPv6 address
   */
  static Ipv6Address MakeAutoconfiguredLinkLocalAddress (Mac48Address mac);

  /**
   * \brief Make the autoconfigured link-local IPv6 address with Mac48Address.
   * \param mac the MAC address (64 bits).
   * \return autoconfigured link-local IPv6 address
   */
  static Ipv6Address MakeAutoconfiguredLinkLocalAddress (Mac64Address mac);

  /**
   * \brief Print this address to the given output stream.
   *
   * The print format is in the typical "2001:660:4701::1".
   * \param os the output stream to which this Ipv6Address is printed
   */
  void Print (std::ostream& os) const;

  /**
   * \brief If the IPv6 address is localhost (::1).
   * \return true if localhost, false otherwise
   */
  bool IsLocalhost () const;

  /**
   * \brief If the IPv6 address is multicast (ff00::/8).
   * \return true if multicast, false otherwise
   */
  bool IsMulticast () const;

  /**
   * \brief If the IPv6 address is link-local multicast (ff02::/16).
   * \return true if link-local multicast, false otherwise
   */
  bool IsLinkLocalMulticast () const;

  /**
   * \brief If the IPv6 address is "all nodes multicast" (ff02::1/8).
   * \return true if "all nodes multicast", false otherwise
   */
  bool IsAllNodesMulticast () const;

  /**
   * \brief If the IPv6 address is "all routers multicast" (ff02::2/8).
   * \return true if "all routers multicast", false otherwise
   */
  bool IsAllRoutersMulticast () const;

  /**
   * \brief If the IPv6 address is "all hosts multicast" (ff02::3/8).
   *
   * \deprecated This function is deprecated because the address has been removed from RFCs.
   *
   * \return true if "all hosts multicast", false otherwise
   */
  NS_DEPRECATED
  bool IsAllHostsMulticast () const;

  /**
   * \brief If the IPv6 address is a link-local address (fe80::/64).
   * \return true if the address is link-local, false otherwise
   */
  bool IsLinkLocal () const;

  /**
   * \brief If the IPv6 address is a Solicited multicast address.
   * \return true if it is, false otherwise
   */
  bool IsSolicitedMulticast () const;

  /**
   * \brief If the IPv6 address is the "Any" address.
   * \return true if it is, false otherwise
   */
  bool IsAny () const;

  /**
   * \brief If the IPv6 address is a documentation address (2001:DB8::/32).
   * \return true if the address is documentation, false otherwise
   */
  bool IsDocumentation () const;

  /**
   * \brief Combine this address with a prefix.
   * \param prefix a IPv6 prefix
   * \return an IPv6 address that is this address combined
   * (bitwise AND) with a prefix, yielding an IPv6 network address.
   */
  Ipv6Address CombinePrefix (Ipv6Prefix const & prefix);

  /**
   * \brief If the Address matches the type.
   * \param address other address
   * \return true if the type matches, false otherwise
   */
  static bool IsMatchingType (const Address& address);

  /**
   * \brief If the address is an IPv4-mapped address
   * \return true if address is an IPv4-mapped address, otherwise false.
   */
  bool IsIpv4MappedAddress() const;

  /**
   * \brief Convert to Address object
   */
  operator Address () const;

  /**
   * \brief Convert the Address object into an Ipv6Address ones.
   * \param address address to convert
   * \return an Ipv6Address
   */
  static Ipv6Address ConvertFrom (const Address& address);

  /**
   * \brief Get the 0 (::) Ipv6Address.
   * \return the :: Ipv6Address representation
   */
  static Ipv6Address GetZero ();

  /**
   * \brief Get the "any" (::) Ipv6Address.
   * \return the "any" (::) Ipv6Address
   */
  static Ipv6Address GetAny ();

  /**
   * \brief Get the "all nodes multicast" address.
   * \return the "ff02::2/8" Ipv6Address representation
   */
  static Ipv6Address GetAllNodesMulticast ();

  /**
   * \brief Get the "all routers multicast" address.
   * \return the "ff02::2/8" Ipv6Address representation
   */
  static Ipv6Address GetAllRoutersMulticast ();

  /**
   * \brief Get the "all hosts multicast" address.
   * \return the "ff02::3/8" Ipv6Address representation
   */
  static Ipv6Address GetAllHostsMulticast ();

  /**
   * \brief Get the loopback address.
   * \return the "::1/128" Ipv6Address representation.
   */
  static Ipv6Address GetLoopback ();

  /**
   * \brief Get the "all-1" IPv6 address (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff).
   * \return all-1 Ipv6Address representation
   */
  static Ipv6Address GetOnes ();

  /**
   * \brief Get the bytes corresponding to the address.
   * \param buf buffer to store the data
   * \return bytes of the address
   */
  void GetBytes (uint8_t buf[16]) const;

private:
  /**
   * \brief convert the IPv6Address object to an Address object.
   * \return the Address object corresponding to this object.
   */
  Address ConvertTo (void) const;

  /**
   * \brief Return the Type of address.
   * \return type of address
   */
  static uint8_t GetType (void);

  /**
   * \brief The address representation on 128 bits (16 bytes).
   */
  uint8_t m_address[16];

  /**
   * \brief Equal to operator.
   *
   * \param a the first operand.
   * \param b the first operand.
   * \returns true if the operands are equal.
   */
  friend bool operator == (Ipv6Address const &a, Ipv6Address const &b);

  /**
   * \brief Not equal to operator.
   *
   * \param a the first operand.
   * \param b the first operand.
   * \returns true if the operands are not equal.
   */
  friend bool operator != (Ipv6Address const &a, Ipv6Address const &b);

  /**
   * \brief Less than to operator.
   *
   * \param a the first operand.
   * \param b the first operand.
   * \returns true if the first operand is less than the second.
   */
  friend bool operator < (Ipv6Address const &a, Ipv6Address const &b);
};

/**
 * \ingroup address
 * \class Ipv6Prefix
 * \brief Describes an IPv6 prefix. It is just a bitmask like Ipv4Mask.
 * \see Ipv6Address
 * \see attribute_Ipv6Prefix
 */
class Ipv6Prefix
{
public:
  /**
   * \brief Default constructor.
   */
  Ipv6Prefix ();

  /**
   * \brief Constructs an Ipv6Prefix by using the input 16 bytes.
   * \param prefix the 128-bit prefix
   */
  Ipv6Prefix (uint8_t prefix[16]);

  /**
   * \brief Constructs an Ipv6Prefix by using the input string.
   * \param prefix the 128-bit prefix
   */
  Ipv6Prefix (char const* prefix);

  /**
   * \brief Constructs an Ipv6Prefix by using the input number of bits.
   * \param prefix number of bits of the prefix (0 - 128)
   * \note A valid number of bits is between 0 and 128).
   */
  Ipv6Prefix (uint8_t prefix);

  /**
   * \brief Copy constructor.
   * \param prefix Ipv6Prefix object
   */
  Ipv6Prefix (Ipv6Prefix const& prefix);

  /**
   * \brief Copy constructor.
   * \param prefix Ipv6Prefix pointer
   */
  Ipv6Prefix (Ipv6Prefix const* prefix);

  /**
   * \brief Destructor.
   */
  ~Ipv6Prefix ();

  /**
   * \brief If the Address match the type.
   * \param a a first address
   * \param b a second address
   * \return true if the type match, false otherwise
   */
  bool IsMatch (Ipv6Address a, Ipv6Address b) const;

  /**
   * \brief Get the bytes corresponding to the prefix.
   * \param buf buffer to store the data
   */
  void GetBytes (uint8_t buf[16]) const;

  /**
   * \brief Get prefix length.
   * \return prefix length
   */
  uint8_t GetPrefixLength () const;

  /**
   * \brief Comparison operation between two Ipv6Prefix.
   * \param other the IPv6 prefix to which to compare this prefix
   * \return true if the prefixes are equal, false otherwise
   */
  bool IsEqual (const Ipv6Prefix& other) const;

  /**
   * \brief Print this address to the given output stream.
   *
   * The print format is in the typical "2001:660:4701::1".
   * \param os the output stream to which this Ipv6Address is printed
   */
  void Print (std::ostream &os) const;

  /**
   * \brief Get the loopback prefix ( /128).
   * \return a Ipv6Prefix corresponding to loopback prefix
   */
  static Ipv6Prefix GetLoopback ();

  /**
   * \brief Get the "all-1" IPv6 mask (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff).
   * \return /128 Ipv6Prefix representation
   */
  static Ipv6Prefix GetOnes ();

  /**
   * \brief Get the zero prefix ( /0).
   * \return an Ipv6Prefix
   */
  static Ipv6Prefix GetZero ();

private:
  /**
   * \brief The prefix representation.
   */
  uint8_t m_prefix[16];

  /**
   * \brief Equal to operator.
   *
   * \param a the first operand
   * \param b the first operand
   * \returns true if the operands are equal
   */
  friend bool operator == (Ipv6Prefix const &a, Ipv6Prefix const &b);

  /**
   * \brief Not equal to operator.
   *
   * \param a the first operand
   * \param b the first operand
   * \returns true if the operands are not equal
   */
  friend bool operator != (Ipv6Prefix const &a, Ipv6Prefix const &b);
};

ATTRIBUTE_HELPER_HEADER (Ipv6Address);
ATTRIBUTE_HELPER_HEADER (Ipv6Prefix);

/**
 * \brief Stream insertion operator.
 *
 * \param os the reference to the output stream
 * \param address the Ipv6Address
 * \returns the reference to the output stream
 */
std::ostream & operator << (std::ostream& os, Ipv6Address const& address);

/**
 * \brief Stream insertion operator.
 *
 * \param os the reference to the output stream
 * \param prefix the Ipv6Prefix
 * \returns the reference to the output stream
 */
std::ostream & operator << (std::ostream& os, Ipv6Prefix const& prefix);

/**
 * \brief Stream extraction operator.
 *
 * \param is the reference to the input stream
 * \param address the Ipv6Address
 * \returns the reference to the input stream
 */
std::istream & operator >> (std::istream &is, Ipv6Address &address);

/**
 * \brief Stream extraction operator.
 *
 * \param is the reference to the input stream
 * \param prefix the Ipv6Preofix
 * \returns the reference to the input stream
 */
std::istream & operator >> (std::istream &is, Ipv6Prefix &prefix);

inline bool operator == (const Ipv6Address& a, const Ipv6Address& b)
{
  return (!std::memcmp (a.m_address, b.m_address, 16));
}

inline bool operator != (const Ipv6Address& a, const Ipv6Address& b)
{
  return std::memcmp (a.m_address, b.m_address, 16);
}

inline bool operator < (const Ipv6Address& a, const Ipv6Address& b)
{
  return (std::memcmp (a.m_address, b.m_address, 16) < 0);
}

inline bool operator == (const Ipv6Prefix& a, const Ipv6Prefix& b)
{
  return (!std::memcmp (a.m_prefix, b.m_prefix, 16));
}

inline bool operator != (const Ipv6Prefix& a, const Ipv6Prefix& b)
{
  return std::memcmp (a.m_prefix, b.m_prefix, 16);
}

/**
 * \class Ipv6AddressHash
 * \brief Hash function class for IPv6 addresses.
 */
class Ipv6AddressHash : public std::unary_function<Ipv6Address, size_t>
{
public:
  /**
   * \brief Unary operator to hash IPv6 address.
   * \param x IPv6 address to hash
   * \returns the hash of the address
   */
  size_t operator () (Ipv6Address const &x) const;
};

} /* namespace ns3 */

#endif /* IPV6_ADDRESS_H */