summaryrefslogtreecommitdiff
path: root/src/api/session.h
blob: 80d05eed7d95afb9a2bc077120bef67d933adaf9 (plain)
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
//------------------------------------------------------------------------------
// Author: Pavel Karneliuk
// Description: Session structure.
// Copyright (c) 2013 EPAM Systems
//------------------------------------------------------------------------------
/*
    This file is part of Nfstrace.

    Nfstrace is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, version 2 of the License.

    Nfstrace 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 Nfstrace.  If not, see <http://www.gnu.org/licenses/>.
*/
//------------------------------------------------------------------------------
#ifndef SESSION_H
#define SESSION_H
//------------------------------------------------------------------------------
#include <cstdint>

#include <netinet/in.h> // for in_port_t, in_addr_t types
//------------------------------------------------------------------------------
namespace NST
{
namespace API
{

struct Session
{
    enum Direction
    {
        Source      =0,
        Destination =1,
        Unknown     =0xBAD
    };

    enum Type
    {
        TCP=0,
        UDP=1
    } type   :16;       // 16 bit for alignment following integers

    enum IPType
    {
        v4=0,
        v6=1
    } ip_type:16;       // 16 bit for alignment following integers

    in_port_t port[2];  // 2 ports in network byte order

    union IPAddress
    {
        struct  // 2 IPv4 addresses in network byte order
        {
            in_addr_t addr[2];
        } v4;
        union   // 2 IPv6 addresses in network byte order
        {
            uint8_t  addr       [2][16];
            uint32_t addr_uint32[2][4];
        } __attribute__ ((__packed__)) v6;
    } ip;
};

} // namespace API
} // namespace NST
//------------------------------------------------------------------------------
#endif//SESSION_H
//------------------------------------------------------------------------------