-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#14712) pcapplusplus: add version v22.11
* Update recipe to PcapPlusPlus v22.11 * Add `test_v1_package` * Fix typo * Add sources for 22.11 * Trigger CI * Address comment in CMakeLists Co-authored-by: Uilian Ries <uilianries@gmail.com> * Remove `test_package.cpp` from `test_v1_package` * Try fixing the bin path * Apply changes suggested by @prince-chrismc * Fix bin folder * Fix test_v1_package bin dir * Revert bin location change * Simplify test package Signed-off-by: Uilian Ries <uilianries@gmail.com> Signed-off-by: Uilian Ries <uilianries@gmail.com> Co-authored-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
1f4f8a3
commit 454af42
Showing
9 changed files
with
60 additions
and
69 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
Binary file not shown.
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
find_package(pcapplusplus REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) | ||
target_link_libraries(${PROJECT_NAME} pcapplusplus::pcapplusplus) |
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 |
---|---|---|
@@ -1,43 +1,8 @@ | ||
#include <cstdlib> | ||
#include <iostream> | ||
#include <IPv4Layer.h> | ||
#include <Packet.h> | ||
#include <PcapFileDevice.h> | ||
#include <PcapPlusPlusVersion.h> | ||
|
||
int main(int argc, char **argv) { | ||
if (argc < 2) { | ||
std::cerr << "ERROR: Need at least one argument" << std::endl; | ||
return 1; | ||
} | ||
|
||
// open a pcap file for reading | ||
pcpp::PcapFileReaderDevice reader(argv[1]); | ||
if (!reader.open()) { | ||
std::cerr << "ERROR: Error opening the pcap file" << std::endl; | ||
return 1; | ||
} | ||
|
||
// read the first (and only) packet from the file | ||
pcpp::RawPacket rawPacket; | ||
if (!reader.getNextPacket(rawPacket)) { | ||
std::cerr << "ERROR: Couldn't read the first packet in the file" << std::endl; | ||
return 1; | ||
} | ||
|
||
// parse the raw packet into a parsed packet | ||
pcpp::Packet parsedPacket(&rawPacket); | ||
|
||
// verify the packet is IPv4 | ||
if (parsedPacket.isPacketOfType(pcpp::IPv4)) { | ||
// extract source and dest IPs | ||
pcpp::IPv4Address srcIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getSrcIPv4Address(); | ||
pcpp::IPv4Address destIP = parsedPacket.getLayerOfType<pcpp::IPv4Layer>()->getDstIPv4Address(); | ||
|
||
// print source and dest IPs | ||
std::cout << "Source IP is '" << srcIP.toString() << "'; Dest IP is '" << destIP.toString() << "'" << std::endl; | ||
} | ||
|
||
// close the file | ||
reader.close(); | ||
|
||
return 0; | ||
int main() { | ||
std::cout << "PCAP++ VERSION: " << pcpp::getPcapPlusPlusVersionFull() << std::endl; | ||
return EXIT_SUCCESS; | ||
} |
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,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
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,18 @@ | ||
from conans import ConanFile, CMake | ||
from conan.tools.build import cross_building | ||
import os | ||
|
||
|
||
class TestPackageV1Conan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
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 |
---|---|---|
|
@@ -5,3 +5,5 @@ versions: | |
folder: all | ||
"22.05": | ||
folder: all | ||
"22.11": | ||
folder: all |