seladb / PcapPlusPlus

PcapPlusPlus is a multiplatform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use. It provides C++ wrappers for the most popular packet processing engines such as libpcap, Npcap, WinPcap, DPDK, AF_XDP and PF_RING.
https://pcapplusplus.github.io/
The Unlicense
2.75k stars 674 forks source link

`RawPacket::getPacketTimeStamp()` should be const #187

Closed eteran closed 5 years ago

eteran commented 5 years ago

https://github.com/seladb/PcapPlusPlus/blob/236e035be8d7109082e1b599abd435269f13032d/Packet%2B%2B/src/RawPacket.cpp#L120

This is a simple accessor, it should be const. Not being const, unfortunately, forces me to pass RawPacket by non-const reference simply because of this one method.

I can make a PR for this if that helps, but, it's also just 6 character patch ;-)

echo-Mike commented 5 years ago

Hi, @eteran On most projects so called “const”-patches are welcome.
If You can find more accessors with same problem and merge corrections to one patch it will be appreciated.

seladb commented 5 years ago

I agree. Even making a PR with just 6 chars patch will save me some time :)

eteran commented 5 years ago

OK, I see actually a lot of places where const shoudl be applied. Should the PR be against dev or master?

echo-Mike commented 5 years ago

I think to dev so it can be part of future release

seladb commented 5 years ago

yes, dev is better. I'll merge it to master later

eteran commented 5 years ago

OK, submitting a PR now.

seladb commented 5 years ago

Thanks for this contribution, much appreciated!