/Types/lookupTable added
This commit is contained in:
parent
ad92736b74
commit
8bff5f6644
2 changed files with 5 additions and 24 deletions
21
src/Lookup.h
21
src/Lookup.h
|
@ -5,26 +5,7 @@
|
|||
* Author: jdi
|
||||
*/
|
||||
|
||||
#include <boost/bimap.hpp>
|
||||
|
||||
class lookupTable: public boost::bimap<short, std::string> {
|
||||
struct set{
|
||||
short n;
|
||||
std::string s;
|
||||
};
|
||||
public:
|
||||
lookupTable(std::initializer_list<set> l) {
|
||||
for (set s : l) {
|
||||
this->left[s.n]=s.s;
|
||||
}
|
||||
}
|
||||
const short& operator[](std::string s){
|
||||
return this->right[s];
|
||||
}
|
||||
const std::string& operator[](short n){
|
||||
return this->left[n];
|
||||
}
|
||||
};
|
||||
#include "Types/lookupTable.h"
|
||||
|
||||
static lookupTable rcv_lookup = { { 1, "type" }, //string
|
||||
{ 2, "hostname" }, //string
|
||||
|
|
|
@ -84,14 +84,14 @@ int Program::sniff() {
|
|||
for(auto a : p.getPayload()) {
|
||||
dataset d = a.second;
|
||||
auto lookup=(options.flags & FLAG_REVERSE)?snd_lookup:rcv_lookup;
|
||||
if(lookup.find(d.type) ==lookup.end()) {
|
||||
if(lookup.exists(d.type)) {
|
||||
if(d.len>0) {
|
||||
std::cout<<std::dec<<"\t++"<<std::hex<<d.type<<std::dec<<"++\n";
|
||||
} else {
|
||||
std::cout<<std::dec<<"#"<<d.type<<"\tLength: "<<d.len<<"\n";
|
||||
std::cout<<std::hex<< "\tHex: " <<d.value<<"\n";
|
||||
d.value.push_back(0U);
|
||||
std::cout<<"\tString: " <<&d.value[0]<<"\n";
|
||||
} else {
|
||||
std::cout<<std::dec<<"\t++"<<std::hex<<d.type<<std::dec<<"++\n";
|
||||
}
|
||||
} else {
|
||||
std::cout<<"###"<<lookup[d.type]<<"\n";
|
||||
|
|
Loading…
Reference in a new issue