libtins 4.5
Loading...
Searching...
No Matches
stream_identifier.h
1/*
2 * Copyright (c) 2017, 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 <tins/config.h>
34
35#ifdef TINS_HAVE_TCPIP
36
37#include <array>
38#include <stdint.h>
39
40namespace Tins {
41
42class PDU;
43class IPv4Address;
44class IPv6Address;
45
46namespace TCPIP {
47
48class Stream;
49
59struct StreamIdentifier {
63 typedef std::array<uint8_t, 16> address_type;
64
68 StreamIdentifier();
69
78 StreamIdentifier(const address_type& client_addr, uint16_t client_port,
79 const address_type& server_addr, uint16_t server_port);
80
84 bool operator<(const StreamIdentifier& rhs) const;
85
89 bool operator==(const StreamIdentifier& rhs) const;
90
91 address_type min_address;
92 address_type max_address;
93 uint16_t min_address_port;
94 uint16_t max_address_port;
95
96 static StreamIdentifier make_identifier(const PDU& packet);
97 static StreamIdentifier make_identifier(const Stream& stream);
98 static address_type serialize(IPv4Address address);
99 static address_type serialize(const IPv6Address& address);
100};
101
102} // TCPIP
103} // Tins
104
105#endif // TINS_HAVE_TCPIP
106#endif // TINS_TCP_IP_STREAM_ID_H
107
The Tins namespace.
Definition address_range.h:38
bool operator==(const PDUIteratorBase< Concrete > &lhs, const PDUIteratorBase< Concrete > &rhs)
Definition pdu_iterator.h:108