X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2FpcapDecoder%2Fmain.cpp;h=97474e8428a5cb9d2a32b241ddedb2c8220ee5d5;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=32e9dcbd3b0e87a8520414305a69cb3c120f4a6a;hpb=93366a0bda79e6fd6e7dad6316bfcf8cc82f5731;p=anna.git diff --git a/example/diameter/pcapDecoder/main.cpp b/example/diameter/pcapDecoder/main.cpp index 32e9dcb..97474e8 100644 --- a/example/diameter/pcapDecoder/main.cpp +++ b/example/diameter/pcapDecoder/main.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -50,20 +49,20 @@ public: } } - void setSourceIP(const std::string &srcIP) throw() { + void setSourceIP(const std::string &srcIP) { _sourceIP = srcIP; } - void setDestinationIP(const std::string &dstIP) throw() { + void setDestinationIP(const std::string &dstIP) { _destinationIP = dstIP; } - void setTimestamp(time_t ts) throw() { + void setTimestamp(time_t ts) { _timestamp = ts; } - void setTimestampU(int tsu) throw() { + void setTimestampU(int tsu) { _timestampU = tsu; } // Returns true if completed: - bool appendData(const char *data, size_t size) throw(RuntimeException) { + bool appendData(const char *data, size_t size) noexcept(false) { LOGDEBUG( Logger::debug(anna::functions::asString("Appending %d bytes", size), ANNA_FILE_LOCATION)); _data.append(data, size); @@ -80,7 +79,7 @@ public: return true; } - void reset() throw() { + void reset() { _sourceIP = ""; _destinationIP = ""; _timestamp = 0; @@ -89,22 +88,22 @@ public: _diameterLength = -1; // not calculated yet } - const std::string &getSourceIP() const throw() { + const std::string &getSourceIP() const { return _sourceIP; } - const std::string &getDestinationIP() const throw() { + const std::string &getDestinationIP() const { return _destinationIP; } - time_t getTimestamp() const throw() { + time_t getTimestamp() const { return _timestamp; } - int getTimestampU() const throw() { + int getTimestampU() const { return _timestampU; } - const std::string &getData() const throw() { + const std::string &getData() const { return _data; } - std::string getDataAsHex() const throw() { + std::string getDataAsHex() const { return anna::functions::asHexString( anna::DataBlock(_data.c_str(), _data.size())); } @@ -180,12 +179,10 @@ struct sniff_tcp { u_char *getPayload(const u_char* packet, int packetSize, int &payloadSize, std::string &srcIp, std::string &dstIp, int &fragmentId, bool &dfFlag, bool &mfFlag, int &fragmentOffset) { - const struct sniff_ethernet *ethernet; /* The ethernet header */ const struct sniff_ip *ip; /* The IP header */ const struct sniff_tcp *tcp; /* The TCP header */ u_int size_ip; u_int size_tcp; - ethernet = (struct sniff_ethernet*)(packet); ip = (struct sniff_ip*)(packet + SIZE_ETHERNET); size_ip = IP_HL(ip) * 4; // 4 bytes per 32 bits word @@ -256,7 +253,7 @@ void my_callback(u_char *useless, const struct pcap_pkthdr* pkthdr, count++; } -bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) throw() { +bool getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) { // Get hex string static char buffer[8192]; std::ifstream infile(pathfile.c_str(), std::ifstream::in); @@ -307,7 +304,7 @@ int main(int argc, char **argv) { // Command-line parameters: std::string inputFile = argv[1]; - bool isHex = (inputFile.substr(inputFile.find_last_of(".") + 1) == "hex"); + //bool isHex = (inputFile.substr(inputFile.find_last_of(".") + 1) == "hex"); std::string outputFile = inputFile; // extension will be added later std::string optionals; int indx = 2; @@ -322,8 +319,8 @@ int main(int argc, char **argv) { // SNIFFING //////////////////////////////////////////////////////////////////////////////////////////////7 //temporary packet buffers - struct pcap_pkthdr header; // The header that pcap gives us - const u_char *packet; // The actual packet + //struct pcap_pkthdr header; // The header that pcap gives us + //const u_char *packet; // The actual packet //------------------ //open the pcap file pcap_t *handle;