+ if (ethertype_print(ndo, length_type, p, length, caplen, &src, &dst) == 0) {
+ /* type not known, print raw packet */
+ if (!ndo->ndo_eflag) {
+ /*
+ * We didn't print the full link-layer
+ * header, as -e wasn't specified, so
+ * print only the source and destination
+ * MAC addresses and the final Ethernet
+ * type.
+ */
+ ether_addresses_print(ndo, src.addr, dst.addr);
+ ether_type_print(ndo, length_type);
+ ND_PRINT(", length %u: ", orig_length);
+ }
+
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
+ }
+ return (hdrlen);
+}
+
+/*
+ * Print an Ethernet frame while specyfing a non-standard Ethernet header
+ * length.
+ * This might be encapsulated within another frame; we might be passed
+ * a pointer to a function that can print header information for that
+ * frame's protocol, and an argument to pass to that function.
+ *
+ * FIXME: caplen can and should be derived from ndo->ndo_snapend and p.
+ */
+u_int
+ether_print_switch_tag(netdissect_options *ndo, const u_char *p, u_int length,
+ u_int caplen,
+ void (*print_switch_tag)(netdissect_options *, const u_char *),
+ u_int switch_tag_len)
+{
+ return (ether_print_common(ndo, p, length, caplen, print_switch_tag,
+ switch_tag_len, NULL, NULL));
+}
+
+/*
+ * Print an Ethernet frame.
+ * This might be encapsulated within another frame; we might be passed
+ * a pointer to a function that can print header information for that
+ * frame's protocol, and an argument to pass to that function.
+ *
+ * FIXME: caplen can and should be derived from ndo->ndo_snapend and p.
+ */
+u_int
+ether_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int caplen,
+ void (*print_encap_header)(netdissect_options *ndo, const u_char *),
+ const u_char *encap_header_arg)
+{
+ ndo->ndo_protocol = "ether";
+ return (ether_print_common(ndo, p, length, caplen, NULL, 0,
+ print_encap_header, encap_header_arg));
+}
+
+/*
+ * This is the top level routine of the printer. 'p' points
+ * to the ether header of the packet, 'h->len' is the length
+ * of the packet off the wire, and 'h->caplen' is the number
+ * of bytes actually captured.
+ */
+u_int
+ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ const u_char *p)
+{
+ ndo->ndo_protocol = "ether_if";
+ return (ether_print(ndo, p, h->len, h->caplen, NULL, NULL));
+}
+
+/*
+ * This is the top level routine of the printer. 'p' points
+ * to the ether header of the packet, 'h->len' is the length
+ * of the packet off the wire, and 'h->caplen' is the number
+ * of bytes actually captured.
+ *
+ * This is for DLT_NETANALYZER, which has a 4-byte pseudo-header
+ * before the Ethernet header.
+ */
+u_int
+netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ const u_char *p)
+{
+ /*
+ * Fail if we don't have enough data for the Hilscher pseudo-header.
+ */
+ ndo->ndo_protocol = "netanalyzer_if";
+ if (h->caplen < 4) {
+ nd_print_trunc(ndo);
+ return (h->caplen);
+ }
+
+ /* Skip the pseudo-header. */
+ return (4 + ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL));