]> The Tcpdump Group git mirrors - tcpdump/blobdiff - CONTRIBUTING
ICMPv6: Add the IPv6-Only flag
[tcpdump] / CONTRIBUTING
index 0093fc9aa3ccd626db708a154f008071004a53bd..4e94d645ee5cea356be6769b631f416d642b6bd5 100644 (file)
@@ -73,9 +73,13 @@ How to add new code and to update existing code
 6) Add/update sample.pcap files
    We use tests directory to do regression tests on the dissection of captured
    packets.  Those captured packets were saved running tcpdump with option "-w
-   sample.pcap".  Additional options like "-n" and "-t" are used to create
-   relevant and reproducible output.  The actual test compares the current text
-   output with the expected result (sample.out) saved from a previous version.
+   sample.pcap".  Additional options, such as "-n", are used to create relevant
+   and reproducible output; "-#" is used to indicate which particular packets
+   have output that differs.  The tests are run with the TZ environment
+   variable set to GMT0, so that UTC, rather than the local time where the
+   tests are being run, is used when "local time" values are printed.  The
+   actual test compares the current text output with the expected result
+   (sample.out) saved from a previous version.
 
    Any new/updated fields in a dissector must be present in a sample.pcap file
    and the corresponding output file.
@@ -85,7 +89,7 @@ How to add new code and to update existing code
    test-name   sample.pcap   sample.out   tcpdump-options
 
    The sample.out file can be build by:
-   (cd tests && ../tcpdump -n -t -r sample.pcap tcpdump-options > sample.out)
+   (cd tests && TZ=GMT0 ../tcpdump -# -n -r sample.pcap tcpdump-options > sample.out)
 
    Or, for convenience, use "./update-test.sh test-name"
 
@@ -122,9 +126,18 @@ c) Put the format of packets/headers/options as comments if there is no
 
 d) The printer may receive incomplete packet in the buffer, truncated at any
    random position, for example by capturing with '-s size' option.
-   Thus use ND_TTEST, ND_TTEST_LEN, ND_TCHECK or ND_TCHECK_LEN for bound checking.
-   For ND_TCHECK_LEN:
-     Define : static const char tstr[] = " [|protocol]";
+   Thus use, for bounds checking, one of the following macros (defined in
+   netdissect.h or extract.h):
+    ND_TCHECK_n(p), n in { 1, 2, 3, 4, 5, 6, 7, 8, 16 }
+    ND_TCHECK_SIZE(p)
+    ND_TCHECK_LEN(p, l)
+
+    ND_TTEST_n(p), n in { 1, 2, 3, 4, 5, 6, 7, 8, 16 }
+    ND_TTEST_SIZE(p)
+    ND_TTEST_LEN(p, l)
+
+   For the ND_TCHECK_* macros (if not already done):
+     Assign: ndo->ndo_protocol = "protocol";
      Define a label: trunc
      Print with: nd_print_trunc(ndo);
    You can test the code via:
@@ -135,8 +148,8 @@ d) The printer may receive incomplete packet in the buffer, truncated at any
 e) Do invalid packet checks in code: Think that your code can receive in input
    not only a valid packet but any arbitrary random sequence of octets (packet
    - built malformed originally by the sender or by a fuzz tester,
-   - became corrupted in transit).
-   Print with: ND_PRINT("%s", istr);   /* to print " (invalid)" */
+   - became corrupted in transit or for some other reason).
+   Print with: nd_print_invalid(ndo);  /* to print " (invalid)" */
 
 f) Use 'struct tok' for indexed strings and print them with
    tok2str() or bittok2str() (for flags).