private ArrayList getLocalViaHeaders() throws IOException { /* * We can't keep a cached copy because the callers * of this method change the viaHeaders. In particular * a branch may be added which causes INVITES to fail. */ if (viaHeaders != null) { return viaHeaders; } ListeningPoint lp = sipProvider.getListeningPoint(); viaHeaders = new ArrayList(); try { String addr = lp.getIPAddress(); ViaHeader viaHeader = headerFactory.createViaHeader(addr, lp.getPort(), lp.getTransport(), null); viaHeader.setRPort(); viaHeaders.add(viaHeader); return viaHeaders; } catch (ParseException e) { throw new IOException( "A ParseException occurred while creating Via Headers! " + e.getMessage()); } catch (InvalidArgumentException e) { throw new IOException( "Unable to create a via header for port " + lp.getPort() + " " + e.getMessage()); } }
public void runTask() { if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) { logger.logDebug( "~~~ Starting processing of KeepAliveTimeoutEvent( " + peerAddress.getHostAddress() + "," + peerPort + ")..."); } close(true, true); if (sipStack instanceof SipStackImpl) { for (Iterator<SipProviderImpl> it = ((SipStackImpl) sipStack).getSipProviders(); it.hasNext(); ) { SipProviderImpl nextProvider = (SipProviderImpl) it.next(); SipListener sipListener = nextProvider.getSipListener(); ListeningPoint[] listeningPoints = nextProvider.getListeningPoints(); for (ListeningPoint listeningPoint : listeningPoints) { if (sipListener != null && sipListener instanceof SipListenerExt // making sure that we don't notify each listening point but only the one on which // the timeout happened && listeningPoint.getIPAddress().equalsIgnoreCase(myAddress) && listeningPoint.getPort() == myPort && listeningPoint.getTransport().equalsIgnoreCase(getTransport())) { ((SipListenerExt) sipListener) .processIOException( new IOExceptionEventExt( nextProvider, Reason.KeepAliveTimeout, myAddress, myPort, peerAddress.getHostAddress(), peerPort, getTransport())); } } } } else { SipListener sipListener = sipStack.getSipListener(); if (sipListener instanceof SipListenerExt) { ((SipListenerExt) sipListener) .processIOException( new IOExceptionEventExt( this, Reason.KeepAliveTimeout, myAddress, myPort, peerAddress.getHostAddress(), peerPort, getTransport())); } } }
public ViaHeader getStackViaHeader() { try { ListeningPoint lp = (ListeningPoint) sipStack.getListeningPoints().next(); String host = sipStack.getIPAddress(); int port = lp.getPort(); String transport = lp.getTransport(); // branch id is assigned by the transaction layer. return headerFactory.createViaHeader(host, port, transport, null); } catch (Exception e) { e.printStackTrace(); return null; } }
/** * Returns the JAIN-SIP <tt>ListeningPoint</tt> associated to the given transport string. * * @param transport a string like "UDP", "TCP" or "TLS". * @return the LP associated to the given transport. */ @SuppressWarnings("unchecked") // jain-sip legacy code public ListeningPoint getLP(String transport) { ListeningPoint lp; Iterator<ListeningPoint> it = this.stack.getListeningPoints(); while (it.hasNext()) { lp = it.next(); // FIXME: JAIN-SIP stack is not consistent with case // (reported upstream) if (lp.getTransport().toLowerCase().equals(transport.toLowerCase())) return lp; } throw new IllegalArgumentException("Invalid transport: " + transport); }
public ContactHeader getStackContactHeader() { try { ListeningPoint lp = (ListeningPoint) sipStack.getListeningPoints().next(); String host = sipStack.getIPAddress(); int port = lp.getPort(); String transport = lp.getTransport(); SipURI sipURI = addressFactory.createSipURI(null, host); sipURI.setPort(port); sipURI.setTransportParam(transport); Address contactAddress = addressFactory.createAddress(sipURI); return headerFactory.createContactHeader(contactAddress); } catch (Exception e) { e.printStackTrace(); return null; } }