Convert to c99 int type
This commit is contained in:
parent
a841b93b33
commit
07bab263b3
8 changed files with 65 additions and 65 deletions
|
@ -5,7 +5,7 @@
|
|||
// Copyright : GNU GPL3
|
||||
// Description : Network Sniffer
|
||||
//
|
||||
// Special Thanks to fede.tft for the big help :-)
|
||||
// Special Thanks to fede.tft and admiral0 for the big help :-)
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Copyright : GNU GPL3
|
||||
// Description : Network Sniffer
|
||||
//
|
||||
// Special Thanks to fede.tft for the big help :-)
|
||||
// Special Thanks to fede.tft and admiral0 for the big help :-)
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Copyright : GNU GPL3
|
||||
// Description : Network Sniffer
|
||||
//
|
||||
// Special Thanks to fede.tft for the big help :-)
|
||||
// Special Thanks to fede.tft and admiral0 for the big help :-)
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Copyright : GNU GPL3
|
||||
// Description : Network Sniffer
|
||||
//
|
||||
// Special Thanks to fede.tft for the big help :-)
|
||||
// Special Thanks to fede.tft and admiral0 for the big help :-)
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace boost;
|
|||
packet* packet::factory(int timeEpoch_i, int timeMillis_i, std::string rawData_i)
|
||||
{
|
||||
|
||||
int protocol_type;
|
||||
uint16_t protocol_type;
|
||||
|
||||
std::string temp;
|
||||
temp.reserve(4);
|
||||
|
@ -72,17 +72,17 @@ packet* packet::factory(std::string packetLine)
|
|||
return pkg;
|
||||
}
|
||||
|
||||
int packet::getPacketLength()
|
||||
uint32_t packet::getPacketLength()
|
||||
{
|
||||
return pkgLength;
|
||||
}
|
||||
|
||||
long int packet::getEpoch()
|
||||
uint64_t packet::getEpoch()
|
||||
{
|
||||
return timeEpoch;
|
||||
}
|
||||
|
||||
int packet::getMillis()
|
||||
uint32_t packet::getMillis()
|
||||
{
|
||||
return timeMillis;
|
||||
}
|
||||
|
@ -155,9 +155,9 @@ mac_address packet::getTargetMac()
|
|||
return this->getMacAddress(0);
|
||||
}
|
||||
|
||||
unsigned int packet::getEtherType()
|
||||
uint16_t packet::getEtherType()
|
||||
{
|
||||
unsigned int protocol_type;
|
||||
uint16_t protocol_type;
|
||||
|
||||
std::stringstream convert (this->getHexString(12, 2));
|
||||
convert>>std::hex>>protocol_type;
|
||||
|
@ -178,9 +178,9 @@ ARPpacket::ARPpacket(int timeEpoch_i, int timeMillis_i, std::string rawData_i)
|
|||
return;
|
||||
}
|
||||
|
||||
unsigned int ARPpacket::getOpCode()
|
||||
uint16_t ARPpacket::getOpCode()
|
||||
{
|
||||
unsigned int opcode;
|
||||
uint16_t opcode;
|
||||
|
||||
std::stringstream convert (this->getHexString(ARP_OFFSET+6, 2));
|
||||
convert>>std::hex>>opcode;
|
||||
|
@ -254,9 +254,9 @@ asio::ip::address IPv4packet::getTargetIp()
|
|||
return newaddr;
|
||||
}
|
||||
|
||||
unsigned int IPv4packet::getIdentity()
|
||||
uint16_t IPv4packet::getIdentity()
|
||||
{
|
||||
unsigned int id;
|
||||
uint16_t id;
|
||||
|
||||
std::stringstream convert (this->getHexString(IPv4_OFFSET+4, 2));
|
||||
convert>>std::hex>>id;
|
||||
|
@ -264,9 +264,9 @@ unsigned int IPv4packet::getIdentity()
|
|||
return id;
|
||||
}
|
||||
|
||||
unsigned int IPv4packet::getTTL()
|
||||
uint16_t IPv4packet::getTTL()
|
||||
{
|
||||
unsigned int ttl;
|
||||
uint16_t ttl;
|
||||
|
||||
std::stringstream convert (this->getHexString(IPv4_OFFSET+8, 1));
|
||||
convert>>std::hex>>ttl;
|
||||
|
@ -274,9 +274,9 @@ unsigned int IPv4packet::getTTL()
|
|||
return ttl;
|
||||
}
|
||||
|
||||
unsigned int IPv4packet::getProtocolType()
|
||||
uint16_t IPv4packet::getProtocolType()
|
||||
{
|
||||
unsigned int protocol_type;
|
||||
uint16_t protocol_type;
|
||||
|
||||
std::stringstream convert (this->getHexString(IPv4_OFFSET+9, 1));
|
||||
convert>>std::hex>>protocol_type;
|
||||
|
@ -284,9 +284,9 @@ unsigned int IPv4packet::getProtocolType()
|
|||
return protocol_type;
|
||||
}
|
||||
|
||||
unsigned int IPv4packet::getIPChecksum()
|
||||
uint16_t IPv4packet::getIPChecksum()
|
||||
{
|
||||
unsigned int cs;
|
||||
uint16_t cs;
|
||||
std::stringstream convert (this->getHexString(IPv4_OFFSET+10, 2));
|
||||
convert>>std::hex>>cs;
|
||||
return cs;
|
||||
|
@ -368,33 +368,33 @@ TCPv4packet::TCPv4packet(int timeEpoch_i, int timeMillis_i, std::string rawData_
|
|||
return;
|
||||
}
|
||||
|
||||
unsigned int TCPv4packet::getSenderPort()
|
||||
uint16_t TCPv4packet::getSenderPort()
|
||||
{
|
||||
unsigned int port;
|
||||
uint16_t port;
|
||||
std::stringstream convert (this->getHexString(TCP_OFFSET, 2));
|
||||
convert>>std::hex>>port;
|
||||
return port;
|
||||
}
|
||||
|
||||
unsigned int TCPv4packet::getTargetPort()
|
||||
uint16_t TCPv4packet::getTargetPort()
|
||||
{
|
||||
unsigned int port;
|
||||
uint16_t port;
|
||||
std::stringstream convert (this->getHexString(TCP_OFFSET+2, 2));
|
||||
convert>>std::hex>>port;
|
||||
return port;
|
||||
}
|
||||
|
||||
unsigned int TCPv4packet::getSequenceNumber()
|
||||
uint32_t TCPv4packet::getSequenceNumber()
|
||||
{
|
||||
unsigned int sn;
|
||||
uint32_t sn;
|
||||
std::stringstream convert (this->getHexString(TCP_OFFSET+4, 4));
|
||||
convert>>std::hex>>sn;
|
||||
return sn;
|
||||
}
|
||||
|
||||
unsigned int TCPv4packet::getAcknowledgmentNumber()
|
||||
uint32_t TCPv4packet::getAcknowledgmentNumber()
|
||||
{
|
||||
unsigned int an;
|
||||
uint32_t an;
|
||||
std::stringstream convert (this->getHexString(TCP_OFFSET+8, 4));
|
||||
convert>>std::hex>>an;
|
||||
return an;
|
||||
|
|
32
libPacket.h
32
libPacket.h
|
@ -61,10 +61,10 @@ class packet
|
|||
{
|
||||
|
||||
protected:
|
||||
uint64_t timeEpoch; /** Timestamp */
|
||||
uint32_t timeMillis; /** Millisecond from timestamp */
|
||||
uint32_t pkgLength; /** Packet length */
|
||||
std::string rawData; /** Raw packet recived from riddle */
|
||||
long int timeEpoch; /** Timestamp */
|
||||
int timeMillis; /** Millisecond from timestamp */
|
||||
int pkgLength; /** Packet length */
|
||||
|
||||
public:
|
||||
|
||||
|
@ -83,13 +83,13 @@ public:
|
|||
/* GENERAL FUNCTIONS */
|
||||
|
||||
/** Returns the packet length in bytes. */
|
||||
int getPacketLength();
|
||||
uint32_t getPacketLength();
|
||||
|
||||
/** Returns packet epoch */
|
||||
long int getEpoch();
|
||||
uint64_t getEpoch();
|
||||
|
||||
/** Returns milliseconds passed from epoch */
|
||||
int getMillis();
|
||||
uint32_t getMillis();
|
||||
|
||||
/** Legge n byte a partire dal byte voluto e li restituisce in stringa. */
|
||||
std::string getHexString(int string_cursor, int read_byte);
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
mac_address getTargetMac();
|
||||
|
||||
/** Restituisce ethertype */
|
||||
unsigned int getEtherType();
|
||||
uint16_t getEtherType();
|
||||
|
||||
};
|
||||
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
ARPpacket(int timeEpoch_i, int timeMillis_i, std::string rawData_i);
|
||||
|
||||
/** Ritorna OpCode */
|
||||
unsigned int getOpCode();
|
||||
uint16_t getOpCode();
|
||||
|
||||
/** Ritorna indirizzo IP del mittente */
|
||||
boost::asio::ip::address getSenderIp();
|
||||
|
@ -158,16 +158,16 @@ public:
|
|||
boost::asio::ip::address getTargetIp();
|
||||
|
||||
/** Ritorna identificatore **/
|
||||
unsigned int getIdentity();
|
||||
uint16_t getIdentity();
|
||||
|
||||
/** Ritorna il Time To Live **/
|
||||
unsigned int getTTL();
|
||||
uint16_t getTTL();
|
||||
|
||||
/** Ritorna il tipo di protocollo incapsulato */
|
||||
unsigned int getProtocolType();
|
||||
uint16_t getProtocolType();
|
||||
|
||||
/** Ritorna checksum */
|
||||
unsigned int getIPChecksum();
|
||||
uint16_t getIPChecksum();
|
||||
|
||||
/** Verify checksum **/
|
||||
bool verifyIPChecksum();
|
||||
|
@ -194,16 +194,16 @@ public:
|
|||
TCPv4packet(int timeEpoch_i, int timeMillis_i, std::string rawData_i);
|
||||
|
||||
/** Restituisce porta TCP del mittente */
|
||||
unsigned int getSenderPort();
|
||||
uint16_t getSenderPort();
|
||||
|
||||
/** Restituisce porta TCP del destinatario */
|
||||
unsigned int getTargetPort();
|
||||
uint16_t getTargetPort();
|
||||
|
||||
/** Restituisce il numero di sequenza */
|
||||
unsigned int getSequenceNumber();
|
||||
uint32_t getSequenceNumber();
|
||||
|
||||
/** Restituisce il numero di acknowledgment */
|
||||
unsigned int getAcknowledgmentNumber();
|
||||
uint32_t getAcknowledgmentNumber();
|
||||
|
||||
/** Ritorna dimensione dell'header TCP in byte */
|
||||
unsigned int getHeaderLength();
|
||||
|
|
|
@ -204,10 +204,10 @@ std::string stream::exportRawFlow()
|
|||
return stdstring.str();
|
||||
}
|
||||
|
||||
unsigned int stream::getBufferLength()
|
||||
uint64_t stream::getBufferLength()
|
||||
{
|
||||
|
||||
int bufferlenght = 0;
|
||||
uint64_t bufferlenght = 0;
|
||||
|
||||
for(int i = 0; i <= 1; i++)
|
||||
{
|
||||
|
@ -224,17 +224,17 @@ unsigned int stream::getBufferLength()
|
|||
return bufferlenght;
|
||||
}
|
||||
|
||||
unsigned int stream::getFlowLength()
|
||||
uint64_t stream::getFlowLength()
|
||||
{
|
||||
return (flow[0].length() + flow[1].length())/2;
|
||||
}
|
||||
|
||||
long int stream::getTimeEpoch()
|
||||
uint64_t stream::getTimeEpoch()
|
||||
{
|
||||
return timeEpoch;
|
||||
}
|
||||
|
||||
int stream::getTimeMillis()
|
||||
uint32_t stream::getTimeMillis()
|
||||
{
|
||||
return timeMillis;
|
||||
}
|
||||
|
@ -259,22 +259,22 @@ boost::asio::ip::address stream::getSecondIpAddress()
|
|||
return ipAddress[1];
|
||||
}
|
||||
|
||||
unsigned int stream::getFirstPort()
|
||||
uint16_t stream::getFirstPort()
|
||||
{
|
||||
return port[0];
|
||||
}
|
||||
|
||||
unsigned int stream::getSecondPort()
|
||||
uint16_t stream::getSecondPort()
|
||||
{
|
||||
return port[1];
|
||||
}
|
||||
|
||||
unsigned int stream::getFirstSN()
|
||||
uint32_t stream::getFirstSN()
|
||||
{
|
||||
return sequenceNumber[0];
|
||||
}
|
||||
|
||||
unsigned int stream::getSecondSN()
|
||||
uint32_t stream::getSecondSN()
|
||||
{
|
||||
return sequenceNumber[1];
|
||||
}
|
||||
|
|
24
libPursuer.h
24
libPursuer.h
|
@ -25,18 +25,18 @@ std::string decodeHexText(std::string raw);
|
|||
class stream
|
||||
{
|
||||
private:
|
||||
long int timeEpoch;
|
||||
int timeMillis;
|
||||
uint64_t timeEpoch;
|
||||
uint32_t timeMillis;
|
||||
|
||||
bool flagFirstFIN;
|
||||
bool flagSecondFIN;
|
||||
|
||||
mac_address macAddress[2];
|
||||
boost::asio::ip::address ipAddress[2];
|
||||
unsigned int port[2];
|
||||
uint16_t port[2];
|
||||
|
||||
std::list<TCPv4packet*> buffer[2];
|
||||
unsigned int sequenceNumber[2];
|
||||
uint32_t sequenceNumber[2];
|
||||
std::string flow[2];
|
||||
|
||||
void flushBuffer(int number);
|
||||
|
@ -50,22 +50,22 @@ public:
|
|||
void flushFirstBuffer();
|
||||
void flushSecondBuffer();
|
||||
|
||||
long int getTimeEpoch();
|
||||
int getTimeMillis();
|
||||
uint64_t getTimeEpoch();
|
||||
uint32_t getTimeMillis();
|
||||
mac_address getFirstMacAddress();
|
||||
mac_address getSecondMacAddress();
|
||||
boost::asio::ip::address getFirstIpAddress();
|
||||
boost::asio::ip::address getSecondIpAddress();
|
||||
unsigned int getFirstPort();
|
||||
unsigned int getSecondPort();
|
||||
unsigned int getFirstSN();
|
||||
unsigned int getSecondSN();
|
||||
uint16_t getFirstPort();
|
||||
uint16_t getSecondPort();
|
||||
uint32_t getFirstSN();
|
||||
uint32_t getSecondSN();
|
||||
|
||||
/* Ritorna in byte la somma dei payload dei pachetti nel buffer */
|
||||
unsigned int getBufferLength();
|
||||
uint64_t getBufferLength();
|
||||
|
||||
/* Ritorna lunghezza in byte dei due flussi in uscita */
|
||||
unsigned int getFlowLength();
|
||||
uint64_t getFlowLength();
|
||||
|
||||
std::string exportFlow();
|
||||
std::string exportRawFlow();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue