Search in sources :

Example 1 with HostPort

use of gov.nist.core.HostPort 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 HostPort

use of gov.nist.core.HostPort 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 HostPort

use of gov.nist.core.HostPort 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 4 with HostPort

use of gov.nist.core.HostPort 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)

Example 5 with HostPort

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

the class URLParser method uricString.

protected String uricString() throws ParseException {
    StringBuffer retval = new StringBuffer();
    while (true) {
        String next = uric();
        if (next == null) {
            char la = lexer.lookAhead(0);
            // e.g. http://[::1]
            if (la == '[') {
                HostNameParser hnp = new HostNameParser(this.getLexer());
                HostPort hp = hnp.hostPort(false);
                retval.append(hp.toString());
                continue;
            }
            break;
        }
        retval.append(next);
    }
    return retval.toString();
}
Also used : HostNameParser(gov.nist.core.HostNameParser) HostPort(gov.nist.core.HostPort)

Aggregations

HostPort (gov.nist.core.HostPort)11 Host (gov.nist.core.Host)9 HostNameParser (gov.nist.core.HostNameParser)2 ParseException (java.text.ParseException)2 NameValue (gov.nist.core.NameValue)1 Token (gov.nist.core.Token)1 SipUri (gov.nist.javax.sip.address.SipUri)1 SIPRequest (gov.nist.javax.sip.message.SIPRequest)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Iterator (java.util.Iterator)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1