]> The Tcpdump Group git mirrors - tcpdump/commitdiff
OpenFlow 1.0: Simplify the snapend management. [skip ci]
authorDenis Ovsienko <[email protected]>
Mon, 25 Jan 2021 12:51:54 +0000 (12:51 +0000)
committerDenis Ovsienko <[email protected]>
Mon, 25 Jan 2021 12:51:54 +0000 (12:51 +0000)
As Guy explains it, nd_push_snapend() makes it easy to save and to
restore the snapend from different functions or different invocations
of the same function. In a simple case a local variable and ND_MIN()
do the job just as well without the associated memory management and
error checking.

print-openflow-1.0.c

index 7751f2d90ead0ef24bdf2870359f3fe11932b943..82a4f0ba0c82d8b660356b4f3d29faa13498265a 100644 (file)
@@ -1025,11 +1025,10 @@ of10_packet_data_print(netdissect_options *ndo,
         * what ether_print() needs to decode an Ethernet frame nested in
         * the middle of a TCP payload.
         */
-       if (!nd_push_snapend(ndo, cp + len))
-               (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
-                                 "%s: failed to adjust snapend", __func__);
+       const u_char *snapend_save = ndo->ndo_snapend;
+       ndo->ndo_snapend = ND_MIN(cp + len, ndo->ndo_snapend);
        ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
-       nd_pop_packet_info(ndo);
+       ndo->ndo_snapend = snapend_save;
        ndo->ndo_vflag += 3;
 }