forked from sudoVlad/openair-cn-cups
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-1 Implements send data to uplink test in spgwu
- Loading branch information
1 parent
926c10b
commit 89c5d90
Showing
10 changed files
with
250 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "packet_stats.hpp" | ||
#include <PcapLiveDevice.h> | ||
#include <IPv4Layer.h> | ||
#include <iostream> | ||
|
||
packet_stats::packet_stats(const std::string& destination_address) | ||
: m_destination_address(destination_address) | ||
{ | ||
clear(); | ||
} | ||
|
||
packet_stats::~packet_stats() | ||
{ | ||
} | ||
|
||
void packet_stats::on_packet_arrives(pcpp::RawPacket *packet, pcpp::PcapLiveDevice *dev, void *cookie) | ||
{ | ||
// extract the stats object form the cookie | ||
packet_stats *stats = (packet_stats *)cookie; | ||
|
||
// parsed the raw packet | ||
pcpp::Packet parsedPacket(packet); | ||
|
||
// collect stats from packet | ||
stats->consume_packet(parsedPacket); | ||
} | ||
|
||
bool packet_stats::on_packet_arrives_blocking_mode(pcpp::RawPacket* packet, pcpp::PcapLiveDevice* dev, void* cookie) | ||
{ | ||
on_packet_arrives(packet, dev, cookie); | ||
return false; | ||
} | ||
|
||
void packet_stats::consume_packet(pcpp::Packet &packet) | ||
{ | ||
if (packet.isPacketOfType(pcpp::IPv4)) { | ||
auto destination_addresss = static_cast<pcpp::IPv4Layer*>(packet.getLayerOfType(pcpp::IPv4))->getDstIpAddress(); | ||
std::cout << "Destination address " << destination_addresss.toString() << std::endl; | ||
|
||
if(destination_addresss == m_destination_address){ | ||
m_ipv4_count++; | ||
} | ||
} | ||
} | ||
|
||
void packet_stats::clear() | ||
{ | ||
m_ipv4_count = 0; | ||
} | ||
|
||
|
||
unsigned int packet_stats::get_ipv4_count() const | ||
{ | ||
return m_ipv4_count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <RawPacket.h> | ||
#include <PcapLiveDevice.h> | ||
#include <Packet.h> | ||
|
||
/** | ||
* @brief Class for packet stats. | ||
*/ | ||
class packet_stats | ||
{ | ||
public: | ||
packet_stats(const std::string& destination_address); | ||
virtual ~packet_stats(); | ||
static void on_packet_arrives(pcpp::RawPacket* packet, pcpp::PcapLiveDevice* dev, void* cookie); | ||
static bool on_packet_arrives_blocking_mode(pcpp::RawPacket* packet, pcpp::PcapLiveDevice* dev, void* cookie); | ||
void consume_packet(pcpp::Packet& packet); | ||
void clear(); | ||
unsigned int get_ipv4_count() const; | ||
private: | ||
unsigned int m_ipv4_count; | ||
std::string m_destination_address; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.