/** * Set the host portion of the SipURI * * @param host host to set. */ public void setHost(String host) throws ParseException { Host h = new Host(host); this.setHost(h); }
/** * @param ipAddress the ipAddress to set */ protected void setIpAddress(InetAddress ipAddress) { this.sentByHostPort.setHost( new Host(ipAddress.getHostAddress())); this.ipAddress = ipAddress; }
public ConnectionAddress connectionAddress(String address) { ConnectionAddress connectionAddress = new ConnectionAddress(); int begin = address.indexOf("/"); if (begin != -1) { connectionAddress.setAddress(new Host(address.substring(0, begin))); int middle = address.indexOf("/", begin + 1); if (middle != -1) { String ttl = address.substring(begin + 1, middle); connectionAddress.setTtl(Integer.parseInt(ttl.trim())); String addressNumber = address.substring(middle + 1); connectionAddress.setPort( Integer.parseInt(addressNumber.trim())); } else { String ttl = address.substring(begin + 1); connectionAddress.setTtl(Integer.parseInt(ttl.trim())); } } else connectionAddress.setAddress(new Host(address)); return connectionAddress; }
/** * Set the host part of this ViaHeader to the newly supplied <code>host</code> * parameter. * * @throws ParseException which signals that an error has been reached * unexpectedly while parsing the host value. */ public void setHost(String host) throws ParseException { if (sentBy == null) sentBy = new HostPort(); try { Host h = new Host(host); sentBy.setHost(h); } catch (Exception e) { throw new NullPointerException(" host parameter is null"); } }
/** * 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); }
/** * Set the sentby string. This is used for stamping outgoing messages sent * from this listening point. * * @param sentBy */ public void setSentBy(String sentBy) throws ParseException { int ind = sentBy.indexOf(":"); if (ind == -1) { this.sentByHostPort = new HostPort(); this.sentByHostPort.setHost(new Host(sentBy)); } else { this.sentByHostPort = new HostPort(); this.sentByHostPort.setHost(new Host(sentBy.substring(0, ind))); String portStr = sentBy.substring(ind + 1); try { int port = Integer.parseInt(portStr); this.sentByHostPort.setPort(port); } catch (NumberFormatException ex) { throw new ParseException("Bad format encountered at ", ind); } } this.sentBySet = true; this.sentBy = sentBy; }
/** * Sets the value of the <code>maddr</code> parameter of this ViaHeader. The * maddr parameter indicates the server address to be contacted for this * user, overriding any address derived from the host field. * * @param mAddr new value of the <code>maddr</code> parameter * @throws ParseException which signals that an error has been reached * unexpectedly while parsing the mAddr value. */ public void setMAddr(String mAddr) throws ParseException { if (mAddr == null) throw new NullPointerException( "JAIN-SIP Exception, " + "Via, setMAddr(), the mAddr parameter is null."); Host host = new Host(); host.setAddress(mAddr); NameValue nameValue = new NameValue(ParameterNames.MADDR, host); setParameter(nameValue); }
/** Sets the type of the address for this Connection. * @param addr string address type. * @throws SdpException if the addr is null */ public void setAddress(String addr) throws SdpException { if (addr == null) throw new SdpException("The addr parameter is null"); else { Host host = getHost(); if (host == null) host = new Host(); host.setAddress(addr); setAddress(host); } }
/** * Get the hostport structure of this message channel. */ public HostPort getHostPort() { HostPort retval = new HostPort(); retval.setHost(new Host(this.getHost())); retval.setPort(this.getPort()); return retval; }
/** * 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; }
/** * Get the via header host:port structure. This is extracted from the topmost via header of * the request. * * @return a host:port structure */ public HostPort getViaHostPort() { HostPort retval = new HostPort(); retval.setHost(new Host(this.getViaHost())); retval.setPort(this.getViaPort()); return retval; }
/** Sets the type of the address for this Connection. * @param addr to set * @throws SdpException if the type is null */ public void setAddress(String addr) throws SdpException { if (addr == null) throw new SdpException("the addr is null"); else { if (address == null) { address = new ConnectionAddress(); Host host = new Host(addr); address.setAddress(host); } else { Host host = address.getAddress(); if (host == null) { host = new Host(addr); address.setAddress(host); } else host.setAddress(addr); } setAddress(address); } }
/** * Set the MADDR parameter . * @param mAddr Host Name to set */ public void setMAddr(String mAddr) { NameValue nameValue = uriParms.getNameValue(MADDR); Host host = new Host(); host.setAddress(mAddr); if (nameValue != null) nameValue.setValueAsObject(host); else { nameValue = new NameValue(MADDR, host); uriParms.set(nameValue); } }
public boolean closeReliableConnection(String peerAddress, int peerPort) throws IllegalArgumentException { validatePortInRange(peerPort); HostPort hostPort = new HostPort(); hostPort.setHost(new Host(peerAddress)); hostPort.setPort(peerPort); String messageChannelKey = MessageChannel.getKey(hostPort, "TCP"); synchronized (this) { ConnectionOrientedMessageChannel foundMessageChannel = messageChannels.get(messageChannelKey); if (foundMessageChannel != null) { foundMessageChannel.close(); if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) logger.logDebug(Thread.currentThread() + " Removing channel " + messageChannelKey + " for processor " + getIpAddress()+ ":" + getPort() + "/" + getTransport()); incomingMessageChannels.remove(messageChannelKey); messageChannels.remove(messageChannelKey); return true; } foundMessageChannel = incomingMessageChannels.get(messageChannelKey); if (foundMessageChannel != null) { foundMessageChannel.close(); if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) logger.logDebug(Thread.currentThread() + " Removing incoming channel " + messageChannelKey + " for processor " + getIpAddress()+ ":" + getPort() + "/" + getTransport()); incomingMessageChannels.remove(messageChannelKey); messageChannels.remove(messageChannelKey); return true; } } return false; }
lexer.getPtr()); else return new Host(hostname); } finally { if (debug)
lexer.getPtr()); else return new Host(hostname); } finally { if (debug)
public boolean setKeepAliveTimeout(String peerAddress, int peerPort, long keepAliveTimeout) { validatePortInRange(peerPort); HostPort hostPort = new HostPort(); hostPort.setHost(new Host(peerAddress)); hostPort.setPort(peerPort); String messageChannelKey = MessageChannel.getKey(hostPort, "TCP"); ConnectionOrientedMessageChannel foundMessageChannel = messageChannels.get(messageChannelKey); if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) logger.logDebug(Thread.currentThread() + " checking channel with key " + messageChannelKey + " : " + foundMessageChannel + " for processor " + getIpAddress()+ ":" + getPort() + "/" + getTransport()); if (foundMessageChannel != null) { foundMessageChannel.setKeepAliveTimeout(keepAliveTimeout); return true; } foundMessageChannel = incomingMessageChannels.get(messageChannelKey); if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) logger.logDebug(Thread.currentThread() + " checking incoming channel with key " + messageChannelKey + " : " + foundMessageChannel + " for processor " + getIpAddress()+ ":" + getPort() + "/" + getTransport()); if (foundMessageChannel != null) { foundMessageChannel.setKeepAliveTimeout(keepAliveTimeout); return true; } return false; }
/** * Creates a client transaction to handle a new request. Gets the real * message channel from the superclass, and then creates a new client * transaction wrapped around this channel. * * @param nextHop * Hop to create a channel to contact. */ public MessageChannel createMessageChannel(SIPRequest request, MessageProcessor mp, Hop nextHop) throws IOException { // Create a new client transaction around the // superclass' message channel // Create the host/port of the target hop Host targetHost = new Host(); targetHost.setHostname(nextHop.getHost()); HostPort targetHostPort = new HostPort(); targetHostPort.setHost(targetHost); targetHostPort.setPort(nextHop.getPort()); MessageChannel returnChannel = mp.createMessageChannel(targetHostPort); return returnChannel; }
/** * Get the Via header to assign for this message processor. The topmost via * header of the outoging messages use this. * * @return the ViaHeader to be used by the messages sent via this message processor. */ public Via getViaHeader() { try { Via via = new Via(); if (this.sentByHostPort != null) { via.setSentBy(sentByHostPort); via.setTransport(this.getTransport()); } else { Host host = new Host(); host.setHostname(this.getIpAddress().getHostAddress()); via.setHost(host); via.setPort(this.getPort()); via.setTransport(this.getTransport()); } return via; } catch (ParseException ex) { ex.printStackTrace(); return null; } catch (InvalidArgumentException ex) { ex.printStackTrace(); return null; } } public ListeningPointImpl getListeningPoint() {
public void sendHeartbeat(String ipAddress, int port) throws IOException { if(!sipStack.isAlive()) return; HostPort targetHostPort = new HostPort(); targetHostPort.setHost(new Host( ipAddress)); targetHostPort.setPort(port); MessageChannel messageChannel = this.messageProcessor.createMessageChannel(targetHostPort); SIPRequest siprequest = new SIPRequest(); siprequest.setNullRequest(); if(messageChannel instanceof ConnectionOrientedMessageChannel) { // RFC 5626 : schedule the keepaive timeout to make sure we receive a pong response and notify the app if not ConnectionOrientedMessageChannel connectionOrientedMessageChannel = (ConnectionOrientedMessageChannel) messageChannel; long keepaliveTimeout = connectionOrientedMessageChannel.getKeepAliveTimeout(); if(keepaliveTimeout > 0) { connectionOrientedMessageChannel.rescheduleKeepAliveTimeout(keepaliveTimeout); } } messageChannel.sendMessage(siprequest); }