com.ibm.diameter.packet
Class Avp

java.lang.Object
  extended by com.ibm.diameter.packet.Avp
Direct Known Subclasses:
VsAvp

public class Avp
extends java.lang.Object

The Avp class is used to construct a Diameter Attribute Value Pair (AVP). Diameter AVPs are used in Diameter messages to be the envelopes for individual information elements This Avp class holds an AvpValueUtil which encapsulates the actual data held by this AVP. There are different AvpValueUtil types for each of the Diameter AVP types.

This Avp class is only used by a client application that wishes to use a Raw method for either the Ro or Rf requests. The higher level APIs do not require the usage of the Avp class by the client application.


Field Summary
protected  int avpLength
          Length of the AVP in number of bytes.
static byte M_BIT
          Bit mask for the Mandatory AVP Flag.
static byte P_BIT
          Bit mask for the Encryption on end-to-end security AVP Flag (Obsolete).
static byte R_BITS
          Bit mask for the Reserved fields in the AVP Flag.
static byte V_BIT
          Bit mask for the Vendor Specific AVP Flag.
static byte VOFF_MOFF_POFF
          Non vendor specific, non mandatory, no encryption
static byte VOFF_MOFF_PON
          Non vendor specific, non mandatory, encryption
static byte VOFF_MON_POFF
          Non vendor specific, mandatory, no encryption
static byte VOFF_MON_PON
          Non vendor specific, mandatory, encryption
static byte VON_MOFF_POFF
          Vendor specific, non mandatory, no encryption
static byte VON_MOFF_PON
          Vendor specific, non mandatory, encryption
static byte VON_MON_POFF
          Vendor specific, mandatory, no encryption
static byte VON_MON_PON
          Vendor specific, mandatory, encryption
 
Constructor Summary
Avp()
          Empty constructor for the Avp.
Avp(int avpCode, byte avpFlags, AvpValueUtil avpValue)
          Creates an instance of Avp.
Avp(int avpCode, byte avpFlags, int length, AvpValueUtil avpValue)
          Creates an instance of Avp .
 
Method Summary
 int getAvpCode()
          Returns the AVP code which is used along with the Vendor-Id to uniquely identify this attribute.
 byte getAvpFlags()
          Returns the AVP flags which include the P Bit, M Bit and V Bit.
 int getAvpLength()
          Returns the length of the AVP in octets.
 AvpValueUtil getAvpValueUtil()
          Returns the AvpValueUtil object which is used to read the value of this AVP.
 boolean isMBit()
          Queries whether the Mandatory bit is set on this AVP.
 boolean isPBit()
          Queries whether the P bit is set on this AVP.
 boolean isValid()
          isValid() checks to see if AVP is valid
 boolean isVBit()
          Queries whether the Vendor-Specific bit is set on this AVP.
 void setAvpCode(int avpCode)
          Sets the AVP code.
 void setAvpFlags(byte avpFlags)
          Sets the AVP flags.
 void setAvpLength(int avpLength)
          Sets the length of the AVP in octets.
 void setAvpValueUtil(AvpValueUtil avpValue)
          Sets the AvpValueUtil object which is used to read the value of this AVP.
 void setMBit(boolean value)
          Sets the Mandatory bit on this AVP.
 void setPBit(boolean value)
          Sets the P bit on this AVP.
 void setVBit(boolean value)
          Sets the Vendor-Specific bit on this AVP.
 void toDataOutputStream(java.io.DataOutputStream out)
          Writes the Avp to the DataOutputStream, including the header information and the value of the AVP contained within the AvpValueUtil instance.
 void toDiamWsByteBufferOutputStream(com.ibm.diameter.util.DiamWsByteBufferOutputStream out)
          Writes the Avp to the DiamWsByteBufferOutputStream, including the header information and the value of the AVP contained within the AvpValueUtil instance.
 java.lang.String toString()
          Returns a String representation of the Avp.
 java.lang.String toString2()
          Returns a String representation of the Avp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

avpLength

protected int avpLength
Length of the AVP in number of bytes.


V_BIT

public static final byte V_BIT
Bit mask for the Vendor Specific AVP Flag. The conventional value is 0x80.

See Also:
Constant Field Values

M_BIT

public static final byte M_BIT
Bit mask for the Mandatory AVP Flag. The conventional value is 0x40.

See Also:
Constant Field Values

P_BIT

public static final byte P_BIT
Bit mask for the Encryption on end-to-end security AVP Flag (Obsolete). The conventional value is 0x20.

See Also:
Constant Field Values

R_BITS

public static final byte R_BITS
Bit mask for the Reserved fields in the AVP Flag. The conventional value is 0x1F.

See Also:
Constant Field Values

VOFF_MOFF_POFF

public static final byte VOFF_MOFF_POFF
Non vendor specific, non mandatory, no encryption

See Also:
Constant Field Values

VOFF_MOFF_PON

public static final byte VOFF_MOFF_PON
Non vendor specific, non mandatory, encryption

See Also:
Constant Field Values

VOFF_MON_POFF

public static final byte VOFF_MON_POFF
Non vendor specific, mandatory, no encryption

See Also:
Constant Field Values

VOFF_MON_PON

public static final byte VOFF_MON_PON
Non vendor specific, mandatory, encryption

See Also:
Constant Field Values

VON_MOFF_POFF

public static final byte VON_MOFF_POFF
Vendor specific, non mandatory, no encryption

See Also:
Constant Field Values

VON_MOFF_PON

public static final byte VON_MOFF_PON
Vendor specific, non mandatory, encryption

See Also:
Constant Field Values

VON_MON_POFF

public static final byte VON_MON_POFF
Vendor specific, mandatory, no encryption

See Also:
Constant Field Values

VON_MON_PON

public static final byte VON_MON_PON
Vendor specific, mandatory, encryption

See Also:
Constant Field Values
Constructor Detail

Avp

public Avp()
Empty constructor for the Avp. This constructor should typically not be used.


Avp

public Avp(int avpCode,
           byte avpFlags,
           AvpValueUtil avpValue)
Creates an instance of Avp. Note that the length is not included in this constructor. The length is calculated by getting the length from the AvpValueUtil class and adding the AVP header length to it.

Example:

Avp myAvp = new Avp(AvpConstants.ACCT_APPLICATION_ID, Avp.VOFF_MON_POFF, new AvpValueUtilUnsigned32(0xFFFFFFFF));

Parameters:
avpCode - Identifier of the AVP
avpFlags - Tells the receiver how the attribute should be handled. It is of the form VMPrrrrr. The V, or Vendor-Specific, bit indicates whether the Vendor Id field is present in the header. The M, or Mandatory, bit indicates whether support of this AVP is required or not. The P bit indicates the need for encryption. The P bit is obsolete, and should not be set to 0. The r, or reserved, bits are unused in this release and should be set to 0.
avpValue - An instance of the AvpValueUtil class that contains the value in a form that the class knows how to interpret.

Avp

public Avp(int avpCode,
           byte avpFlags,
           int length,
           AvpValueUtil avpValue)
Creates an instance of Avp .

This constructor in not suggested for use as it overrides the length that is provided in the AvpValueUtil. An inconsistent length may cause unexpected results.

Parameters:
avpCode - Identifier of the AVP
avpFlags - Tells the receiver how the attribute should be handled. It is of the form VMPrrrrr. \ The V, or Vendor-Specific, bit indicates whether the Vendor Id field is present in the header. The \ M, or Mandatory, bit indicates whether support of this AVP is required or not. The P bit indicates \ the need for encryption. The P bit has been made obsolete by the IETF, and should be set to 0. The r, or reserved, bits are unused in this release and should be set to 0.
length - The length of the Avp that is being created.
avpValue - An instance of the AvpValueUtil class that contains the value in a form\ that the class knows how to interpret.
Method Detail

isVBit

public boolean isVBit()
Queries whether the Vendor-Specific bit is set on this AVP.

Returns:
true if the Vendor-Specific bit is set, otherwise false.

isMBit

public boolean isMBit()
Queries whether the Mandatory bit is set on this AVP.

Returns:
true if the Mandatory bit is set, otherwise false.

isPBit

public boolean isPBit()
Queries whether the P bit is set on this AVP.

Returns:
true if the P bit is set, otherwise false.

setVBit

public void setVBit(boolean value)
Sets the Vendor-Specific bit on this AVP.

Parameters:
value - true if this is a Vendor-Specific AVP, otherwise false.

setMBit

public void setMBit(boolean value)
Sets the Mandatory bit on this AVP.

Parameters:
value - true if support for this AVP is required, otherwise false.

setPBit

public void setPBit(boolean value)
Sets the P bit on this AVP.

Parameters:
value - true if this AVP requires encryption for end-to-end security, otherwise false.

getAvpCode

public int getAvpCode()
Returns the AVP code which is used along with the Vendor-Id to uniquely identify this attribute.

Returns:
Returns the The IANA defined code for this Diameter Attribute.

setAvpCode

public void setAvpCode(int avpCode)
Sets the AVP code.

Parameters:
avpCode - The IANA defined code for this Diameter Attribute.

getAvpFlags

public byte getAvpFlags()
Returns the AVP flags which include the P Bit, M Bit and V Bit.

Returns:
Returns the AVP flags as a byte.

setAvpFlags

public void setAvpFlags(byte avpFlags)
Sets the AVP flags.

Parameters:
avpFlags - The AVP flags to set.

getAvpLength

public int getAvpLength()
Returns the length of the AVP in octets. The length includes the AVP header and the the AVP data.

Returns:
Returns the length of the AVP.

setAvpLength

public void setAvpLength(int avpLength)
Sets the length of the AVP in octets. The length includes the AVP header and the the AVP data.

Parameters:
avpLength - The length of the AVP.

getAvpValueUtil

public AvpValueUtil getAvpValueUtil()
Returns the AvpValueUtil object which is used to read the value of this AVP.

Returns:
an instance of AvpValueUtil that contains the data as well as a method to retrieve the data.

setAvpValueUtil

public void setAvpValueUtil(AvpValueUtil avpValue)
Sets the AvpValueUtil object which is used to read the value of this AVP.

Parameters:
avpValue - an instance of AvpValueUtil that contains the data as well as a method to retrieve the data.

isValid

public boolean isValid()
isValid() checks to see if AVP is valid

Checks include: V_Bit must be off for a generic AVP.

Returns:
Returns true if this AVP is valid.

toDiamWsByteBufferOutputStream

public void toDiamWsByteBufferOutputStream(com.ibm.diameter.util.DiamWsByteBufferOutputStream out)
Writes the Avp to the DiamWsByteBufferOutputStream, including the header information and the value of the AVP contained within the AvpValueUtil instance.

Parameters:
out - The output stream to write the Avp to.

toDataOutputStream

public void toDataOutputStream(java.io.DataOutputStream out)
Writes the Avp to the DataOutputStream, including the header information and the value of the AVP contained within the AvpValueUtil instance.

Parameters:
out - The output stream to write the Avp to.

toString

public java.lang.String toString()
Returns a String representation of the Avp.

If the Avp is recognized as having an entry in the internal Avp dictionary, the name of the Avp will be displayed. However, if the Avp is does not contain an entry in the Avp dictionary, the result will be identical output to toString2().

Overrides:
toString in class java.lang.Object
Returns:
String representation of the Avp

toString2

public java.lang.String toString2()
Returns a String representation of the Avp.

This method does not reference any dictionary to produce the string output.

Returns:
String representation of the Avp


Copyright © 2006 IBM Corp. All Rights Reserved.