Search in sources :

Example 1 with Host

use of gov.nist.core.Host in project XobotOS by xamarin.

the class ListeningPointImpl method sendHeartbeat.

public void sendHeartbeat(String ipAddress, int port) throws IOException {
    HostPort targetHostPort = new HostPort();
    targetHostPort.setHost(new Host(ipAddress));
    targetHostPort.setPort(port);
    MessageChannel messageChannel = this.messageProcessor.createMessageChannel(targetHostPort);
    SIPRequest siprequest = new SIPRequest();
    siprequest.setNullRequest();
    messageChannel.sendMessage(siprequest);
}
Also used : HostPort(gov.nist.core.HostPort) Host(gov.nist.core.Host) SIPRequest(gov.nist.javax.sip.message.SIPRequest)

Example 2 with Host

use of gov.nist.core.Host in project XobotOS by xamarin.

the class SIPTransactionStack method createRawMessageChannel.

/**
     * Creates a new MessageChannel for a given Hop.
     *
     * @param sourceIpAddress - Ip address of the source of this message.
     *
     * @param sourcePort - source port of the message channel to be created.
     *
     * @param nextHop Hop to create a MessageChannel to.
     *
     * @return A MessageChannel to the specified Hop, or null if no MessageProcessors support
     *         contacting that Hop.
     *
     * @throws UnknownHostException If the host in the Hop doesn't exist.
     */
public MessageChannel createRawMessageChannel(String sourceIpAddress, int sourcePort, Hop nextHop) throws UnknownHostException {
    Host targetHost;
    HostPort targetHostPort;
    Iterator processorIterator;
    MessageProcessor nextProcessor;
    MessageChannel newChannel;
    // Create the host/port of the target hop
    targetHost = new Host();
    targetHost.setHostname(nextHop.getHost());
    targetHostPort = new HostPort();
    targetHostPort.setHost(targetHost);
    targetHostPort.setPort(nextHop.getPort());
    // Search each processor for the correct transport
    newChannel = null;
    processorIterator = messageProcessors.iterator();
    while (processorIterator.hasNext() && newChannel == null) {
        nextProcessor = (MessageProcessor) processorIterator.next();
        // transport is found,
        if (nextHop.getTransport().equalsIgnoreCase(nextProcessor.getTransport()) && sourceIpAddress.equals(nextProcessor.getIpAddress().getHostAddress()) && sourcePort == nextProcessor.getPort()) {
            try {
                // Create a channel to the target
                // host/port
                newChannel = nextProcessor.createMessageChannel(targetHostPort);
            } catch (UnknownHostException ex) {
                if (stackLogger.isLoggingEnabled())
                    stackLogger.logException(ex);
                throw ex;
            } catch (IOException e) {
                if (stackLogger.isLoggingEnabled())
                    stackLogger.logException(e);
            // Ignore channel creation error -
            // try next processor
            }
        }
    }
    // Return the newly-created channel
    return newChannel;
}
Also used : UnknownHostException(java.net.UnknownHostException) HostPort(gov.nist.core.HostPort) Iterator(java.util.Iterator) Host(gov.nist.core.Host) IOException(java.io.IOException)

Example 3 with Host

use of gov.nist.core.Host in project XobotOS by xamarin.

the class MessageProcessor method setIpAddress.

/**
     * @param ipAddress the ipAddress to set
     */
protected void setIpAddress(InetAddress ipAddress) {
    this.sentByHostPort.setHost(new Host(ipAddress.getHostAddress()));
    this.ipAddress = ipAddress;
}
Also used : Host(gov.nist.core.Host)

Example 4 with Host

use of gov.nist.core.Host in project XobotOS by xamarin.

the class MessageProcessor method initialize.

/**
     * Initializes this MessageProcessor. Needed for extensions
     * that use classloading
     * 
     * @param ipAddress2
     * @param transactionStack
     * @param port2
     */
public final void initialize(InetAddress ipAddress, int port, SIPTransactionStack transactionStack) {
    this.sipStack = transactionStack;
    this.savedIpAddress = ipAddress.getHostAddress();
    this.ipAddress = ipAddress;
    this.port = port;
    this.sentByHostPort = new HostPort();
    this.sentByHostPort.setHost(new Host(ipAddress.getHostAddress()));
    this.sentByHostPort.setPort(port);
}
Also used : HostPort(gov.nist.core.HostPort) Host(gov.nist.core.Host)

Example 5 with Host

use of gov.nist.core.Host in project XobotOS by xamarin.

the class MessageChannel method getPeerHostPort.

/**
     * Get the peer host and port.
     * 
     * @return a HostPort structure for the peer.
     */
public HostPort getPeerHostPort() {
    HostPort retval = new HostPort();
    retval.setHost(new Host(this.getPeerAddress()));
    retval.setPort(this.getPeerPort());
    return retval;
}
Also used : HostPort(gov.nist.core.HostPort) Host(gov.nist.core.Host)

Aggregations

Host (gov.nist.core.Host)12 HostPort (gov.nist.core.HostPort)9 ParseException (java.text.ParseException)3 InvalidArgumentException (javax.sip.InvalidArgumentException)2 NameValue (gov.nist.core.NameValue)1 Via (gov.nist.javax.sip.header.Via)1 SIPRequest (gov.nist.javax.sip.message.SIPRequest)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Iterator (java.util.Iterator)1