summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-09-14 01:09:53 -0700
committerGuy Harris <guy@alum.mit.edu>2011-09-14 01:10:25 -0700
commitcc39563c02bdd3b60420f64f5507ed1300cbf41c (patch)
tree503c5f9da670206e951c5226ea7b94ebc3405d13
parent51d2e51ff205a9d61b89aab0d682257b709ee043 (diff)
downloadlibpcap-cc39563c02bdd3b60420f64f5507ed1300cbf41c.tar.gz
Add link-layer types for Hilscher Ethernet-capture devices.
Those devices (netAnalyzer PCI card and netAnalyzer box) add a 4-byte pseudo-header before the Ethernet header, and also support a "transparent" mode where the Ethernet preamble and SFD show up between the pseudo-header and Ethernet header.
-rw-r--r--gencode.c30
-rw-r--r--pcap-common.c26
-rw-r--r--pcap.c2
-rw-r--r--pcap/bpf.h22
4 files changed, 79 insertions, 1 deletions
diff --git a/gencode.c b/gencode.c
index 68117f17..6fcc2326 100644
--- a/gencode.c
+++ b/gencode.c
@@ -1618,6 +1618,20 @@ init_linktype(p)
off_nl = -1;
off_nl_nosnap = -1;
return;
+
+ case DLT_ETHERNET_HILSCHER:
+ off_linktype = 16; /* includes 4-byte pseudo-header */
+ off_macpl = 18; /* pseudo-header+Ethernet header length */
+ off_nl = 0; /* Ethernet II */
+ off_nl_nosnap = 3; /* 802.3+802.2 */
+ return;
+
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
+ off_linktype = 24; /* includes 4-byte pseudo-header+preamble+SFD */
+ off_macpl = 26; /* pseudo-header+preamble+SFD+Ethernet header length */
+ off_nl = 0; /* Ethernet II */
+ off_nl_nosnap = 3; /* 802.3+802.2 */
+ return;
}
bpf_error("unknown data link type %d", linktype);
/* NOTREACHED */
@@ -3089,6 +3103,8 @@ gen_linktype(proto)
switch (linktype) {
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
return gen_ether_linktype(proto);
/*NOTREACHED*/
break;
@@ -4850,6 +4866,8 @@ gen_gateway(eaddr, alist, proto, dir)
case Q_RARP:
switch (linktype) {
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
b0 = gen_ehostop(eaddr, Q_OR);
break;
case DLT_FDDI:
@@ -6221,6 +6239,8 @@ gen_scode(name, q)
switch (linktype) {
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
bpf_error(
@@ -6740,6 +6760,8 @@ gen_ecode(eaddr, q)
if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) {
switch (linktype) {
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
return gen_ehostop(eaddr, (int)q.dir);
case DLT_FDDI:
return gen_fhostop(eaddr, (int)q.dir);
@@ -7343,6 +7365,8 @@ gen_broadcast(proto)
case DLT_ARCNET_LINUX:
return gen_ahostop(abroadcast, Q_DST);
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
return gen_ehostop(ebroadcast, Q_DST);
case DLT_FDDI:
return gen_fhostop(ebroadcast, Q_DST);
@@ -7438,6 +7462,8 @@ gen_multicast(proto)
/* all ARCnet multicasts use the same address */
return gen_ahostop(abroadcast, Q_DST);
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
/* ether[0] & 1 != 0 */
return gen_mac_multicast(0);
case DLT_FDDI:
@@ -8064,6 +8090,8 @@ gen_vlan(vlan_num)
switch (linktype) {
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
/* check for VLAN */
b0 = gen_cmp(OR_LINK, off_linktype, BPF_H,
(bpf_int32)ETHERTYPE_8021Q);
@@ -8127,6 +8155,8 @@ gen_mpls(label_num)
case DLT_C_HDLC: /* fall through */
case DLT_EN10MB:
+ case DLT_ETHERNET_HILSCHER:
+ case DLT_ETHERNET_HILSCHER_TRANSPARENT:
b0 = gen_linktype(ETHERTYPE_MPLS);
break;
diff --git a/pcap-common.c b/pcap-common.c
index d0a053c5..1bba068e 100644
--- a/pcap-common.c
+++ b/pcap-common.c
@@ -787,6 +787,26 @@
*/
#define LINKTYPE_NFLOG 239
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
+ * for Ethernet packets with a 4-byte pseudo-header and always
+ * with the payload including the FCS.
+ *
+ * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
+ */
+#define LINKTYPE_ETHERNET_HILSCHER 240
+
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
+ * for Ethernet packets with a 4-byte pseudo-header and FCS and
+ * with the Ethernet header preceded by 7 bytes of preamble and
+ * 1 byte of SFD.
+ *
+ * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
+ */
+#define LINKTYPE_ETHERNET_HILSCHER_TRANSPARENT 241
+
+
static struct linktype_map {
int dlt;
int linktype;
@@ -1162,6 +1182,12 @@ static struct linktype_map {
/* Linux NetFilter LOG messages */
{ DLT_NFLOG, LINKTYPE_NFLOG },
+ /* Ethernet with Hilscher pseudo-header */
+ { DLT_ETHERNET_HILSCHER, LINKTYPE_ETHERNET_HILSCHER },
+
+ /* Ethernet with Hilscher pseudo-header and preamble/SFD */
+ { DLT_ETHERNET_HILSCHER_TRANSPARENT, LINKTYPE_ETHERNET_HILSCHER_TRANSPARENT },
+
{ -1, -1 }
};
diff --git a/pcap.c b/pcap.c
index 7c7c8133..4f2b2cd0 100644
--- a/pcap.c
+++ b/pcap.c
@@ -862,6 +862,8 @@ static struct dlt_choice dlt_choices[] = {
DLT_CHOICE(DLT_DVB_CI, "DVB-CI"),
DLT_CHOICE(DLT_JUNIPER_ATM_CEMIC, "Juniper ATM CEMIC"),
DLT_CHOICE(DLT_NFLOG, "Linux netfilter log messages"),
+ DLT_CHOICE(DLT_ETHERNET_HILSCHER, "Ethernet with Hilscher pseudo-header"),
+ DLT_CHOICE(DLT_ETHERNET_HILSCHER_TRANSPARENT, "Ethernet with Hilscher pseudo-header and preamble/SFD"),
DLT_CHOICE_SENTINEL
};
diff --git a/pcap/bpf.h b/pcap/bpf.h
index 8b2a732e..1ff8f288 100644
--- a/pcap/bpf.h
+++ b/pcap/bpf.h
@@ -1039,7 +1039,27 @@ struct bpf_program {
* Requested by Jakub Zawadzki <darkjames-ws@darkjames.pl>
*/
#define DLT_NFLOG 239
-
+
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
+ * for Ethernet packets with a 4-byte pseudo-header and always
+ * with the payload including the FCS.
+ *
+ * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
+ */
+#define DLT_ETHERNET_HILSCHER 240
+
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH link-layer type
+ * for Ethernet packets with a 4-byte pseudo-header and FCS and
+ * with the Ethernet header preceded by 7 bytes of preamble and
+ * 1 byte of SFD.
+ *
+ * Requested by Holger P. Frommer <HPfrommer@hilscher.com>
+ */
+#define DLT_ETHERNET_HILSCHER_TRANSPARENT 241
+
+
/*
* DLT and savefile link type values are split into a class and
* a member of that class. A class value of 0 indicates a regular