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

Netdump library #6518

Closed
wants to merge 29 commits into from
Closed

Netdump library #6518

wants to merge 29 commits into from

Conversation

hreintke
Copy link
Contributor

Netdump library, initial commit

@dok-net
Copy link
Contributor

dok-net commented Sep 16, 2019

@hreintke There's not a single patch to the ESP8266 Arduino core in the PR, it's a plain old library from what I see, why don't you just make it an Arduino library, available via the library manager? If there's interest in the core team, they can still pick it up as a git submodule and establish fixed version relationships in this way, I would not encourage that, though, speaking from experience with EspSoftwareSerial.
The added benefit is that you won't have to bother writing PRs for every change and release you make to/for NetdumpLibrary.

@hreintke
Copy link
Contributor Author

@dok-net At the request of core developers
cc @d-a-v

@dok-net
Copy link
Contributor

dok-net commented Sep 17, 2019

@hreintke I'm just commenting out of concern over ever-longer build times.
That left aside, a review remark, if that's appropriate, other internal libs use, in their library.properties:

dot_a_linkage=true

@hreintke
Copy link
Contributor Author

@dok-net No problem, your comments. And review remarks are welcome.
On longer build time : Aren't libraries only build when included/used in the sketch ?
@d-a-v : Should I include library.properties: dot_a_linkage=true

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 17, 2019

Unused libraries are not compiled.
dot_a_linkage=true is harmless and useful if this library stays here.
This library depends on phy_capture only existing in this core, in fact in another submodule of this core.
Indeed I suggested @hreintke to propose his great improvements of my simple netdump directly here as a PR. However I personally have absolutely nothing against this library from being a submodule or a separate library (it can be useful with Ethernet, but a patch on this one is needed to propose a phy-capture-like call). It's @hreintke's call.

@earlephilhower
Copy link
Collaborator

Re: the longer build times, there is a bug in the arduino-builder that was recently patched that made it scan the entire .git tree (takes 2+ mins and 4GB on my server!) at the start of every build. arduino/arduino-cli#366 . The nightly arduino tarball should have this fixed, or you can build your own arduino-builder executable and install over the existing one from a stable release. This only applies, of course, when you're building from a git clone'd copy and not a board manager install.

@earlephilhower
Copy link
Collaborator

@hreintke trivial failure on the example. Can you run tests/restyle.sh to clean up the formatting to match Arduino standard?

@hreintke
Copy link
Contributor Author

@earlephilhower
This is the initial commit. There is work to do for improving efficiency (using cost type& parameters).
I am working on that at the moment.
In the next update I will also include the style changes.

@dok-net
Copy link
Contributor

dok-net commented Sep 18, 2019

About build times for libraries, what I mostly had in mind is CI, where the examples are all built. Is the NetdumpLibrary really this essential?
"Pollution" of the ESP8266 core git history would be another issue - a submodule over standalone library still has some of the disadvantage as you can tell from the frequent EspSoftwareSerial PRs ;-)
And of course, there is a tendency to just use whatever is there, sometimes resulting in dependency loops or core depending on library.

@dok-net
Copy link
Contributor

dok-net commented Sep 18, 2019

@hreintke IIRC, examples should be in <lib>/examples/<exampleproj>/<exampleproj>.ino
Plus, from the back of my mind, <exampleproj> != <lib>

@devyte
Copy link
Collaborator

devyte commented Nov 8, 2019

@hreintke could you please fix this PR?

@hreintke
Copy link
Contributor Author

hreintke commented Nov 9, 2019

@devyte OK, will fix the issues on the PR.
Do you still want it included in this repo or do you want it as an external library.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 9, 2019

Do you still want it included in this repo or do you want it as an external library.

It's up to you.

If it is an external library you will be the maintainer of it, others will PR on it, we'll import it as a submodule, and it will be usable with other network library if they implement/have a phy_capture() like API.

If it is internal, you'll be able to fix/improve it with PRs.

Anyway, as a submodule or plainly included, it will be useful for learning and debugging.

@devyte
Copy link
Collaborator

devyte commented Nov 9, 2019

@hreintke there are ongoing networking changes and development, and I expect users will be instructed to make use of it for dumps, so I prefer it in the repo close at hand, at least for now.

@hreintke hreintke closed this Nov 12, 2019
@hreintke hreintke deleted the NetdumpLibrary branch November 12, 2019 10:54
@hreintke hreintke reopened this Nov 12, 2019
@hreintke
Copy link
Contributor Author

hreintke commented Nov 12, 2019

@d-a-v @devyte
Had some trouble/unexpected behavior on my github Netdump branch.
Think it is now up to date with my development.

  • I updated with the changes for const etc. Can you check those and comment ?
  • Can you give a astyle conf, then I will apply that
  • Working now on further test and completion of example

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 12, 2019

Can you give a astyle conf, then I will apply that

Add libraries/Netdump into this line and run the script.

@hreintke
Copy link
Contributor Author

@d-a-v @devyte
Can I use experimental features in Netdump ?
Used CallbackLIst for implementing callbacks to multiple instances of Netdump.
If OK, I will do further testing and cleanup of that.

@devyte
Copy link
Collaborator

devyte commented Nov 26, 2019

@hreintke experimental means beware it might abruptly change and is not fully tested. In other words, it's ok to use internally for our core features, but not ok for exposing to users as supported functionality/api.
The purpose is in part your use case, so go ahead.

@hreintke
Copy link
Contributor Author

hreintke commented Dec 5, 2019

@devyte @d-a-v
Can you do another review ?

@d-a-v d-a-v self-requested a review August 12, 2020 19:42
Copy link
Collaborator

@d-a-v d-a-v left a comment

Choose a reason for hiding this comment

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

Thanks !

Copy link
Collaborator

@devyte devyte left a comment

Choose a reason for hiding this comment

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

Of my comments/questions in my previous review, there are 6 that I think are still valid. All others are resolved.
This review adds 6 additional comments on top of the previous 6.

HTTPChar
};

void startSerial(int option) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The switch was changed, but the arg is still received as an int.

WiFi.begin(ssid, password);

if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that what comes next is an infinite loop, I suggest: "WiFiFailed, stopping sketch". I've been confused by these things myself.

void tcpDumpProcess(const NetdumpPacket& np);
void tcpDumpLoop(WiFiServer &tcpDumpServer, NetdumpFilter nf);

WiFiClient tcpDumpClient;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it also not apply to WiFiClientSecure?

char* packetBuffer = nullptr;
size_t bufferIndex = 0;

static constexpr int tcpBuffersize = 2048;
Copy link
Collaborator

Choose a reason for hiding this comment

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

tcpBufferSize* (uppercase S)

Comment on lines +24 to +30
NetdumpIP::NetdumpIP()
{
}

NetdumpIP::~NetdumpIP()
{
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What I mean is that these two implement the default behavior, i.e.: they are empty, so you don't need to do it yourself, because the compiler provides them for you. Just remove them (cleaner)


NetdumpIP::NetdumpIP(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
{
setV4();
Copy link
Collaborator

Choose a reason for hiding this comment

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

What I mean is that there doesn't seem to be an equivalent for IPv6, and also: is this constructor valid for the case of a sketch with only IPv6? If the answer to that is "no", then should the constructor have different args? have an overload with different args? something else?

{
return len;
}
uint16_t ntoh16(uint16_t idx) const
Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant: rather than reimplement here, why not call the lwip functions directly? or wrap the lwip calls in these methods.

Comment on lines +13 to +19
PacketType::PacketType()
{
}

PacketType::~PacketType()
{
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to implement default constructor/destructor, the compiler provides them.

UKNW,
};

PacketType();
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this, if the constructor is the default (empty body in the cpp)

PacketType();
PacketType(PType pt) : ptype(pt) {};

~PacketType();
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this, if the destructor is the default (empty body in the cpp)

@hreintke
Copy link
Contributor Author

Something did not go the way I wanted.

My goal was to sync my branch with the littleFS/unused parameter patches from @d-a-v.
What happened that the PR is updated with my NetdumpV2 (wip), which restructures the way info is taken from the packets and includes a wifi promiscuous mode.

Not sure now how to continue.
It there an (hopefully easy) to revert the PR to the previous commit ?

@hreintke hreintke closed this Aug 14, 2020
This was referenced Aug 15, 2020
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.

5 participants