Package com.ericsson.ssa.sip

Examples of com.ericsson.ssa.sip.ViaImpl


            return;
        }
       
        Header viaHeader = request.getRawHeader(Header.VIA);
        ListIterator<String> viaHeaderIter = viaHeader.getValues();
        ViaImpl firstViaHeader = new ViaImpl(viaHeaderIter.next());
        String felbParam =
                firstViaHeader.getParameter(CLBConstants.FE_LB_PARAM);
        //Request is not proxied, there will be no Path header added by FE
        if (felbParam == null) {
            if (logger.isLoggable(Level.FINER)) {
                logger.finer("felb param is null");
            }
            return;
        }

        Address feAddress = createSipAddress(
                firstViaHeader.getHost(), firstViaHeader.getPort());

        int statusCode = response.getStatus();
        if ( statusCode >= 200 && statusCode < 300) {
            if (isRegisterMethod) {
                String expires = request.getHeader(Header.EXPIRES);
View Full Code Here


            if (viaIterator.hasNext()) {
                if (clbMonitoringManager.isCLBMonitoringEnabled()) {
                    clbMonitoringManager.getCLBStatsUpdater().
                            incrementTotalOutgoingSipResponsesFE();
                }
                ViaImpl via = new ViaImpl(viaIterator.next());

                // Extract 'felb' flag
                String frontEndLb = via.getParameter(CLBConstants.FE_LB_PARAM);

                if (frontEndLb != null) {
                    // This response was received from the back-end,
                    // pop Via, extract connection and forward it to the client.
                    viaHeader.setReadOnly(false);
View Full Code Here

        if (viaHeader != null) {
            ListIterator<String> viaIterator;
            viaIterator = viaHeader.getValues();

            if (viaIterator.hasNext()) {
                ViaImpl via = new ViaImpl(viaIterator.next());

                String instanceID = via.getParameter(
                        CLBConstants.BE_ROUTE_PARAM);
               
                if(instanceID == null || instanceID.length() <=2){
                    // Should never happen, drop response
                    throw new SipRoutingException(
View Full Code Here

        // This Via is used to route an incoming response if the request is being proxied and the
        // response goes via UDP or if the TCP connection via which the request was sent
        // is broken.
        Header viaHeader = request.getRawHeader(Header.VIA);
       
        ViaImpl topVia = null;
        String branchId;
        if (viaHeader == null) {
            throw new SipRoutingException("No Via header on incoming request!");
        } else {
            topVia = new ViaImpl(viaHeader.getValue());
            branchId = LoadbalancerUtil.createBranchId(request, topVia);
        }

        ViaImpl via = new ViaImpl("SIP", SipTransports.TCP_PROT.name(),
                hostName, port);
        if (frontend) {
            // Set flag indicating that this Via was pushed by the front-end
            via.setParameter(CLBConstants.FE_LB_PARAM, null);
            // Save connection between client and front-end
            Connection connection;
            if (request.getRemote().getProtocol() != SipTransports.UDP_PROT) {
                // Encode information about the connection between the client and the
                // front-end
                connection = new Connection(request.getRemote().getProtocol(),
                    new Socket(request.getLocal().getAddress().getHostAddress(),
                        request.getLocal().getPort()),
                    new Socket(request.getRemote().getIP(),
                        request.getRemote().getPort()));
            } else {
                // In case of UDP, only save a marker
                connection = Connection.UDP;
            }
            via.setParameter(CLBConstants.CONNID_PARAM, connection.getEncodedValue());
        } else {
            // Fix for issue#1418
            // This via is pushed by the CLB in back-end instance.
            // Set flag indicating that this Via was pushed by the back-end
            via.setParameter(CLBConstants.BE_LB_PARAM, null);
        }
        via.setParameter(ViaImpl.PARAM_BRANCH, branchId);
        viaHeader.setValue(via.toString(), true);
    }
View Full Code Here

        if (viaHeader != null) {
            ListIterator<String> viaIterator;
            viaIterator = viaHeader.getValues();

            if (viaIterator.hasNext()) {
                ViaImpl via = new ViaImpl(viaIterator.next());

                // Extract 'felb' flag
                String frontEndLb = via.getParameter(
                        CLBConstants.FE_LB_PARAM);

                if (frontEndLb != null) {
                    return true;
                }
View Full Code Here

        boolean hasProxyRemoteHeader = resp.getHeader("Proxy-Remote") != null;

        String topViaHeader = resp.getHeader(Header.VIA);
        if (topViaHeader != null) {
            ViaImpl via = new ViaImpl(topViaHeader);
            // does top via contain 'felb' flag ?
            boolean hasFeLbParam = via.getParameter(CLBConstants.FE_LB_PARAM) != null;
            if (hasFeLbParam) {
                return ics == InterceptionSpecifier.OUT ? LbSpecifier.TO_FE : LbSpecifier.FROM_BE;
            } else if (hasProxyRemoteHeader) {
                return ics == InterceptionSpecifier.OUT ? LbSpecifier.TO_BE : LbSpecifier.FROM_FE;
            }
View Full Code Here

            if (viaHeader != null) {
                ListIterator<String> viaIterator;
                viaIterator = viaHeader.getValues();

                if (viaIterator.hasNext()) {
                    ViaImpl via = new ViaImpl(viaIterator.next());
                    // Extract 'felb' flag
                    String frontEndLb = via.getParameter(CLBConstants.FE_LB_PARAM);

                    if (frontEndLb != null) {
                        // This response was received from the back-end,
                        // pop Via, extract connection and forward it to the client.
                        viaHeader.setReadOnly(false);
View Full Code Here

            logger.log(Level.FINER, "Hashkey: " + hashkey);
        }

        // Set BERoute parameter on topmost Via
        // Add quotes around it, as it may contain special characters
        ViaImpl via = getTopVia(request);
        via.setParameter(CLBConstants.BE_ROUTE_PARAM,
                CLBConstants.QUOTE + instanceID + CLBConstants.QUOTE);

        sipClientToClbFEMapper.pushRouteHeader(request, localAddress.getHostName(),
                localAddress.getPort());
       
        // Check if the application has set Contact
        if (request.isContactIndicated()) {
            // Check if this request is initiated from this instance

            Header contactHeader = request.getRawHeader(Header.CONTACT);
            if (contactHeader != null) {
                // There is a contact, we need to add the BE-KEY to it
                try {
                    AddressImpl addressValue = (AddressImpl) contactHeader.getAddressValue();
                    if (addressValue != null) {
                        // Fetch current read-only status
                        boolean readOnly = addressValue.isReadOnly();
                        // Allow writes on Address object
                        addressValue.setReadOnly(false);
                        URIImpl uriImpl = (URIImpl) addressValue.getURI();
                        if(uriImpl != null){
                            uriImpl.encodeBeKey(hashkey);
                        }
                        // Reset read-only status
                        addressValue.setReadOnly(readOnly);
                    }
                } catch (ServletParseException e) {
                    throw new SipRoutingException("Malformed Contact", e);
                }
            }

            replaceTopVia(request, via);

            if (logger.isLoggable(Level.FINER)) {
                logger.log(Level.FINER,
                        "The request originates from this instance, altered request: " + request);
            }

            return null;
        } else if (request.isRecordRouteIndicated()) {
            // This request was proxied, save ID of incoming connection.
            String encodedConnection;
            if ((encodedConnection=getEncondedConnection(request)) == null) {
                throw new SipRoutingException("Could not find connection information in a proxied request, shall never happen!");
            } else {
                via.setParameter(CLBConstants.CONNID_PARAM, encodedConnection);
            }


            Header rrHeader = request.getRawHeader(Header.RECORD_ROUTE);
            AddressImpl rrAddr;
            try {
                rrAddr = (AddressImpl) rrHeader.getAddressValue();
            } catch (ServletParseException e) {
                throw new SipRoutingException("Malformed record-Route", e);
            }

            // The R-R was added by the application, thus we shall set 'bekey'
            // Fetch current read-only status
            boolean readOnly = rrAddr.isReadOnly();
            // Allow writes on Address object
            rrAddr.setReadOnly(false);
            URIImpl uriImpl = (URIImpl) rrAddr.getURI();
            if (uriImpl != null) {
                uriImpl.encodeBeKey(hashkey);
            }
            // Reset read-only status
            rrAddr.setReadOnly(readOnly);

            replaceTopVia(request, via);

            if (logger.isLoggable(Level.FINER)) {
                logger.log(Level.FINER,
                        "The request was proxied, altered request: " + request);
            }

            return null;
        } else {
            // This request was either:
            // a) proxied but not Record-Routed; save ID of incoming connection so that response can travel back on it.
            // b) a non-dialog request originating from this instance; no connection information will exist.
            String encodedConnection;
            if ((encodedConnection=getEncondedConnection(request)) != null) {
                via.setParameter(CLBConstants.CONNID_PARAM, encodedConnection);
            }

            replaceTopVia(request, via);

            return null;
View Full Code Here

        if (viaHeader != null) {
            ListIterator<String> viaIterator;
            viaIterator = viaHeader.getValues();

            if (viaIterator.hasNext()) {
                ViaImpl via = new ViaImpl(viaIterator.next());
                // Extract connection
                Connection connection = LoadbalancerUtil.getConnection(via);
                if (connection != null) {
                    // The top Via contained connection information, the origin request was proxied
                    // by the application; the connection information either identifies
View Full Code Here

            popTopVia(response);
        }
    }

    private ViaImpl getTopVia(SipServletMessageImpl msg) {
        return new ViaImpl(msg.getRawHeader(Header.VIA).getValue());
    }
View Full Code Here

TOP

Related Classes of com.ericsson.ssa.sip.ViaImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.