public abstract class Message extends Object
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version | Message Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | command flags | Command-Code | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Application-ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Hop-by-Hop Identifier | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | End-to-End Identifier | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... AVPs ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_ERROR |
static int |
FLAG_POTENTIALLY_RETRANSMITTED |
static int |
FLAG_PROXIABLE |
static int |
FLAG_REQUEST |
static int |
FLAGS_MASK |
static int |
HEADER_SIZE |
static int |
VERSION
Diameter version.
|
Modifier | Constructor and Description |
---|---|
protected |
Message(ByteBuffer bb,
com.bea.wcp.diameter.transport.Connection c)
Creates a new Message decoded from the specified message bytes.
|
protected |
Message(Message req,
ResultCode rc)
Creates a new Diameter answer message for the specified request.
|
protected |
Message(Node node,
Command cmd,
int appId,
int hopByHopId,
int endToEndId,
String sessionId)
This constructor is only called by Request when creating a new request.
|
Modifier and Type | Method and Description |
---|---|
void |
addAvp(Attribute attr,
Object value)
Adds a new AVP to the message.
|
void |
addAvp(Avp avp)
Adds a new AVP to the message.
|
void |
addAvp(String name,
Object value)
Adds a new AVP by name to the message.
|
XmlBuffer |
appendXml(XmlBuffer xb) |
abstract void |
commit()
Commits a message currently being sent.
|
static Message |
decode(ByteBuffer bb,
com.bea.wcp.diameter.transport.Connection c)
Decodes the message header from the specified message bytes and connection.
|
void |
decodeAvps(ByteBuffer bb)
Called by Connection to decode message AVPs.
|
ByteBuffer |
encode()
Returns a byte buffer which contains the encoded message bytes.
|
ByteBuffer |
encode(ByteBuffer bb)
Encodes this diameter message to the specified byte buffer.
|
void |
extractAndSetSessionIdAvp() |
int |
getAppId()
Returns the application identifier for this message.
|
static int |
getAppId(ByteBuffer bb) |
Avp |
getAvp(Attribute attr)
Returns the first AVP in the message with the specified attribute.
|
Avp |
getAvp(String name)
Returns the first AVP for the specific attribute name, or null if none
|
AvpList |
getAvpList()
Returns the list of message AVPs.
|
int |
getCode()
Returns the Command code for this message.
|
static int |
getCode(ByteBuffer bb) |
Command |
getCommand()
Returns the Command for this message.
|
com.bea.wcp.diameter.transport.Connection |
getConnection()
If this message was received then returns the connection used to receive
the message.
|
String |
getEffectiveSessionId()
Returns the session id of this message,
or if none exists, looks for one in the original request.
|
int |
getEndToEndId()
Returns the end-to-end identifier for this message.
|
int |
getHopByHopId()
Returns the hop-by-hop identifier for this message.
|
static int |
getLength(ByteBuffer bb) |
String |
getOriginHost()
Returns the value of the Origin-Host AVP.
|
String |
getOriginRealm()
Returns the value of the Origin-Realm AVP.
|
abstract Session |
getSession()
Returns the Session associated with this message, or null if none.
|
String |
getSessionId()
Returns the value of the Session-Id AVP, or null if none.
|
static int |
getVersion(ByteBuffer bb) |
boolean |
isAnswer()
Returns true if this message an answer message.
|
abstract boolean |
isCommitted() |
boolean |
isError()
Returns true if this message is an erorr according to the header flags.
|
boolean |
isPotentiallyRetransmitted()
Returns true if this message has been potentially retransmitted according
to the header flags.
|
boolean |
isProxiable()
Returns true if this message is proxiable according to the header flags.
|
boolean |
isRequest()
Returns true if this message is a request.
|
boolean |
popProxyInfo()
Removes the last proxy info element from this message.
|
void |
preValidate()
Performs initial validation of a message to include validation of AVPs
required to determine if the request/answer should be forwarded.
|
protected void |
preValidateAvp(Avp avp)
Fully decodes and validates the specified AVP.
|
abstract void |
send()
Sends this Diameter message.
|
String |
toLoggableString() |
String |
toString() |
void |
validate()
Validates the message by validating each message AVP.
|
protected void |
validateAvp(Avp avp) |
public static final int HEADER_SIZE
public static final int VERSION
public static final int FLAG_REQUEST
public static final int FLAG_PROXIABLE
public static final int FLAG_ERROR
public static final int FLAG_POTENTIALLY_RETRANSMITTED
public static final int FLAGS_MASK
protected Message(Node node, Command cmd, int appId, int hopByHopId, int endToEndId, String sessionId)
node
- the Diameter node (used for setting origin Avps)cmd
- the request commandappId
- the application identifierhopByHopId
- the hop-by-hop identifierendToEndId
- the end-to-end identifiersessionId
- optional session identifierprotected Message(Message req, ResultCode rc)
req
- the original request messagerc
- the result code for the answerprotected Message(ByteBuffer bb, com.bea.wcp.diameter.transport.Connection c)
bb
- the message bytesc
- the connection which received the messagepublic void decodeAvps(ByteBuffer bb) throws MessageException
bb
- the message body bytesMessageException
- if the message was invalidpublic void preValidate() throws MessageException
MessageException
- if validation failedprotected void preValidateAvp(Avp avp) throws AvpException
avp
- the AVP to be validatedAvpException
- if the AVP was invalidpublic void validate() throws MessageException
MessageException
- if the message was invalidprotected void validateAvp(Avp avp) throws AvpException
AvpException
public ByteBuffer encode(ByteBuffer bb)
bb
- the output byte bufferpublic ByteBuffer encode()
public Avp getAvp(Attribute attr)
attr
- the AVP attributepublic Avp getAvp(String name)
name
- the attribute namepublic void addAvp(Avp avp)
avp
- the AVP to be addedpublic void addAvp(Attribute attr, Object value)
attr
- the AVP Attributevalue
- the AVP valuepublic void addAvp(String name, Object value)
name
- the AVP attribute namevalue
- the AVP valuepublic int getCode()
public Command getCommand()
public final boolean isRequest()
public final boolean isAnswer()
public boolean isProxiable()
public boolean isError()
public boolean isPotentiallyRetransmitted()
public int getAppId()
public int getHopByHopId()
public int getEndToEndId()
public AvpList getAvpList()
public String getSessionId()
public String getEffectiveSessionId()
public String getOriginHost()
public String getOriginRealm()
public abstract Session getSession()
public com.bea.wcp.diameter.transport.Connection getConnection()
public abstract void send() throws IOException
IOException
- if an I/O error occurred while sendingpublic abstract void commit() throws IOException
IOException
public abstract boolean isCommitted()
public boolean popProxyInfo()
public static Message decode(ByteBuffer bb, com.bea.wcp.diameter.transport.Connection c)
bb
- the message bytes to be decodedc
- the connection used to receive the messageIndexOutOfBoundsException
- if the message length was less than
HEADER_SIZEpublic static int getLength(ByteBuffer bb)
public static int getCode(ByteBuffer bb)
public static int getVersion(ByteBuffer bb)
public static int getAppId(ByteBuffer bb)
public String toLoggableString()
public void extractAndSetSessionIdAvp()