SunSPOT API V6.0


com.sun.spot.ipv6
Class IPv6Packet

java.lang.Object
  extended by com.sun.spot.ipv6.GenericPacket
      extended by com.sun.spot.ipv6.IPv6Packet
Direct Known Subclasses:
ICMP6Packet, TCPPacket, UDPPacket

public class IPv6Packet
extends GenericPacket

Basic IPv6 packet that includes an IPv6 header and data payload

Author:
Pete St. Pierre

Field Summary
static boolean debug
           
static int HEADER_SIZE
           
 
Fields inherited from class com.sun.spot.ipv6.GenericPacket
bytes, headerSize, headerStart, length, link_destination, link_source
 
Constructor Summary
IPv6Packet()
          Creates a new instance of IP6Packet
IPv6Packet(byte[] src, byte[] dest, int payloadSize)
          Create the full IP packet and initialize the IP header
IPv6Packet(byte[] b, int start, int hSize)
          Create an IP6Packet with an initial buffer
IPv6Packet(int totalSize)
          Creates a new IP6Packet object.
 
Method Summary
 int calculatePseudoHeaderChecksum()
          Calcualte the checksum of the IPv6 pseudo header
 void copy(int pos, byte[] dst, int dstPos, int len)
           
 String debug()
          Returns a String representation of the IPv6 protocol header, including labels for readability and debugging.
 short get16(int pos)
           
 int get32(int pos)
           
 byte getData(int pos)
           
 byte[] getDstAddress()
          Gets the value of the destination address field of this IPv6 packet
 int getFlowLabel()
          Gets the flow label field of the IPv6 protocol header
 short getHopLimit()
          Get the hop limit field from the IPv6 protocol header
 IIPNetworkInterface getInterface()
           
 int getNextHeader()
          Gets the value of the next header field in the IPv6 protocol header.
 String getNextHeaderString(int hdr)
          Returns a string representation of the next header value.
 int getPacketEnd()
          Returns the index of the last byte in the payload buffer
 byte[] getPayloadBytes()
           
 int getPayloadLength()
          Returns the length of the payload portion of the packet.
 byte[] getSrcAddress()
          Gets the value of the source address field of this IPv6 packet
 int getTotalLength()
          Returns the total length of this packet.
 short getTrafficClass()
          Get the Traffic class in the IPv6 protocol header
 int getVersion()
          Returns the IP version number of this packet.
 void resetHopLimit()
           
 void set16(int pos, short val)
           
 void set32(int pos, int val)
           
 void setChecksum()
          Print an error if someone tries to set the checksum on a raw IP packet.
 void setData(int pos, byte val)
           
 void setDstAddress(byte[] addr)
          Sets the value of the destination address field of this IPv6 packet
 void setFlowLabel(int flow)
          Sets the flow label field of the IPv6 protocol header
 void setHopLimit(short hops)
          Set the hop limit field from the IPv6 protocol header
 void setInterface(IIPNetworkInterface iface)
           
 void setNextHeader(byte hdr)
          Sets the next header value in the IPv6 protocol header
 void setPayloadLength(int len)
          Sets the length field of the IP Header
 void setSrcAddress(byte[] addr)
          Sets the value of the source address field of this IPv6 packet
 void setTrafficClass(int c)
          Sets the traffic class value in the IPv6 protocol header
 void setVersion()
          Sets the IP Version field of the packet
 String toString()
          Returns a string representation of this IPv6 packet.
 
Methods inherited from class com.sun.spot.ipv6.GenericPacket
getBytes, getDataOffset, getDataSize, getHeaderOffset, getHeaderSize, getLinkDestination, getLinkSource, setLinkDestination, setLinkSource, toBytes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static final boolean debug

HEADER_SIZE

public static final int HEADER_SIZE
See Also:
Constant Field Values
Constructor Detail

IPv6Packet

public IPv6Packet()
Creates a new instance of IP6Packet


IPv6Packet

public IPv6Packet(byte[] src,
                  byte[] dest,
                  int payloadSize)
Create the full IP packet and initialize the IP header

Parameters:
src - Source Address of this packet
dest - Destination Address of this packet
payloadSize - The total IP payload size

IPv6Packet

public IPv6Packet(int totalSize)
Creates a new IP6Packet object.

Parameters:
totalSize - The total size of this packet.

IPv6Packet

public IPv6Packet(byte[] b,
                  int start,
                  int hSize)
Create an IP6Packet with an initial buffer

Parameters:
b - The buffer
start - The index at which point the header starts.
hSize - The size of the header in bytes
Method Detail

getVersion

public int getVersion()
Returns the IP version number of this packet. It should always be '6'.

Returns:
IP protocol version number.

setVersion

public void setVersion()
Sets the IP Version field of the packet


resetHopLimit

public void resetHopLimit()

getPayloadLength

public int getPayloadLength()
Returns the length of the payload portion of the packet. This may include other protocol headers from higher level protocols.

Returns:
The length, in bytes, of the payload

getTotalLength

public int getTotalLength()
Returns the total length of this packet.

Returns:
The length, in bytes, of the full packet including headers

getPayloadBytes

public byte[] getPayloadBytes()

copy

public void copy(int pos,
                 byte[] dst,
                 int dstPos,
                 int len)

getData

public byte getData(int pos)

setData

public void setData(int pos,
                    byte val)

get16

public short get16(int pos)

set16

public void set16(int pos,
                  short val)

get32

public int get32(int pos)

set32

public void set32(int pos,
                  int val)

getPacketEnd

public int getPacketEnd()
Returns the index of the last byte in the payload buffer

Returns:
the index of the last byte of the packet

setPayloadLength

public void setPayloadLength(int len)
Sets the length field of the IP Header

Parameters:
len - The number of bytes in the IP Payload portion of the packet.

getTrafficClass

public short getTrafficClass()
Get the Traffic class in the IPv6 protocol header

Returns:
the value of the traffic class field of the IPv6 protocol header

setTrafficClass

public void setTrafficClass(int c)
Sets the traffic class value in the IPv6 protocol header

Parameters:
c - the traffic class of this IPv6 packet

getFlowLabel

public int getFlowLabel()
Gets the flow label field of the IPv6 protocol header

Returns:
the value of the flow label field of the IPv6 protocol header

setFlowLabel

public void setFlowLabel(int flow)
Sets the flow label field of the IPv6 protocol header

Parameters:
flow - the new flow label for this IPv6 packet

getNextHeader

public int getNextHeader()
Gets the value of the next header field in the IPv6 protocol header. An index into the payload to find the start of the next header.

Returns:
The value of the next header field.

setNextHeader

public void setNextHeader(byte hdr)
Sets the next header value in the IPv6 protocol header

Parameters:
hdr - The index into the packet where the next protocol header begins.

getHopLimit

public short getHopLimit()
Get the hop limit field from the IPv6 protocol header

Returns:
the value of the hop limit field of this IPv6 packet

setHopLimit

public void setHopLimit(short hops)
Set the hop limit field from the IPv6 protocol header

Parameters:
hops - the maximum number of hops for this IPv6 packet

getSrcAddress

public byte[] getSrcAddress()
Gets the value of the source address field of this IPv6 packet

Returns:
A Inet6Address object. The source address of this packet

setSrcAddress

public void setSrcAddress(byte[] addr)
Sets the value of the source address field of this IPv6 packet

Parameters:
addr - the new source address of this IPv6 packet

getDstAddress

public byte[] getDstAddress()
Gets the value of the destination address field of this IPv6 packet

Returns:
A byte[] representing the address. The destination address of this packet

setDstAddress

public void setDstAddress(byte[] addr)
Sets the value of the destination address field of this IPv6 packet

Parameters:
addr - the new destination address of this IPv6 packet

calculatePseudoHeaderChecksum

public int calculatePseudoHeaderChecksum()
Calcualte the checksum of the IPv6 pseudo header


getNextHeaderString

public String getNextHeaderString(int hdr)
Returns a string representation of the next header value. Mostly used as a debugging tool.

Parameters:
hdr - The next header value to be translated.
Returns:
A String object. A String representation of the next header value.

setInterface

public void setInterface(IIPNetworkInterface iface)

getInterface

public IIPNetworkInterface getInterface()

toString

public String toString()
Returns a string representation of this IPv6 packet. The string is a space separated set of hex values for each byte, in rows of 8 bytes per line. No other formating is done to the bytes.

Overrides:
toString in class Object
Returns:
A String object. A string of hex values representing the contents of the IPv6 packet.

debug

public String debug()
Returns a String representation of the IPv6 protocol header, including labels for readability and debugging.

Returns:
a decoded string version of this packet

setChecksum

public void setChecksum()
Print an error if someone tries to set the checksum on a raw IP packet. Classes that extend IPv6Packet will override this method

Specified by:
setChecksum in class GenericPacket

SunSPOT API V6.0


Copyright © 2006-2010 Oracle. All Rights Reserved.