private ReConfigChunk makeSSNResets() { ReConfigChunk reply = new ReConfigChunk(); // create a new thing //logger.LogDebug($"SCTP closing {listOfStreamsToReset.Count} stream."); List <int> streamsL = new List <int>(); lock (listOfStreamsToReset) { foreach (var s in listOfStreamsToReset) { if (s.InboundIsOpen()) { streamsL.Add(s.getNum()); } } } int[] streams = streamsL.ToArray(); if (streams.Length > 0) { OutgoingSSNResetRequestParameter rep = new OutgoingSSNResetRequestParameter(nextNearNo(), farSeqno - 1, assoc.getNearTSN()); rep.setStreams(streams); reply.addParam(rep); } streamsL.Clear(); lock (listOfStreamsToReset) { foreach (var s in listOfStreamsToReset) { if (s.OutboundIsOpen()) { streamsL.Add(s.getNum()); } } } streams = streamsL.ToArray(); if (streams.Length > 0) { IncomingSSNResetRequestParameter rep = new IncomingSSNResetRequestParameter(nextNearNo()); rep.setStreams(streams); reply.addParam(rep); } //logger.LogDebug("reconfig chunk is " + reply.ToString()); return(reply); }
/* * https://tools.ietf.org/html/rfc6525 */ public Chunk[] deal(ReConfigChunk rconf) { Chunk[] ret = new Chunk[1]; ReConfigChunk reply = null; //logger.LogDebug("Got a reconfig message to deal with"); if (haveSeen(rconf)) { // if not - is this a repeat reply = getPrevious(rconf); // then send the same reply } if (reply == null) { // not a repeat then reply = new ReConfigChunk(); // create a new thing if (rconf.hasOutgoingReset()) { OutgoingSSNResetRequestParameter oreset = rconf.getOutgoingReset(); int[] streams = oreset.getStreams(); if (streams.Length == 0) { streams = assoc.allStreams(); } if (timerIsRunning()) { markAsAcked(rconf); } // if we are behind, we are supposed to wait until we catch up. if (oreset.getLastAssignedTSN() > assoc.getCumAckPt()) { //logger.LogDebug("Last assigned > farTSN " + oreset.getLastAssignedTSN() + " v " + assoc.getCumAckPt()); foreach (int s in streams) { SCTPStream defstr = assoc.getStream(s); // AC: All this call did was set an unused local variable. Removed for now. //defstr.setDeferred(true); } ReconfigurationResponseParameter rep = new ReconfigurationResponseParameter(); rep.setSeq(oreset.getReqSeqNo()); rep.setResult(ReconfigurationResponseParameter.IN_PROGRESS); reply.addParam(rep); } else { // somehow invoke this when TSN catches up ?!?! ToDo //logger.LogDebug("we are up-to-date "); ReconfigurationResponseParameter rep = new ReconfigurationResponseParameter(); rep.setSeq(oreset.getReqSeqNo()); int result = streams.Length > 0 ? ReconfigurationResponseParameter.SUCCESS_PERFORMED : ReconfigurationResponseParameter.SUCCESS_NOTHING_TO_DO; rep.setResult((uint)result); // assume all good foreach (int s in streams) { SCTPStream cstrm = assoc.delStream(s); if (cstrm == null) { //logger.LogError("Close a non existant stream"); rep.setResult(ReconfigurationResponseParameter.ERROR_WRONG_SSN); break; // bidriectional might be a problem here... } else { cstrm.reset(); } } reply.addParam(rep); } } // ponder putting this in a second chunk ? if (rconf.hasIncomingReset()) { IncomingSSNResetRequestParameter ireset = rconf.getIncomingReset(); /*The Re-configuration * Response Sequence Number of the Outgoing SSN Reset Request * Parameter MUST be the Re-configuration Request Sequence Number * of the Incoming SSN Reset Request Parameter. */ OutgoingSSNResetRequestParameter rep = new OutgoingSSNResetRequestParameter(nextNearNo(), ireset.getReqNo(), assoc.getNearTSN()); int[] streams = ireset.getStreams(); rep.setStreams(streams); if (streams.Length == 0) { streams = assoc.allStreams(); } foreach (int s in streams) { SCTPStream st = assoc.getStream(s); if (st != null) { st.setClosing(true); } } reply.addParam(rep); // set outbound timer running here ??? //logger.LogDebug("Ireset " + ireset); } } if (reply.hasParam()) { ret[0] = reply; // todo should add sack here //logger.LogDebug("about to reply with " + reply.ToString()); } else { ret = null; } return(ret); }