gov.nist.javax.sip.stack
Class MessageChannel

java.lang.Object
  extended by gov.nist.javax.sip.stack.MessageChannel
Direct Known Subclasses:
ConnectionOrientedMessageChannel, SIPTransaction, UDPMessageChannel

public abstract class MessageChannel
extends Object

Message channel abstraction for the SIP stack.

Version:
1.2 $Revision: 1.40 $ $Date: 2010-12-02 22:44:53 $
Author:
M. Ranganathan
Contains additions for support of symmetric NAT contributed by Hagai.

Field Summary
protected  MessageProcessor messageProcessor
          Message processor to whom I belong (if set).
protected  int useCount
           
 
Constructor Summary
MessageChannel()
           
 
Method Summary
abstract  void close()
          Close the message channel.
protected  String createBadReqRes(String badReq, ParseException pe)
          Creates a response to a bad request (ie one that causes a ParseException)
 SIPClientTransaction getEncapsulatedClientTransaction()
           
 String getHost()
          Get the host of this message channel.
 HostPort getHostPort()
          Get the hostport structure of this message channel.
abstract  String getKey()
          Generate a key which identifies the message channel.
static String getKey(HostPort hostPort, String transport)
          Generate a key given host and port.
static String getKey(InetAddress inetAddr, int port, String transport)
          generate a key given the inet address port and transport.
 MessageProcessor getMessageProcessor()
          Get the message processor.
abstract  String getPeerAddress()
          Get the peer address of the machine that sent us this message.
 HostPort getPeerHostPort()
          Get the peer host and port.
protected abstract  InetAddress getPeerInetAddress()
           
abstract  InetAddress getPeerPacketSourceAddress()
           
abstract  int getPeerPacketSourcePort()
           
abstract  int getPeerPort()
          Get the sender port ( the port of the other end that sent me the message).
protected abstract  String getPeerProtocol()
           
 int getPort()
          Get port of this message channel.
 String getRawIpSourceAddress()
          Convenience function to get the raw IP source address of a SIP message as a String.
abstract  SIPTransactionStack getSIPStack()
          Get the SIPStack object from this message channel.
abstract  String getTransport()
          Get transport string of this message channel.
 Via getViaHeader()
          Get the Via header for this transport.
abstract  String getViaHost()
          Get the host for a viaHeader.
 HostPort getViaHostPort()
          Get the via header host:port structure.
abstract  int getViaPort()
          Get the port to assign for the via header of an outgoing message.
abstract  boolean isReliable()
          Get whether this channel is reliable or not.
abstract  boolean isSecure()
          Return true if this is a secure channel.
 void logMessage(SIPMessage sipMessage, InetAddress address, int port, long time)
          Log a message sent to an address and port via the default interface.
 void logResponse(SIPResponse sipResponse, long receptionTime, String status)
          Log a response received at this message channel.
protected abstract  void sendMessage(byte[] message, InetAddress receiverAddress, int receiverPort, boolean reconnectFlag)
          Send the message (after it has been formatted), to a specified address and a specified port
abstract  void sendMessage(SIPMessage sipMessage)
          Send the message (after it has been formatted)
 void sendMessage(SIPMessage sipMessage, Hop hop)
          Send a formatted message to the specified target.
 void sendMessage(SIPMessage sipMessage, InetAddress receiverAddress, int receiverPort)
          Send a message given SIP message.
 void setEncapsulatedClientTransaction(SIPClientTransaction transaction)
           
protected  void uncache()
          Hook method, overridden by subclasses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useCount

protected int useCount

messageProcessor

protected transient MessageProcessor messageProcessor
Message processor to whom I belong (if set).

Constructor Detail

MessageChannel

public MessageChannel()
Method Detail

uncache

protected void uncache()
Hook method, overridden by subclasses


close

public abstract void close()
Close the message channel.


getSIPStack

public abstract SIPTransactionStack getSIPStack()
Get the SIPStack object from this message channel.

Returns:
SIPStack object of this message channel

getTransport

public abstract String getTransport()
Get transport string of this message channel.

Returns:
Transport string of this message channel.

isReliable

public abstract boolean isReliable()
Get whether this channel is reliable or not.

Returns:
True if reliable, false if not.

isSecure

public abstract boolean isSecure()
Return true if this is a secure channel.


sendMessage

public abstract void sendMessage(SIPMessage sipMessage)
                          throws IOException
Send the message (after it has been formatted)

Parameters:
sipMessage - Message to send.
Throws:
IOException

getPeerAddress

public abstract String getPeerAddress()
Get the peer address of the machine that sent us this message.

Returns:
a string contianing the ip address or host name of the sender of the message.

getPeerInetAddress

protected abstract InetAddress getPeerInetAddress()

getPeerProtocol

protected abstract String getPeerProtocol()

getPeerPort

public abstract int getPeerPort()
Get the sender port ( the port of the other end that sent me the message).


getPeerPacketSourcePort

public abstract int getPeerPacketSourcePort()

getPeerPacketSourceAddress

public abstract InetAddress getPeerPacketSourceAddress()

getKey

public abstract String getKey()
Generate a key which identifies the message channel. This allows us to cache the message channel.


getViaHost

public abstract String getViaHost()
Get the host for a viaHeader.


getViaPort

public abstract int getViaPort()
Get the port to assign for the via header of an outgoing message.


sendMessage

protected abstract void sendMessage(byte[] message,
                                    InetAddress receiverAddress,
                                    int receiverPort,
                                    boolean reconnectFlag)
                             throws IOException
Send the message (after it has been formatted), to a specified address and a specified port

Parameters:
message - Message to send.
receiverAddress - Address of the receiver.
receiverPort - Port of the receiver.
Throws:
IOException

getHost

public String getHost()
Get the host of this message channel.

Returns:
host of this messsage channel.

getPort

public int getPort()
Get port of this message channel.

Returns:
Port of this message channel.

sendMessage

public void sendMessage(SIPMessage sipMessage,
                        Hop hop)
                 throws IOException
Send a formatted message to the specified target.

Parameters:
sipMessage - Message to send.
hop - hop to send it to.
Throws:
IOException - If there is an error sending the message

sendMessage

public void sendMessage(SIPMessage sipMessage,
                        InetAddress receiverAddress,
                        int receiverPort)
                 throws IOException
Send a message given SIP message.

Parameters:
sipMessage - is the messge to send.
receiverAddress - is the address to which we want to send
receiverPort - is the port to which we want to send
Throws:
IOException

getRawIpSourceAddress

public String getRawIpSourceAddress()
Convenience function to get the raw IP source address of a SIP message as a String.


getKey

public static String getKey(InetAddress inetAddr,
                            int port,
                            String transport)
generate a key given the inet address port and transport.


getKey

public static String getKey(HostPort hostPort,
                            String transport)
Generate a key given host and port.


getHostPort

public HostPort getHostPort()
Get the hostport structure of this message channel.


getPeerHostPort

public HostPort getPeerHostPort()
Get the peer host and port.

Returns:
a HostPort structure for the peer.

getViaHeader

public Via getViaHeader()
Get the Via header for this transport. Note that this does not set a branch identifier.

Returns:
a via header for outgoing messages sent from this channel.

getViaHostPort

public HostPort getViaHostPort()
Get the via header host:port structure. This is extracted from the topmost via header of the request.

Returns:
a host:port structure

logMessage

public void logMessage(SIPMessage sipMessage,
                       InetAddress address,
                       int port,
                       long time)
Log a message sent to an address and port via the default interface.

Parameters:
sipMessage - is the message to log.
address - is the inet address to which the message is sent.
port - is the port to which the message is directed.

logResponse

public void logResponse(SIPResponse sipResponse,
                        long receptionTime,
                        String status)
Log a response received at this message channel. This is used for processing incoming responses to a client transaction.

Parameters:
receptionTime - is the time at which the response was received.
status - is the processing status of the message.

createBadReqRes

protected final String createBadReqRes(String badReq,
                                       ParseException pe)
Creates a response to a bad request (ie one that causes a ParseException)

Parameters:
badReq -
Returns:
message bytes, null if unable to formulate response

getMessageProcessor

public MessageProcessor getMessageProcessor()
Get the message processor.


getEncapsulatedClientTransaction

public SIPClientTransaction getEncapsulatedClientTransaction()

setEncapsulatedClientTransaction

public void setEncapsulatedClientTransaction(SIPClientTransaction transaction)


Copyright © 2012. All Rights Reserved.