org.pcap4j.packet.IcmpV4InformationRequestPacket Maven / Gradle / Ivy
/*_##########################################################################
_##
_## Copyright (C) 2012-2014 Pcap4J.org
_##
_##########################################################################
*/
package org.pcap4j.packet;
import org.pcap4j.util.ByteArrays;
/**
* @author Kaito Yamada
* @since pcap4j 0.9.11
*/
public final class IcmpV4InformationRequestPacket extends IcmpIdentifiablePacket {
/** */
private static final long serialVersionUID = 840757374756962085L;
private final IcmpV4InformationRequestHeader header;
/**
* A static factory method. This method validates the arguments by {@link
* ByteArrays#validateBounds(byte[], int, int)}, which may throw exceptions undocumented here.
*
* @param rawData rawData
* @param offset offset
* @param length length
* @return a new IcmpV4InformationRequestPacket object.
* @throws IllegalRawDataException if parsing the raw data fails.
*/
public static IcmpV4InformationRequestPacket newPacket(byte[] rawData, int offset, int length)
throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
return new IcmpV4InformationRequestPacket(rawData, offset, length);
}
private IcmpV4InformationRequestPacket(byte[] rawData, int offset, int length)
throws IllegalRawDataException {
this.header = new IcmpV4InformationRequestHeader(rawData, offset, length);
}
private IcmpV4InformationRequestPacket(Builder builder) {
super(builder);
this.header = new IcmpV4InformationRequestHeader(builder);
}
@Override
public IcmpV4InformationRequestHeader getHeader() {
return header;
}
@Override
public Builder getBuilder() {
return new Builder(this);
}
/**
* @author Kaito Yamada
* @since pcap4j 0.9.11
*/
public static final class Builder extends org.pcap4j.packet.IcmpIdentifiablePacket.Builder {
/** */
public Builder() {}
private Builder(IcmpV4InformationRequestPacket packet) {
super(packet);
}
@Override
public Builder identifier(short identifier) {
super.identifier(identifier);
return this;
}
@Override
public Builder sequenceNumber(short sequenceNumber) {
super.sequenceNumber(sequenceNumber);
return this;
}
@Override
public IcmpV4InformationRequestPacket build() {
return new IcmpV4InformationRequestPacket(this);
}
}
/**
* @author Kaito Yamada
* @since pcap4j 0.9.11
*/
public static final class IcmpV4InformationRequestHeader extends IcmpIdentifiableHeader {
/*
* 0 15
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Identifier |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Sequence Number |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
/** */
private static final long serialVersionUID = 5499456155277110739L;
private IcmpV4InformationRequestHeader(byte[] rawData, int offset, int length)
throws IllegalRawDataException {
super(rawData, offset, length);
}
private IcmpV4InformationRequestHeader(Builder builder) {
super(builder);
}
@Override
protected String getHeaderName() {
return "ICMPv4 Information Request Header";
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy