Class NeighborAdvertisement

  • All Implemented Interfaces:
    IPacket

    public class NeighborAdvertisement
    extends BasePacket
    Implements ICMPv6 Neighbor Advertisement packet format (RFC 4861).
    • Field Detail

      • routerFlag

        protected byte routerFlag
      • solicitedFlag

        protected byte solicitedFlag
      • overrideFlag

        protected byte overrideFlag
      • targetAddress

        protected byte[] targetAddress
    • Constructor Detail

      • NeighborAdvertisement

        public NeighborAdvertisement()
    • Method Detail

      • getRouterFlag

        public byte getRouterFlag()
        Gets router flag.
        Returns:
        the router flag
      • setRouterFlag

        public NeighborAdvertisement setRouterFlag​(byte routerFlag)
        Sets router flag.
        Parameters:
        routerFlag - the router flag to set
        Returns:
        this
      • getSolicitedFlag

        public byte getSolicitedFlag()
        Gets solicited flag.
        Returns:
        the solicited flag
      • setSolicitedFlag

        public NeighborAdvertisement setSolicitedFlag​(byte solicitedFlag)
        Sets solicited flag.
        Parameters:
        solicitedFlag - the solicited flag to set
        Returns:
        this
      • getOverrideFlag

        public byte getOverrideFlag()
        Gets override flag.
        Returns:
        the override flag
      • setOverrideFlag

        public NeighborAdvertisement setOverrideFlag​(byte overrideFlag)
        Sets override flag.
        Parameters:
        overrideFlag - the override flag to set
        Returns:
        this
      • getTargetAddress

        public byte[] getTargetAddress()
        Gets target address.
        Returns:
        the target IPv6 address
      • setTargetAddress

        public NeighborAdvertisement setTargetAddress​(byte[] targetAddress)
        Sets target address.
        Parameters:
        targetAddress - the target IPv6 address to set
        Returns:
        this
      • getOptions

        public List<NeighborDiscoveryOptions.Option> getOptions()
        Gets the Neighbor Discovery Protocol packet options.
        Returns:
        the Neighbor Discovery Protocol packet options
      • addOption

        public NeighborAdvertisement addOption​(byte type,
                                               byte[] data)
        Adds a Neighbor Discovery Protocol packet option.
        Parameters:
        type - the option type
        data - the option data
        Returns:
        this
      • serialize

        public byte[] serialize()
        Description copied from interface: IPacket
        Sets all payloads parent packet if applicable, then serializes this packet and all payloads.
        Returns:
        a byte[] containing this packet and payloads
      • deserializer

        public static Deserializer<NeighborAdvertisement> deserializer()
        Deserializer function for neighbor advertisement packets.
        Returns:
        deserializer function
      • buildNdpAdv

        public static Ethernet buildNdpAdv​(Ip6Address srcIp,
                                           MacAddress srcMac,
                                           Ethernet request)
        Builds an NDP reply based on a request.
        Parameters:
        srcIp - the IP address to use as the reply source
        srcMac - the MAC address to use as the reply source
        request - the Neighbor Solicitation request we got
        Returns:
        an Ethernet frame containing the Neighbor Advertisement reply