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);
}
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;
}
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);
}
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;
}
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();
}
Aggregations