if (srcBuf.getLinkLayerHeader().getDestinationAddress().isBroadcast()) {
return;
}
// Gets the original IP header
final IPv4Header origIpHdr = (IPv4Header) srcBuf.getNetworkLayerHeader();
// Do not respond to networklayer broadcast/multicast messages
if (origIpHdr.getDestination().isBroadcast() || origIpHdr.getDestination().isMulticast()) {
return;
}
final int tos = 0;
final int ttl = 0xFF;
final IPv4Address dstAddr = origIpHdr.getSource();
// Build the response ICMP header
final ICMPHeader icmpHdr = new ICMPUnreachableHeader(code);
// Build the response IP header
final IPv4Header ipHdr = new IPv4Header(tos, ttl, IPv4Constants.IPPROTO_ICMP, dstAddr, 0);
// Unpull the original transportlayer header
srcBuf.unpull(srcBuf.getTransportLayerHeader().getLength());
// Unpull the original IP header