Module org.jnetpcap

Enum Class PcapDlt

java.lang.Object
java.lang.Enum<PcapDlt>
org.jnetpcap.constant.PcapDlt
All Implemented Interfaces:
Serializable, Comparable<PcapDlt>, Constable, IntSupplier

public enum PcapDlt extends Enum<PcapDlt> implements IntSupplier

Constants that represent the Pcap's Payload Link Type assignments. The most popular constant is the EN10MB (alternatively DLT_EN10MB) which represents Ethernet2 based physical medium. This includes 10, 100, and 1000 mega-bit ethernets.

There are 2 tables within PcapDLT enum structure. First is the full table of enum constants, and then there is a duplicate table containing public final static int of contants, prefixed with DLT_. Also the enum constant's field value is public which means that integer DLT constant can also be access using the field directly.

Here are 4 basic of how you can use DLT constants in various ways.

Accessing the int DLT value using an enum constant

 int dlt = pcap.datalink(); // Get DLT value from open Pcap capture
 if (dlt == PcapDLT.EN10MB.value) {
        // Do something
 }
 
 // Also can use this more formal approach
 
 if (PcapDLT.EN10MB.equals(dlt)) {
        // Do something
 }
 

Accessing the int DLT value from integer constants table

 int dlt = pcap.datalink(); // Get DLT value from open Pcap capture
 if (dlt == PcapDLT.DLT_EN10MB) {
        // Do something
 }
 

Converting integer DLT value into a constant

 int dlt = pcap.datalink(); // Get DLT value from open Pcap capture
 PcapDLT enumConst = PcapDLT.valueOf(dlt);
 System.out.println("The Payload Link Type is " + enumConst + " described as " +
                enumConst.description);
 

Converting string DLT name into a constant

 PcapDLT enumConst = PcapDLT.valueOf("EN10MB");
 System.out.println("The Payload Link Type value is " + enumConst.value);
 
Author:
Mark Bednarczyk, Sly Technologies, Inc.