NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

gov.nist.javax.sip.stack
Class UDPMessageChannel

java.lang.Object
  extended by gov.nist.javax.sip.stack.MessageChannel
      extended by gov.nist.javax.sip.stack.UDPMessageChannel
All Implemented Interfaces:
ParseExceptionListener, RawMessageChannel, Runnable

public class UDPMessageChannel
extends MessageChannel
implements ParseExceptionListener, Runnable, RawMessageChannel

This is the UDP Message handler that gets created when a UDP message needs to be processed. The message is processed by creating a String Message parser and invoking it on the message read from the UDP socket. The parsed structure is handed off via a SIP stack request for further processing. This stack structure isolates the message handling logic from the mechanics of sending and recieving messages (which could be either udp or tcp.

Version:
1.2 $Revision: 1.60 $ $Date: 2009/08/16 17:28:27 $
Author:
M. Ranganathan

Method Summary
 void close()
          Close the message channel.
 boolean equals(Object other)
          Compare two UDP Message channels for equality.
 String getHost()
          get the stack address for the stack that received this message.
 String getKey()
          Generate a key which identifies the message channel.
 String getPeerAddress()
          get the address of the host that sent me the message
 String getPeerName()
          get the name (address) of the host that sent me the message
 InetAddress getPeerPacketSourceAddress()
           
 int getPeerPacketSourcePort()
           
 int getPeerPort()
          Get the sender port ( the port of the other end that sent me the message).
 String getPeerProtocol()
           
 int getPort()
          get the port.
 SIPTransactionStack getSIPStack()
          get the stack pointer.
 String getTransport()
          Return a transport string.
 String getViaHost()
          Get the logical originator of the message (from the top via header).
 int getViaPort()
          Get the logical port of the message orginator (from the top via hdr).
 void handleException(ParseException ex, SIPMessage sipMessage, Class hdrClass, String header, String message)
          Implementation of the ParseExceptionListener interface.
 boolean isReliable()
          Returns "false" as this is an unreliable transport.
 boolean isSecure()
          UDP is not a secure protocol.
 void processMessage(SIPMessage sipMessage)
          Actually proces the parsed message.
 void run()
          Run method specified by runnnable.
 void sendMessage(SIPMessage sipMessage)
          Return a reply from a pre-constructed reply.
 
Methods inherited from class gov.nist.javax.sip.stack.MessageChannel
getHostPort, getKey, getKey, getMessageProcessor, getPeerHostPort, getRawIpSourceAddress, getViaHeader, getViaHostPort, logResponse, sendMessage, sendMessage
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

run

public void run()
Run method specified by runnnable.

Specified by:
run in interface Runnable

processMessage

public void processMessage(SIPMessage sipMessage)
Actually proces the parsed message.

Specified by:
processMessage in interface RawMessageChannel
Parameters:
sipMessage -

handleException

public void handleException(ParseException ex,
                            SIPMessage sipMessage,
                            Class hdrClass,
                            String header,
                            String message)
                     throws ParseException
Implementation of the ParseExceptionListener interface.

Specified by:
handleException in interface ParseExceptionListener
Parameters:
ex - Exception that is given to us by the parser.
sipMessage - -- sip message being processed.
header - -- header/RL/SL text being parsed.
message - -- message where this header was detected.
Throws:
ParseException - If we choose to reject the header or message.

sendMessage

public void sendMessage(SIPMessage sipMessage)
                 throws IOException
Return a reply from a pre-constructed reply. This sends the message back to the entity who caused us to create this channel in the first place.

Specified by:
sendMessage in class MessageChannel
Parameters:
sipMessage - Message string to send.
Throws:
IOException - If there is a problem with sending the message.

getSIPStack

public SIPTransactionStack getSIPStack()
get the stack pointer.

Specified by:
getSIPStack in class MessageChannel
Returns:
The sip stack for this channel.

getTransport

public String getTransport()
Return a transport string.

Specified by:
getTransport in class MessageChannel
Returns:
the string "udp" in this case.

getHost

public String getHost()
get the stack address for the stack that received this message.

Overrides:
getHost in class MessageChannel
Returns:
The stack address for our sipStack.

getPort

public int getPort()
get the port.

Overrides:
getPort in class MessageChannel
Returns:
Our port (on which we are getting datagram packets).

getPeerName

public String getPeerName()
get the name (address) of the host that sent me the message

Returns:
The name of the sender (from the datagram packet).

getPeerAddress

public String getPeerAddress()
get the address of the host that sent me the message

Specified by:
getPeerAddress in class MessageChannel
Returns:
The senders ip address.

equals

public boolean equals(Object other)
Compare two UDP Message channels for equality.

Overrides:
equals in class Object
Parameters:
other - The other message channel with which to compare oursleves.

getKey

public String getKey()
Description copied from class: MessageChannel
Generate a key which identifies the message channel. This allows us to cache the message channel.

Specified by:
getKey in class MessageChannel

getPeerPacketSourcePort

public int getPeerPacketSourcePort()
Specified by:
getPeerPacketSourcePort in class MessageChannel

getPeerPacketSourceAddress

public InetAddress getPeerPacketSourceAddress()
Specified by:
getPeerPacketSourceAddress in class MessageChannel

getViaHost

public String getViaHost()
Get the logical originator of the message (from the top via header).

Specified by:
getViaHost in class MessageChannel
Returns:
topmost via header sentby field

getViaPort

public int getViaPort()
Get the logical port of the message orginator (from the top via hdr).

Specified by:
getViaPort in class MessageChannel
Returns:
the via port from the topmost via header.

isReliable

public boolean isReliable()
Returns "false" as this is an unreliable transport.

Specified by:
isReliable in class MessageChannel
Returns:
True if reliable, false if not.

isSecure

public boolean isSecure()
UDP is not a secure protocol.

Specified by:
isSecure in class MessageChannel

getPeerPort

public int getPeerPort()
Description copied from class: MessageChannel
Get the sender port ( the port of the other end that sent me the message).

Specified by:
getPeerPort in class MessageChannel

getPeerProtocol

public String getPeerProtocol()

close

public void close()
Close the message channel.

Specified by:
close in class MessageChannel

NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

A product of the NIST/ITL Advanced Networking Technologies Division.
See conditions of use.
Submit a bug report or feature request.