All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.restcomm.protocols.ss7.sccp.impl.message.SccpNoticeMessageImpl Maven / Gradle / Ivy

The newest version!
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2011, Red Hat, Inc. and individual contributors
 * Copyright 2019, Mobius Software LTD and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.restcomm.protocols.ss7.sccp.impl.message;

import io.netty.buffer.ByteBuf;

import org.restcomm.protocols.ss7.sccp.SccpProtocolVersion;
import org.restcomm.protocols.ss7.sccp.impl.parameter.AbstractParameter;
import org.restcomm.protocols.ss7.sccp.impl.parameter.ReturnCauseImpl;
import org.restcomm.protocols.ss7.sccp.message.ParseException;
import org.restcomm.protocols.ss7.sccp.message.SccpMessage;
import org.restcomm.protocols.ss7.sccp.message.SccpNoticeMessage;
import org.restcomm.protocols.ss7.sccp.parameter.HopCounter;
import org.restcomm.protocols.ss7.sccp.parameter.Importance;
import org.restcomm.protocols.ss7.sccp.parameter.ReturnCause;
import org.restcomm.protocols.ss7.sccp.parameter.ReturnCauseValue;
import org.restcomm.protocols.ss7.sccp.parameter.SccpAddress;

/**
 *
 * This class represents SCCP a connectionless notice message (UDTS, XUDTS and LUDTS)
 *
 * @author Oleg Kulikov
 * @author baranowb
 * @author sergey vetyutnev
 * @author yulianoifa
 *
 */
public class SccpNoticeMessageImpl extends SccpDataNoticeTemplateMessageImpl implements SccpNoticeMessage {

    protected ReturnCause returnCause;

    /**
     * Create a SCCP-User originated message
     *
     * @param sccpStackImpl
     * @param type
     * @param returnCause
     * @param calledParty
     * @param callingParty
     * @param data
     * @param hopCounter
     * @param importance
     */
    protected SccpNoticeMessageImpl(int maxDataLen, int type, ReturnCause returnCause, SccpAddress calledParty,
            SccpAddress callingParty, ByteBuf data, HopCounter hopCounter, Importance importance) {
        super(maxDataLen, type, 0, -1, calledParty, callingParty, data, hopCounter, importance);

        this.returnCause = returnCause;
    }

    /**
     * Create a MTP3 originated message
     *
     * @param sccpStackImpl
     * @param type
     * @param incomingOpc
     * @param incomingDpc
     * @param incomingSls
     */
    protected SccpNoticeMessageImpl(int maxDataLen, int type, int incomingOpc, int incomingDpc, int incomingSls, int networkId) {
        super(maxDataLen, type, incomingOpc, incomingDpc, incomingSls, networkId);
    }

    public ReturnCause getReturnCause() {
        return returnCause;
    }

    public void setReturnCause(ReturnCause rc) {
        this.returnCause = rc;
    }

    public boolean getReturnMessageOnError() {
        return false;
    }

    public void clearReturnMessageOnError() {
    }

    public boolean getSccpCreatesSls() {
        return true;
    }

    @Override
    protected boolean getSecondParamaterPresent() {
        return this.returnCause != null;
    }

    @Override
    protected void getSecondParamaterData(ByteBuf data,boolean removeSPC, SccpProtocolVersion sccpProtocolVersion) throws ParseException {
        ((AbstractParameter) this.returnCause).encode(data,removeSPC, sccpProtocolVersion);
    }

    @Override
    protected void setSecondParamaterData(ByteBuf data, final SccpProtocolVersion sccpProtocolVersion) throws ParseException {
        this.returnCause = new ReturnCauseImpl(ReturnCauseValue.getInstance(data.readByte()));
    }

    @Override
    protected boolean getIsProtocolClass1() {
        return false;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("Sccp Msg [Type=");
        switch (this.type) {
            case SccpMessage.MESSAGE_TYPE_UDTS:
                sb.append("UDTS");
                break;
            case SccpMessage.MESSAGE_TYPE_XUDTS:
                sb.append("XUDTS");
                break;
            case SccpMessage.MESSAGE_TYPE_LUDTS:
                sb.append("LUDTS");
                break;
            default:
                sb.append(this.type);
                break;
        }
        sb.append(" networkId=").append(this.networkId).append(" sls=").append(this.sls).append(" returnCause=").append(this.returnCause)
                .append(" incomingOpc=").append(this.incomingOpc).append(" incomingDpc=").append(this.incomingDpc).append(" outgoingDpc=")
                .append(this.outgoingDpc).append(" CallingAddress(").append(this.callingParty).append(") CalledParty(").append(this.calledParty).append(")");
        sb.append(" DataLen=");
        if (this.data != null)
            sb.append(this.data.readableBytes());
        return sb.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy