This file is indexed.

/usr/include/resip/stack/Tuple.hxx is in libresiprocate-1.9-dev 1.9.6-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
#if !defined(RESIP_TUPLE_HXX)
#define RESIP_TUPLE_HXX

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <memory>

#include "rutil/Socket.hxx"
#include "rutil/compat.hxx"

#include "rutil/HashMap.hxx"
#include "rutil/TransportType.hxx"
#include "rutil/HeapInstanceCounter.hxx"
#include "rutil/Data.hxx"

#if defined(WIN32)
#include <Ws2tcpip.h>
#else
#include <netinet/in.h>
#endif

namespace resip
{

struct GenericIPAddress;
class Transport;

// WARNING!!
// When you change this structure, make sure to update the hash function,
// operator== and operator< to be consistent with the new structure. For
// instance, the Connection* and Transport* change value in the Tuple over
// its lifetime so they must not be included in the hash or comparisons. 

typedef unsigned long FlowKey;
typedef unsigned long TransportKey;

/**
   @ingroup resip_crit
   @brief Represents a network address.

   This includes:
      - IP address
      - port
      - protocol (TransportType)
      - TLS hostname (since this is integral to connection establishment)

   Internally the class is aware of the struct
   sockaddr/sin_addr/sin6addr binary representation of the address.
   The sa_family of struct sockaddr is used to keep track of whether a
   Tuple is representing a an IPv4 or IPv6 address.

   Also included are some comparator classes that can be used for
   containers of Tuple.


*/
class Tuple
{
   public:
      RESIP_HeapCount(Tuple);

      Tuple();

      explicit Tuple(const GenericIPAddress& genericAddress, 
                     TransportType type=UNKNOWN_TRANSPORT, 
                     const Data& targetDomain = Data::Empty);

      Tuple(const Data& printableAddress, 
            int port, 
            IpVersion ipVer, 
            TransportType type=UNKNOWN_TRANSPORT, 
            const Data& targetDomain = Data::Empty);

      Tuple(const Data& printableAddress, 
            int port, 
            TransportType type, 
            const Data& targetDomain = Data::Empty);

      Tuple(const in_addr& pipv4, 
            int pport,
            TransportType ptype, 
            const Data& targetDomain = Data::Empty);

      Tuple(const sockaddr& addr, 
            TransportType ptype, 
            const Data& targetDomain = Data::Empty);

#ifdef IPPROTO_IPV6
      // enable this if the current platform supports IPV6; the USE_IPV6 #define
      // will determine if this c'tor is actually implemented.
      // ?bwc? Is there a more standard preprocessor macro for this?
      // ?bwc? Is there a way we can add something more informative to the 
      // linker error we'll see if we compiled without USE_IPV6, on a platform
      // with IPV6, and someone tries to invoke this c'tor? (ie; "This library
      // was built with IPV6 support disabled")
      Tuple(const in6_addr& pipv6,  
            int pport, 
            TransportType ptype, 
            const Data& targetDomain = Data::Empty);
#endif
      
      /// @brief Retrieve a const binary representation of the socket address
      /// for this tuple.
      const sockaddr& getSockaddr() const { return mSockaddr; }

      ///  @brief Retrieve the binary representation of the socket address for
      /// this tuple.
      sockaddr& getMutableSockaddr() { return mSockaddr; }
      ///  @brief Get a copy of the socket address including the interface and
      /// not the port number
      void copySockaddrAnyPort(sockaddr *sa);

      ///  @brief Set the internal binary representation of the socket address
      /// from the GenericIPAddress.
      void setSockaddr(const GenericIPAddress &);

      TransportType getType() const { return mTransportType; }
      void setType(TransportType type) { mTransportType = type ;}
      void setPort(int port);
      int getPort() const;
      inline FlowKey getFlowKey() const { return mFlowKey;} 

      /// @deprecated use ipVersion()
      /// @todo !dcm! -- should deprecate asap
      bool isV4() const; 

      /// Returns V4 or V6 as appropriate.
      IpVersion ipVersion() const;
      void setIpVersion(IpVersion version);

      ///  @brief TRUE if this address is equal to the "INADDR_ANY" value for
      /// this address family.  
      bool isAnyInterface() const;
      socklen_t length() const; // of sockaddr
      bool isLoopback() const;
      bool isPrivateAddress() const;  // Return boolean based on definitions in RFC1918(v4) and RFC4193(v6)
      
      ///  @brief Compares TransportType, the binary address, port, and
      /// address family of the Tuple.
      bool operator<(const Tuple& rhs) const;

      ///  @brief Compares TransportType, the binary address, port, and
      /// address family of the Tuple.
      bool operator==(const Tuple& rhs) const;
      
      /// Wrapper around the inet_top() method.
      Data presentationFormat() const;
      
      ///  @brief Converts a string representation of transport type,
      /// i.e. "UDP" to a TransportType
      static TransportType toTransport( const Data& );

      ///  @brief Converts the TransportType to a string representation of the
      /// transport type, e.g. "TCP"
      static const Data& toData( TransportType );

      static const Data& toDataLower(TransportType type);

      ///  @brief Converts the binary socket address to presentation format,
      /// via the DnsUtil::inet_ntop() method.
      static Data inet_ntop(const Tuple& tuple);

      // Creates a binary token from the provided Tuple - if salt is provided, then an HMAC is appended
      // to the end of the token
      static void writeBinaryToken(const Tuple& tuple, Data& container, const Data& salt=Data::Empty);
      // Creates a Tuple from the provided binary token - if salt is provided, then an HMAC is checked
      static Tuple makeTupleFromBinaryToken(const Data& binaryToken, const Data& salt=Data::Empty);

      GenericIPAddress toGenericIPAddress() const;

      /// This is a (largely) opaque key that subclasses of Transport will use
      /// to help record/find flows. For UDP and DTLS, this is just the FD, and
      /// the rest of the information about the flow is carried in the Tuple.
      /// For TCP and TLS, the FD of the connection is used.
      /// For protocols where using the FD would not be appropriate (SCTP),
      /// the transport may use whatever method to generate these it likes.
      /// (It is highly recommended that these ids are unique across all
      /// instances of a transport type)
      FlowKey mFlowKey;
      TransportKey transportKey;

      // deprecate
      Transport* transport;
      bool onlyUseExistingConnection;

      ///  @brief compares this tuple with the one passed in for family, port
      /// and address equality using the passed in address mask (mask
      /// is specified by number of bits)
      bool isEqualWithMask(const Tuple& tuple, short mask, bool ignorePort=false, bool ignoreTransport=false) const;

      ///  @brief A "less than" comparator for Tuple, for use in map
      /// containers etc. Comparison is based on transport type, and
      /// if those are equal, it is based on port number.
      class AnyInterfaceCompare
      {
         public:
            bool operator()(const Tuple& x,
                            const Tuple& y) const;
      };
      friend class AnyInterfaceCompare;

      ///  @brief A "less than" comparator for Tuple, for use in map
      /// containers etc. Comparison is based on transport type, and
      /// if those are equal, it is based on the binary representation
      /// of the socket internet address (v4 or v6, whichever is
      /// appropriate).
      class AnyPortCompare
      {
         public:
            bool operator()(const Tuple& x,
                            const Tuple& y) const;
      };
      friend class AnyPortCompare;

      ///  @brief A "less than" comparator for Tuple, for use in map
      /// containers etc. Comparison is based only on transport type
      class AnyPortAnyInterfaceCompare
      {
         public:
            bool operator()(const Tuple& x,
                            const Tuple& y) const;
      };
      friend class AnyPortAnyInterfaceCompare;

      class FlowKeyCompare
      {
         public:
            bool operator()(const Tuple& x,
                            const Tuple& y) const;
      };
      friend class FlowKeyCompare;

      ///  @brief Set the domain name this address tuple intends to represent.
      void setTargetDomain(const Data& target)
      {
         mTargetDomain = target;
      }
      
      ///  @brief Get the domain name this address tuple intends to represent.
      /// Useful with DnsUtil, for example.
      const Data& getTargetDomain() const
      {
         return mTargetDomain;
      }
      
      /**
         @brief Creates a 32-bit hash based on the contents of this Tuple.
      */
      size_t hash() const;   

private:
      union 
      {
            sockaddr mSockaddr;
            sockaddr_in m_anonv4;
#ifdef IPPROTO_IPV6
            // enable this if the current platform supports IPV6
            // ?bwc? Is there a more standard preprocessor macro for this?
            sockaddr_in6 m_anonv6;
#endif
            char pad[RESIP_MAX_SOCKADDR_SIZE]; //< this make union same size if v6 is in or out
      };
      TransportType mTransportType;
      Data mTargetDomain; 

      friend EncodeStream& operator<<(EncodeStream& strm, const Tuple& tuple);
      friend class DnsResult;
};


EncodeStream&
operator<<(EncodeStream& ostrm, const Tuple& tuple);

}

HashValue(resip::Tuple);

#endif
/* ====================================================================
 * The Vovida Software License, Version 1.0 
 * 
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
 *    and "Vovida Open Communication Application Library (VOCAL)" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact vocal@vovida.org.
 *
 * 4. Products derived from this software may not be called "VOCAL", nor
 *    may "VOCAL" appear in their name, without prior written
 *    permission of Vovida Networks, Inc.
 * 
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 * 
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by Vovida
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
 * Inc.  For more information on Vovida Networks, Inc., please see
 * <http://www.vovida.org/>.
 *
 */