Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility to determine if ip is local external #8

Merged
merged 27 commits into from
Oct 5, 2023

Conversation

pawsten
Copy link
Collaborator

@pawsten pawsten commented Sep 21, 2023

No description provided.

libebpfdiscovery/src/IpUtils.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpUtils.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpUtils.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpUtils.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpUtils.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/headers/ebpfdiscovery/IpUtils.h Outdated Show resolved Hide resolved
libebpfdiscovery/headers/ebpfdiscovery/IpUtils.h Outdated Show resolved Hide resolved
libebpfdiscovery/headers/ebpfdiscovery/IpUtils.h Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpUtils.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpUtils.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/headers/ebpfdiscovery/IpAddressChecker.h Outdated Show resolved Hide resolved
libebpfdiscovery/headers/ebpfdiscovery/IpAddressChecker.h Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Outdated Show resolved Hide resolved
@pawsten pawsten force-pushed the Add-utility-to-determine-if-ip-is-local-external branch from 251c963 to c6beecc Compare September 28, 2023 08:58
@pawsten pawsten force-pushed the Add-utility-to-determine-if-ip-is-local-external branch from c6beecc to 6a1b063 Compare September 28, 2023 09:00
@pawsten pawsten force-pushed the Add-utility-to-determine-if-ip-is-local-external branch from 9c8b70b to 898c2aa Compare October 3, 2023 09:57
filip-szweda
filip-szweda previously approved these changes Oct 3, 2023
libebpfdiscovery/headers/ebpfdiscovery/IpAddressChecker.h Outdated Show resolved Hide resolved
protected:
void moveBridges();
public:
IpAddressChecker(const NetlinkCalls &calls);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GMock cookbook recommends using interfaces instead of concrete class: http://google.github.io/googletest/gmock_cook_book.html#alternative-to-mocking-concrete-classes
I'm curious, what is your opinion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is small project and most work is one-time. I don't see value in additional boilerplate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @pawsten

void addIpIfce(IpIfce&& ifce);
void markBridge(int idx);
protected:
void moveBridges();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we somehow make this private?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's protected because it's called in UT what is required.

#include <unistd.h>

static constexpr uint32_t BUFFLEN{4096};
static constexpr uint32_t IP_CLASS_C{0x0000a8c0}; // 192.168.*.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that both uint32_t and IPv4 are used across the files. I think that deciding upon only one of these for IPv4 addresses and masks would make the code cleaner

libebpfdiscovery/src/IpAddressChecker.cpp Show resolved Hide resolved
libebpfdiscovery/src/IpAddressChecker.cpp Show resolved Hide resolved
filip-szweda
filip-szweda previously approved these changes Oct 5, 2023
jakubrak
jakubrak previously approved these changes Oct 5, 2023
@hparzych
Copy link
Contributor

hparzych commented Oct 5, 2023

I've added small remarks but it's ready be merged.

@pawsten pawsten dismissed stale reviews from jakubrak and filip-szweda via aa968b8 October 5, 2023 08:52
@pawsten pawsten merged commit d65b35f into main Oct 5, 2023
2 checks passed
@hparzych hparzych deleted the Add-utility-to-determine-if-ip-is-local-external branch October 6, 2023 06:50
hparzych added a commit that referenced this pull request Apr 29, 2024
* Added Utility to termine whether ipv4 is external local

* Added gsl to conanfile

* Added recognizing ipv4 link local addresses

* File NetlinkCalls added

Co-authored-by: Hubert Parzych <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants