]> The Tcpdump Group git mirrors - libpcap/commit
Consolidate MAC-48 address matching code. 1507/head
authorDenis Ovsienko <[email protected]>
Sun, 13 Apr 2025 18:55:11 +0000 (19:55 +0100)
committerDenis Ovsienko <[email protected]>
Mon, 21 Apr 2025 20:35:11 +0000 (21:35 +0100)
commit8f99c57221636f18f73ac026c9f9f7a9c9594dce
tree94c288af952db0627dc5ea36d91a8355f7d744dc
parentad56fa246d80deeca6f632726eedde395162eb7b
Consolidate MAC-48 address matching code.

gen_gateway(), gen_scode(), gen_ecode() and gen_broadcast() all have a
switch block with 11 or 13 DLTs and a default case.

The purpose of the latter is to avoid any calls to pcap_ether_hostton()
in gen_scode() case Q_HOST proto Q_LINK if the DLT does not use MAC-48
addresses, so add a new is_mac48_linktype() function to support this
behaviour; for consistency add the same guard to gen_scode() case
Q_GATEWAY and to gen_ecode().

The purpose of the latter is to avoid any calls to pcap_ether_hostton()
in gen_scode() if the DLT does not use MAC-48 addresses, so add a new
is_mac48_linktype() function to support this behaviour; add similar
guards to gen_scode() case Q_GATEWAY and to gen_ecode() for consistency.

These changes replace a few custom messages with templates, so update,
add and coalesce the tests as required.
gencode.c
testprogs/TESTrun