Skip to content

Commit

Permalink
Testing INSTALL-EBPF-XDP#18
Browse files Browse the repository at this point in the history
  • Loading branch information
vpidatala94 committed Feb 18, 2025
1 parent 9a7769e commit e7dc9e0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/plugin/eventwriter/event_writer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\vpidatala\Code\vinodRetina\retina\test\plugin\eventwriter\event_writer.vcxproj(140,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is packages\eBPF-for-Windows.x64.0.20.0\build\native\ebpf-for-windows.x64.props.
32 changes: 31 additions & 1 deletion test/plugin/eventwriter/event_writer_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,39 @@ unload_programs_detach() {
return 0;
}

std::vector<int> get_interface_indices() {
std::vector<int> interface_indices;
ULONG buffer_size = 0;
GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &buffer_size);
std::vector<BYTE> buffer(buffer_size);
PIP_ADAPTER_ADDRESSES adapters = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(buffer.data());

if (GetAdaptersAddresses(AF_UNSPEC, 0, NULL, adapters, &buffer_size) == NO_ERROR) {
for (PIP_ADAPTER_ADDRESSES adapter = adapters; adapter != NULL; adapter = adapter->Next) {
interface_indices.push_back(adapter->IfIndex);
}
} else {
std::cerr << "Failed to get network adapters" << std::endl;
}

int main(void) {
return interface_indices;
}

int main() {
int ret;
ret = pin_maps_load_programs();
if (ret != 0) {
return ret;
}
std::vector<int> interface_indices = get_interface_indices();
for (int ifindx : interface_indices) {
ret = attach_program_to_interface(ifindx);
if (ret != 0) {
return ret;
}
}

std::cout << "All programs attached successfully." << std::endl;
unload_programs_detach()
return 0;
}

0 comments on commit e7dc9e0

Please sign in to comment.