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 print of MDNS detail from UDP packet #2

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

hreintke
Copy link

@hreintke hreintke commented May 3, 2019

As used in debugging of MDNS issue

if ((netDump_getDstPort(ethdata) == 53) || (netDump_getSrcPort(ethdata) == 53))
{
out.print(F(" DNS "));
netDumpDNS(out, ethdata + ETH_HDR_LEN + netDump_getIpHdrLen(ethdata) + 8);
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks !
What do you think of factorizing ?

bool mdns = netDump_getDstPort(ethdata) == 5353) || (netDump_getSrcPort(ethdata) == 5353;
bool dns = netDump_getDstPort(ethdata) == 53) || (netDump_getSrcPort(ethdata) == 53;
if (mdns || dns)
{
   if (mdns) out.print(F(" MDNS ")); else out.print(F(" DNS "));
   ...
}

@hreintke
Copy link
Author

hreintke commented May 3, 2019

Yes, Is better and less duplication of code.
But I left it like it is because I am writing a PR which would generalize the functionality of netdump and tcpdump, including easy creation of custom callbacks.
Working on a Proof of concept, which I hope to show you today or tomorrow.

@hreintke
Copy link
Author

hreintke commented May 3, 2019

@d-a-v :
See the netdump_poc.
It is very much work in progress but shows the way I am thinking.

All is one file for now, easier for me to develop.

Application should able to :
netdump.printDump(Serial);
netdump.printDump(Serial, [](NetworkPacket np){ return (np.isIPv4();}
netdump.printDump(Serial, [](NetworkPacket np){ return (np.destIP() == IPAddress(10,0,0,217);}

netdump.setcallback([](NetworkPacket np){ .....}

PS : untested runtime just now, compiles OK

@hreintke
Copy link
Author

hreintke commented May 4, 2019

Updates and first tests.

To use this version.

#include "Netdump_poc"

Netdump* Netdump::self;
Netdump np;

np.printDump(Serial);
netdump.printDump(Serial, [](NetworkPacket np){ return (np.isIPv4();}

np.fileDump works also, not very much tested and needs work for better handling of open/close/write files.

tcpDump : Need to include the code from your

I am on a short trip to France until next thursday or friday -> silence from my side 😄

@d-a-v
Copy link
Owner

d-a-v commented May 4, 2019

Where that ? :)

@hreintke
Copy link
Author

hreintke commented May 4, 2019

https://www.vaugouard.com
Nice, relaxed, good food, challenging golf course

@hreintke
Copy link
Author

@d-a-v
Can you take a look at the current implementation ?
Not fully tested yet, but close to complete functionality

@d-a-v
Copy link
Owner

d-a-v commented May 22, 2019

Thanks! I will test asap

@d-a-v
Copy link
Owner

d-a-v commented May 28, 2019

@hreintke I had a look - You changed pretty everything ! - and I'm fine with that, the functional way fits nicely.

I propose several things, you tell me what you think about them:

  • Can we agree on a coding style (like Allman, 4 spaces, no tabs or whatever consistent, my vi-like editor looks like broken, even "changes" on gihub - I am currently and painly giving up with my beloved tabs, they are not compatible with open source collaboration)
    (what is your editor, can you set its parameters with an inline directive?)
  • My code is in src/Netdump.h (renamed to NetDumpDAV.h) and src/utility
    Yours in src/Netdump
    Can you properly separate your work
    • mine is still Netdump.h, yours could be Netdump2.h
    • or remove mine
  • What is your feeling about using lambdas instead of std::bind ?
  • Can you add minimal examples
  • Your examples/NetDumpTest.cpp is not arduino-right. examples/Netdump2/Netdump2.ino would be a good one

@hreintke
Copy link
Author

@d-a-v
Sorry, missed this comment until now.

You changed pretty everything !

I tried to make it as easy as possible for others to use/integrate. in that way it is possible to ask issue submitters to include netdump and report without much trouble

Can we agree on a coding style

Sure, no problem. Do you have an astyle config for your preference. I have the windows version working and can pass everything through that.

My code is in src/Netdump.

I just added my code in a way to evaluate.
Please provide the (directory)structure and I will update it to that.

What is your feeling about using lambdas instead of std::bind ?

I learned this week that there is a difference between the two.
Did my reading and indeed think it is good to update. Will do

Can you add minimal examples
Your examples/NetDumpTest.cpp is not arduino-right

Yes will do, I wanted to wait until you agreed to the implementation,
I am using eclipse (sloeber) and only cpp, no ino.
Think that just changing .cpp to .ino will do the job but am not 100% sure.
Will make .ino examples, please test on your config if they work OK for you too.

@d-a-v
Copy link
Owner

d-a-v commented Jun 18, 2019 via email

@d-a-v
Copy link
Owner

d-a-v commented Jun 22, 2019

Again, this is a complete rewrite.
Technically this PR cannot be accepted as is.
But it is worth replacing mine because it is more complete and works differently (lambdas, filters, IPv6, mDNS, scheduled functions)

Why it can't be accepted as is:

  • you are not working with arduino, so you can't see the directory structure is not arduino compliant:

    • remove netdumpDAV and the netdump*.cpp in utility/
    • arduino will not read subdirectories (except utility/): move files to src/
    • examples are in examples/sketchname/sketchname.ino (not in examples/theExample.cpp)
  • macOS FS lets you mix caps letters, linux makes a difference

    • rename all files with consistency (some are NetDump, others Netdump)
  • also:

    • use const type& when passing complex data structures in parameters (like IPAddress, NetDumpAddress, or String) otherwise they will be copied each time they are passed

What I propose:

  • clean your fork from other "EspGoodies", only keep Netdump
    (or create a new "Netdump2" repo with your files)
  • let me make PRs on your repository
  • I will put a link from my repo to yours
  • we can later ask (other) esp8266 arduino core maintainers to integrate this library (plainly or as a submodule) into the main repository

What do you think ?

@hreintke
Copy link
Author

It's the right way forward.,

I will make the updates as you proposed.
What is your preference, update espgoodies or netdump repo ?

Will not be next week, I'll be off to France again (Jura).

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.

2 participants