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.
* what ether_print() needs to decode an Ethernet frame nested in
* the middle of a TCP payload.
*/
* 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);
ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
- nd_pop_packet_info(ndo);
+ ndo->ndo_snapend = snapend_save;