Package com.ericsson.ssa.sip

Examples of com.ericsson.ssa.sip.Header$HeaderName


                logger.finer("Contact address is not sip uri");
            }
            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) {
View Full Code Here


        if (logger.isLoggable(Level.FINER)) {
            logger.log(Level.FINER, "Handle incoming response.");
        }

        // Get topmost header
        Header viaHeader = response.getRawHeader(Header.VIA);

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

            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);
                    viaIterator.remove();
                    viaHeader.setReadOnly(true);

                    // Extract connection
                    Connection connection = LoadbalancerUtil.getConnection(via);
                    if (connection != null && connection == Connection.UDP) {
                            // The origin request was sent via UDP.
View Full Code Here

    // ---------------- Internal methods --------------------
    private ServerInstance getServerInstanceForResponse(
            SipServletResponseImpl response) throws SipRoutingException {
        // Get topmost Via
        Header viaHeader = response.getRawHeader(Header.VIA);

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

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

                String instanceID = via.getParameter(
View Full Code Here

    static void pushVia(SipServletRequestImpl request, String hostName,
            int port, boolean frontend) throws SipRoutingException {
        // 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

        //response can directly go back to client
        if(req.getRemote().getProtocol() == SipTransports.UDP_PROT
                && LoadbalancerUtil.isAsymmetric()){
            req.setSystemAttribute(CLBConstants.CONNID_ATTR,
                    Connection.UDP);
            Header viaHeader = req.getRawHeader(Header.VIA);

            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);
                        viaIterator.remove();
                    }
                }
            }
        }
View Full Code Here

       
        // 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'
View Full Code Here

     * @return true if request is already proxied
     */
    public static boolean isSipRequestProxied(SipServletRequestImpl request) throws SipRoutingException {

        // Get topmost Via header
        Header viaHeader = request.getRawHeader(Header.VIA);

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

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

                // Extract 'felb' flag
View Full Code Here

            } else if (REQUEST.equals(pc)) {
                appendRequestInfo(charBuffer, request);
            } else if (RESPONSE_LENGTH.equals(pc)) {
                appendResponseLength(charBuffer, request.getContentLength());
            } else if (VIA.equals(pc)) {
                Header via = request.getRawHeader(Header.VIA);
                appendVia(charBuffer, via);
            } else if (CALL_ID.equals(pc)) {
                Header callId = request.getRawHeader(Header.CALL_ID);
                appendString(charBuffer, callId);
            } else if (TO.equals(pc)) {
                Header to = request.getRawHeader(Header.TO);
                appendString(charBuffer, to);
            } else if (FROM.equals(pc)) {
                Header from = request.getRawHeader(Header.FROM);
                appendString(charBuffer, from);
            } else if (CSEQ.equals(pc)) {
                Header cseq = request.getRawHeader(Header.CSEQ);
                appendString(charBuffer, cseq);
            } else if (MAX_FORWARDS.equals(pc)) {
                Header maxForwards = request.getRawHeader(Header.MAX_FORWARDS);
                appendString(charBuffer, maxForwards);
            } else if (CONTACT.equals(pc)) {
                Header contact = request.getRawHeader(Header.CONTACT);
                appendString(charBuffer, contact);
            } else if (CONTENT_TYPE.equals(pc)) {
                Header contentType = request.getRawHeader(Header.CONTENT_TYPE);
                appendString(charBuffer, contentType);
            }
            charBuffer.put(SPACE);
        }
        charBuffer.put("\n");
View Full Code Here

            } else if (STATUS.equals(pc)) {
                appendResponseStatus(charBuffer, response);
            } else if (RESPONSE_LENGTH.equals(pc)) {
                appendResponseLength(charBuffer, response.getContentLength());
            } else if (VIA.equals(pc)) {
                Header via = response.getRawHeader(Header.VIA);
                appendVia(charBuffer, via);
            } else if (CALL_ID.equals(pc)) {
                Header callId = response.getRawHeader(Header.CALL_ID);
                appendString(charBuffer, callId);
            } else if (TO.equals(pc)) {
                Header to = response.getRawHeader(Header.TO);
                appendString(charBuffer, to);
            } else if (FROM.equals(pc)) {
                Header from = response.getRawHeader(Header.FROM);
                appendString(charBuffer, from);
            } else if (CSEQ.equals(pc)) {
                Header cseq = response.getRawHeader(Header.CSEQ);
                appendString(charBuffer, cseq);
            } else if (MAX_FORWARDS.equals(pc)) {
                Header maxForwards = response.getRawHeader(Header.MAX_FORWARDS);
                appendString(charBuffer, maxForwards);
            } else if (CONTACT.equals(pc)) {
                Header contact = response.getRawHeader(Header.CONTACT);
                appendString(charBuffer, contact);
            } else if (CONTENT_TYPE.equals(pc)) {
                Header contentType = response.getRawHeader(Header.CONTENT_TYPE);
                appendString(charBuffer, contentType);
            }
            charBuffer.put(SPACE);
        }
        charBuffer.put("\n");
View Full Code Here

       
        //Check if request is send by backend to be forwarded to
        //client.
        //Such a request will have a topmost route with parameter
        //"felb".
        Header routeHeader = req.getRawHeader(Header.ROUTE);
        ListIterator<Address> routeIterator = null;
        try {
            if(routeHeader != null){
                routeIterator = routeHeader.getAddressValues();
            }
        } catch (ServletParseException ex) {
            logger.log(Level.WARNING,
                    "clb.sip.failed_to_route_incoming_request", ex.getMessage());
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "clb.caught_an_exception", ex);
            }
            SipServletResponseImpl errorResponse =
                    req.createTerminatingResponse(503);

            if (errorResponse != null) {
                errorResponse.popDispatcher().dispatch(errorResponse);
            }
            return;
        }
        if(routeIterator != null && routeIterator.hasNext()){
            Address topRoute = routeIterator.next();
            String feParam = topRoute.getURI().getParameter(CLBConstants.FE_LB_PARAM);
            if(feParam != null){
                //remove topmost route
                boolean readOnly = routeHeader.isReadOnly();
                routeHeader.setReadOnly(false);
                routeIterator.remove();
                routeHeader.setReadOnly(readOnly);
                TargetTuple tt = null;
                try{
                    tt = TargetResolver.getInstance().resolveRequest(
                            req, req.getContentLength());
                }catch(Exception ex){
View Full Code Here

TOP

Related Classes of com.ericsson.ssa.sip.Header$HeaderName

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.