-
Notifications
You must be signed in to change notification settings - Fork 861
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
New feature to limit capture file size #464
base: master
Are you sure you want to change the base?
Conversation
We have the -C option, giving a file size in megabytes (real megabytes, i.e. 1,000,000 bytes, not 1,048,576 bytes); once the file gets that big, tcpdump switches to a new file. This adds another file size option, with a different syntax for the size option, and with tcpdump stopping rather than rotating files when it reaches that size. We also have the -G option, to rotate files based on time rather than size. We might want to consider cleaning up these options a bit, so that we can specify "stop" vs. "rotate" and "file size" rather than "capture time" independently. |
Indeed. Cleaning up / consolidating options would be good. Bit of a struggle keeping backward compatibility, mind. Note this pull request is in response to issue #97 which itself was carried over from SourceForge issue http://webcache.googleusercontent.com/search?q=cache:9fbyrQQJZnMJ:sourceforge.net/p/tcpdump/bugs/93/+&cd=2&hl=en&ct=clnk&gl=uk (created 31-Jan-2008, quite a vintage) |
Fortunately, --limit-file-size isn't yet in tcpdump, so we can make its behavior whatever we want it to be. How about making its size default to megabytes (as in "1,000,000 bytes"), just as it is for -C, and have it support "k", "m", and "g", meaning kilobytes (as in "1,000 bytes"), megabytes, and gigabytes (as in "1,000,000,000 bytes"), with "ki" meaning "kibibytes" (as in "1,024 bytes"), "mi" meaning "mibibytes" (as in "1,048,576 bytes"), and "gi" meaning "gibibytes" (as in "1,073,741,824 bytes)? Then we can add those suffixes to -C as well. |
…/gi/k/m/g suffixes for both -C and --limit-file-size.
Good points. Try this for size then, pun intended. https://github.com/stevekay/tcpdump/commit/e7ed12bc027628de15e2960bf45dd091f3847d6f |
Slightly easier way to parse numerical arguments possibly followed by a suffix:
See, for example, the way we handle the |
OK, now revised as suggested. |
Our style puts spaces around assignment operators and after commas that separate arguments, so do Also, right after you do that, fail if Also, I've just added an |
Yes, had missed a few instances, now fixed.
Can add such a test if you want it to improve readability, but functionally it is not required. That is caught by the
Great, now revised to make use of that. |
307efd9
to
99c91c3
Compare
@stevekay |
Hi, tcpdump --versiontcpdump version 4.1.1 Thanks, |
sindhudhatri <[email protected]> wrote:
We also are checking a similar kind of usecase with tcpdump. So can
you please confirm if this limit of file size option is supported or
not. If yes, in which version of tcpdump.
On our machine, we have:
tcpdump --version
tcpdump version 4.1.1
libpcap version 0.9.8
We just released 4.9.
The 4.1 version is a decade old.
…--
] Never tell me the odds! | ipv6 mesh networks [
] Michael Richardson, Sandelman Software Works | network architect [
] [email protected] http://www.sandelman.ca/ | ruby on rails [
|
Hi, If not, please let me know the version and the option that was introduced for this, stopping of tcpdump when file size is reached. Because, I checked the source code of tcpdump-4.9.0 (http://www.tcpdump.org/#latest-releases) where I didnt find any file changes which is mentioned in this thread limit-file-size. So please confirm on the version and the option that can be used. In another machine we have tcpdump version as 4.8.1 also: Regards, |
|
I have cancelled an earlier similar pull request I made. This pull request incorporates the suggestions concerning ambiguous else, int overflow and trailing whitespace.