Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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 org.apache.logging.log4j.Logger;
import org.restcomm.protocols.ss7.sccp.LongMessageRuleType;
import org.restcomm.protocols.ss7.sccp.SccpProtocolVersion;
import org.restcomm.protocols.ss7.sccp.impl.SccpStackImpl;
import org.restcomm.protocols.ss7.sccp.impl.parameter.ErrorCauseImpl;
import org.restcomm.protocols.ss7.sccp.impl.parameter.LocalReferenceImpl;
import org.restcomm.protocols.ss7.sccp.message.ParseException;
import org.restcomm.protocols.ss7.sccp.message.SccpConnErrMessage;
import org.restcomm.protocols.ss7.sccp.parameter.ErrorCause;
import org.restcomm.protocols.ss7.sccp.parameter.ParameterFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
/**
*
* @author yulianoifa
*
*/
public class SccpConnErrMessageImpl extends SccpConnReferencedMessageImpl implements SccpConnErrMessage {
protected ErrorCause errorCause;
public SccpConnErrMessageImpl(int sls, int localSsn) {
super(0, MESSAGE_TYPE_ERR, sls, localSsn);
}
public SccpConnErrMessageImpl(int incomingOpc, int incomingDpc, int incomingSls, int networkId) {
super(0, MESSAGE_TYPE_ERR, incomingOpc, incomingDpc, incomingSls, networkId);
}
@Override
public ErrorCause getErrorCause() {
return errorCause;
}
@Override
public void setErrorCause(ErrorCause value) {
this.errorCause = value;
}
@Override
public void decode(ByteBuf buffer, ParameterFactory factory, SccpProtocolVersion sccpProtocolVersion) throws ParseException {
LocalReferenceImpl ref = new LocalReferenceImpl();
ref.decode(buffer, factory, sccpProtocolVersion);
destinationLocalReferenceNumber = ref;
ErrorCauseImpl cause = new ErrorCauseImpl();
cause.decode(buffer, factory, sccpProtocolVersion);
errorCause = cause;
}
@Override
public EncodingResultData encode(SccpStackImpl sccpStackImpl, LongMessageRuleType longMessageRuleType, int maxMtp3UserDataLength, Logger logger, boolean removeSPC, SccpProtocolVersion sccpProtocolVersion) throws ParseException {
if (type == 0) {
return new EncodingResultData(EncodingResult.MessageTypeMissing, null, null, null);
}
if (destinationLocalReferenceNumber == null) {
return new EncodingResultData(EncodingResult.DestinationLocalReferenceNumberMissing, null, null, null);
}
if (errorCause == null) {
return new EncodingResultData(EncodingResult.ErrorCauseMissing, null, null, null);
}
// 5 is sum of 3 fixed-length field lengths
ByteBuf out = Unpooled.buffer(5);
out.writeByte(type);
((LocalReferenceImpl) destinationLocalReferenceNumber).encode(out,sccpStackImpl.isRemoveSpc(), sccpStackImpl.getSccpProtocolVersion());
((ErrorCauseImpl) errorCause).encode(out,sccpStackImpl.isRemoveSpc(), sccpStackImpl.getSccpProtocolVersion());
return new EncodingResultData(EncodingResult.Success, out, null, null);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Sccp Msg [Type=ERR");
sb.append(" networkId=");
sb.append(this.networkId);
sb.append(" sls=");
sb.append(this.sls);
sb.append(" incomingOpc=");
sb.append(this.incomingOpc);
sb.append(" incomingDpc=");
sb.append(this.incomingDpc);
sb.append(" outgoingDpc=");
sb.append(this.outgoingDpc);
sb.append(" destLR=");
if (this.destinationLocalReferenceNumber != null)
sb.append(this.destinationLocalReferenceNumber.getValue());
sb.append(" errorCause=");
if (this.errorCause != null)
sb.append(this.errorCause.getValue());
sb.append(" isMtpOriginated=");
sb.append(this.isMtpOriginated);
sb.append("]");
return sb.toString();
}
}