/// <summary> /// Sends an SCTP control packet with an abort chunk to terminate /// the association. /// </summary> /// <param name="errorCause">The cause of the abort.</param> public void Abort(ISctpErrorCause errorCause) { if (!_wasAborted) { _wasAborted = true; bool tBit = _remoteVerificationTag != 0; var abortChunk = new SctpAbortChunk(tBit); abortChunk.AddErrorCause(errorCause); SendChunk(abortChunk); OnAborted?.Invoke(errorCause.CauseCode.ToString()); _dataSender.Close(); } }
/// <summary> /// Send an SCTP packet with one of the error type chunks (ABORT or ERROR) to the remote peer. /// </summary> /// <param name=isAbort">Set to true to use an ABORT chunk otherwise an ERROR chunk will be used.</param> /// <param name="desintationPort">The SCTP destination port.</param> /// <param name="sourcePort">The SCTP source port.</param> /// <param name="initiateTag">If available the initial tag for the remote peer.</param> /// <param name="error">The error to send.</param> private void SendError( bool isAbort, ushort destinationPort, ushort sourcePort, uint initiateTag, ISctpErrorCause error) { SctpPacket errorPacket = new SctpPacket( destinationPort, sourcePort, initiateTag); SctpErrorChunk errorChunk = isAbort ? new SctpAbortChunk(true) : new SctpErrorChunk(); errorChunk.AddErrorCause(error); errorPacket.AddChunk(errorChunk); var buffer = errorPacket.GetBytes(); Send(null, buffer, 0, buffer.Length); }
/// <summary> /// Adds an additional error cause parameter to the chunk. /// </summary> /// <param name="errorCause">The additional error cause to add to the chunk.</param> public void AddErrorCause(ISctpErrorCause errorCause) { ErrorCauses.Add(errorCause); }
/// <summary> /// Creates a new ERROR chunk. /// </summary> /// <param name="errorCause">The initial error cause to set on this chunk.</param> public SctpErrorChunk(ISctpErrorCause errorCause) : base(SctpChunkType.ERROR) { ErrorCauses.Add(errorCause); }