Package org.onlab.packet.ndp
Class NeighborAdvertisement
- java.lang.Object
-
- org.onlab.packet.BasePacket
-
- org.onlab.packet.ndp.NeighborAdvertisement
-
- All Implemented Interfaces:
IPacket
public class NeighborAdvertisement extends BasePacket
Implements ICMPv6 Neighbor Advertisement packet format (RFC 4861).
-
-
Field Summary
Fields Modifier and Type Field Description static byte
HEADER_LENGTH
protected static byte
NDP_HOP_LIMIT
protected static byte
NDP_OVERRIDE_FLAG
protected static byte
NDP_SOLICITED_FLAG
protected byte
overrideFlag
protected static byte
RESERVED_CODE
protected byte
routerFlag
protected byte
solicitedFlag
protected byte[]
targetAddress
-
Fields inherited from class org.onlab.packet.BasePacket
parent, payload
-
-
Constructor Summary
Constructors Constructor Description NeighborAdvertisement()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NeighborAdvertisement
addOption(byte type, byte[] data)
Adds a Neighbor Discovery Protocol packet option.static Ethernet
buildNdpAdv(Ip6Address srcIp, MacAddress srcMac, Ethernet request)
Builds an NDP reply based on a request.static Deserializer<NeighborAdvertisement>
deserializer()
Deserializer function for neighbor advertisement packets.boolean
equals(Object obj)
List<NeighborDiscoveryOptions.Option>
getOptions()
Gets the Neighbor Discovery Protocol packet options.byte
getOverrideFlag()
Gets override flag.byte
getRouterFlag()
Gets router flag.byte
getSolicitedFlag()
Gets solicited flag.byte[]
getTargetAddress()
Gets target address.int
hashCode()
byte[]
serialize()
Sets all payloads parent packet if applicable, then serializes this packet and all payloads.NeighborAdvertisement
setOverrideFlag(byte overrideFlag)
Sets override flag.NeighborAdvertisement
setRouterFlag(byte routerFlag)
Sets router flag.NeighborAdvertisement
setSolicitedFlag(byte solicitedFlag)
Sets solicited flag.NeighborAdvertisement
setTargetAddress(byte[] targetAddress)
Sets target address.String
toString()
-
Methods inherited from class org.onlab.packet.BasePacket
clone, getParent, getPayload, resetChecksum, setParent, setPayload
-
-
-
-
Field Detail
-
HEADER_LENGTH
public static final byte HEADER_LENGTH
- See Also:
- Constant Field Values
-
NDP_HOP_LIMIT
protected static final byte NDP_HOP_LIMIT
- See Also:
- Constant Field Values
-
NDP_SOLICITED_FLAG
protected static final byte NDP_SOLICITED_FLAG
- See Also:
- Constant Field Values
-
NDP_OVERRIDE_FLAG
protected static final byte NDP_OVERRIDE_FLAG
- See Also:
- Constant Field Values
-
RESERVED_CODE
protected static final byte RESERVED_CODE
- See Also:
- Constant Field Values
-
routerFlag
protected byte routerFlag
-
solicitedFlag
protected byte solicitedFlag
-
overrideFlag
protected byte overrideFlag
-
targetAddress
protected byte[] targetAddress
-
-
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 typedata
- 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
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBasePacket
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classBasePacket
-
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 sourcesrcMac
- the MAC address to use as the reply sourcerequest
- the Neighbor Solicitation request we got- Returns:
- an Ethernet frame containing the Neighbor Advertisement reply
-
-