Search in sources :

Example 1 with AddressResolver

use of gov.nist.core.net.AddressResolver in project XobotOS by xamarin.

the class DefaultRouter method createHop.

/**
     * Utility method to create a hop from a SIP URI
     *
     * @param sipUri
     * @return
     */
private final Hop createHop(SipURI sipUri, Request request) {
    // always use TLS when secure
    String transport = sipUri.isSecure() ? SIPConstants.TLS : sipUri.getTransportParam();
    if (transport == null) {
        //@see issue 131
        ViaHeader via = (ViaHeader) request.getHeader(ViaHeader.NAME);
        transport = via.getTransport();
    }
    // sipUri.removeParameter("transport");
    int port;
    if (sipUri.getPort() != -1) {
        port = sipUri.getPort();
    } else {
        if (transport.equalsIgnoreCase(SIPConstants.TLS))
            port = 5061;
        else
            // TCP or UDP
            port = 5060;
    }
    String host = sipUri.getMAddrParam() != null ? sipUri.getMAddrParam() : sipUri.getHost();
    AddressResolver addressResolver = this.sipStack.getAddressResolver();
    return addressResolver.resolveAddress(new HopImpl(host, port, transport));
}
Also used : AddressResolver(gov.nist.core.net.AddressResolver) ViaHeader(javax.sip.header.ViaHeader)

Aggregations

AddressResolver (gov.nist.core.net.AddressResolver)1 ViaHeader (javax.sip.header.ViaHeader)1