CONTRIBUTING 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. Some Information for Contributors
  2. ---------------------------------
  3. You want to contribute to Tcpdump, Thanks!
  4. Please, read these lines.
  5. How to report bugs and other problems
  6. -------------------------------------
  7. To report a security issue (segfault, buffer overflow, infinite loop, arbitrary
  8. code execution etc) please send an e-mail to security@tcpdump.org, do not use
  9. the bug tracker!
  10. To report a non-security problem (failure to compile, incorrect output in the
  11. protocol printout, missing support for a particular protocol etc) please check
  12. first that it reproduces with the latest stable release of tcpdump and the latest
  13. stable release of libpcap. If it does, please check that the problem reproduces
  14. with the current git master branch of tcpdump and the current git master branch of
  15. libpcap. If it does (and it is not a security-related problem, otherwise see
  16. above), please navigate to https://github.com/the-tcpdump-group/tcpdump/issues
  17. and check if the problem has already been reported. If it has not, please open
  18. a new issue and provide the following details:
  19. * tcpdump and libpcap version (tcpdump --version)
  20. * operating system name and version and any other details that may be relevant
  21. (uname -a, compiler name and version, CPU type etc.)
  22. * configure flags if any were used
  23. * statement of the problem
  24. * steps to reproduce
  25. Please note that if you know exactly how to solve the problem and the solution
  26. would not be too intrusive, it would be best to contribute some development time
  27. and open a pull request instead as discussed below.
  28. Still not sure how to do? Feel free to [subscribe](http://www.tcpdump.org/#mailing-lists)
  29. to the mailing list tcpdump-workers@lists.tcpdump.org and ask!
  30. How to add new code and to update existing code
  31. -----------------------------------------------
  32. 0) Check that there isn't a pull request already opened for the changes you
  33. intend to make.
  34. 1) Fork the Tcpdump repository on GitHub from
  35. https://github.com/the-tcpdump-group/tcpdump
  36. (See https://help.github.com/articles/fork-a-repo/)
  37. 2) Setup an optional Travis-CI build
  38. You can setup a travis build for your fork. So, you can test your changes
  39. on Linux and OSX before sending pull requests.
  40. (See http://docs.travis-ci.com/user/getting-started/)
  41. 3) Setup your git working copy
  42. git clone https://github.com/<username>/tcpdump.git
  43. cd tcpdump
  44. git remote add upstream https://github.com/the-tcpdump-group/tcpdump
  45. git fetch upstream
  46. 4) Do a 'touch .devel' in your working directory.
  47. Currently, the effect is
  48. a) add (via configure, in Makefile) some warnings options ( -Wall
  49. -Wmissing-prototypes -Wstrict-prototypes, ...) to the compiler if it
  50. supports these options,
  51. b) have the Makefile support "make depend" and the configure script run it.
  52. 5) Configure and build
  53. ./configure && make -s && make check
  54. 6) Add/update sample.pcap files
  55. We use tests directory to do regression tests on the dissection of captured
  56. packets, by running tcpdump against a savefile sample.pcap, created with -w
  57. option and comparing the results with a text file sample.out giving the
  58. expected results.
  59. Any new/updated fields in a dissector must be present in a sample.pcap file
  60. and the corresponding output file.
  61. Configuration is set in tests/TESTLIST.
  62. Each line in this file has the following format:
  63. test-name sample.pcap sample.out tcpdump-options
  64. the sample.out file can be build by:
  65. (cd tests && ../tcpdump -n -r sample.pcap tcpdump-options > sample.out)
  66. It is often useful to have test outputs with different verbosity levels
  67. (none, -v, -vv, -vvv, etc.) depending on the code.
  68. 7) Test with 'make check'
  69. Don't send a pull request if 'make check' gives failed tests.
  70. 8) Try to rebase your commits to keep the history simple.
  71. git rebase upstream/master
  72. (If the rebase fails and you cannot resolve, issue "git rebase --abort"
  73. and ask for help in the pull request comment.)
  74. 9) Once 100% happy, put your work into your forked repository.
  75. git push
  76. 10) Initiate and send a pull request
  77. (See https://help.github.com/articles/using-pull-requests/)
  78. Code style and generic remarks
  79. ------------------------------
  80. a) A thorough reading of some other printers code is useful.
  81. b) Put the normative reference if any as comments (RFC, etc.).
  82. c) Put the format of packets/headers/options as comments if there is no
  83. published normative reference.
  84. d) The printer may receive incomplete packet in the buffer, truncated at any
  85. random position, for example by capturing with '-s size' option.
  86. Thus use ND_TTEST, ND_TTEST2, ND_TCHECK or ND_TCHECK2 for bound checking.
  87. For ND_TCHECK2:
  88. Define : static const char tstr[] = " [|protocol]";
  89. Define a label: trunc
  90. Print with: ND_PRINT((ndo, "%s", tstr));
  91. You can test the code via:
  92. sudo ./tcpdump -s snaplen [-v][v][...] -i lo # in a terminal
  93. sudo tcpreplay -i lo sample.pcap # in another terminal
  94. You should try several values for snaplen to do various truncation.
  95. e) Do invalid packet checks in code: Think that your code can receive in input
  96. not only a valid packet but any arbitrary random sequence of octets (packet
  97. - built malformed originally by the sender or by a fuzz tester,
  98. - became corrupted in transit).
  99. Print with: ND_PRINT((ndo, "%s", istr)); /* to print " (invalid)" */
  100. f) Use 'struct tok' for indexed strings and print them with
  101. tok2str() or bittok2str() (for flags).
  102. g) Avoid empty lines in output of printers.
  103. h) A commit message must have:
  104. First line: Capitalized short summary in the imperative (70 chars or less)
  105. Body: Detailed explanatory text, if necessary. Fold it to approximately
  106. 72 characters. There must be an empty line separating the summary from
  107. the body.
  108. i) Avoid non-ASCII characters in code and commit messages.
  109. j) Use the style of the modified sources.
  110. k) Don't mix declarations and code
  111. l) Don't use // for comments
  112. Not all C compilers accept C++/C99 comments by default.
  113. m) Avoid trailing tabs/spaces