libtins  3.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
stream_identifier.h
1 /*
2  * Copyright (c) 2016, Matias Fontanini
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #ifndef TINS_TCP_IP_STREAM_ID_H
31 #define TINS_TCP_IP_STREAM_ID_H
32 
33 #include "../cxxstd.h"
34 
35 // This classes use C++11 features
36 #if TINS_IS_CXX11
37 
38 namespace Tins {
39 
40 class PDU;
41 class IPv4Address;
42 class IPv6Address;
43 
44 namespace TCPIP {
45 
59  typedef std::array<uint8_t, 16> address_type;
60 
65 
74  StreamIdentifier(const address_type& client_addr, uint16_t client_port,
75  const address_type& server_addr, uint16_t server_port);
76 
80  bool operator<(const StreamIdentifier& rhs) const;
81 
85  bool operator==(const StreamIdentifier& rhs) const;
86 
87  address_type min_address;
88  address_type max_address;
89  uint16_t min_address_port;
90  uint16_t max_address_port;
91 
92  static StreamIdentifier make_identifier(const PDU& packet);
93  static address_type serialize(IPv4Address address);
94  static address_type serialize(const IPv6Address& address);
95 };
96 
97 } // TCPIP
98 } // Tins
99 
100 #endif // TINS_IS_CXX11
101 #endif // TINS_TCP_IP_STREAM_ID_H
102 
bool operator==(const StreamIdentifier &rhs) const
Definition: stream_identifier.cpp:78
Uniquely identifies a stream.
Definition: stream_identifier.h:55
std::array< uint8_t, 16 > address_type
Definition: stream_identifier.h:59
StreamIdentifier()
Definition: stream_identifier.cpp:51
bool operator<(const StreamIdentifier &rhs) const
Definition: stream_identifier.cpp:73
Abstraction of an IPv4 address.
Definition: ip_address.h:44
Definition: ipv6_address.h:44
Base class for protocol data units.
Definition: pdu.h:108