File: showflags.cc

package info (click to toggle)
natlog 3.01.00-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,912 kB
  • sloc: cpp: 3,691; fortran: 201; sh: 133; ansic: 123; makefile: 110
file content (33 lines) | stat: -rw-r--r-- 684 bytes parent folder | download | duplicates (5)
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
#include "record.ih"

namespace {
    unordered_map<size_t, char const *> flagName =
    {
        { Record::FIN,  "FIN "  }, 
        { Record::SYN,  "SYN "  }, 
        { Record::RST,  "RST "  }, 
        { Record::PUSH, "PUSH " }, 
        { Record::ACK,  "ACK "  }, 
        { Record::URG,  "URG "  }, 
        { Record::ECE,  "ECE "  }, 
        { Record::CWR,  "CWR "  }, 
    };
}

#include <iostream>

string Record::showFlags() const
{
    string ret;

    for (size_t flag = 1; flag & Record::TCP_Flags_MASK; flag <<= 1)
    {
        if (size_t key = flag & d_flags)
            ret += flagName[key];
    }

    if (ret.length())
        ret.pop_back();

    return ret;
}