public MpanContainer this[NodeGroupId peerGroupId] { get { if (!_table.ContainsKey(peerGroupId)) { throw new IndexOutOfRangeException("mpan container for such group id doesn't exist"); } return(_table[peerGroupId]); } }
public NonceContainer this[OrdinalPeerNodeId peerNodeId] { get { if (!_table.ContainsKey(peerNodeId)) { throw new IndexOutOfRangeException("nonce container for such peer id doesn't exist"); } return(_table[peerNodeId]); } }
public byte GetTxSequenceNumber(InvariantPeerNodeId peerNodeId) { byte ret = 0; lock (_synchObject) { if (_table.ContainsKey(peerNodeId)) { ret = _table[peerNodeId].TxSequenceNumber; } else if (_txSequenceNumberTable.ContainsKey(peerNodeId)) { ret = ++_txSequenceNumberTable[peerNodeId]; } else { ret = 0x55; _txSequenceNumberTable.Add(peerNodeId, ret); } } return(ret); }
/// <summary> /// Adds new nonce with Receiver state to table /// </summary> /// <param name="peerNodeId">Sender node id</param> /// <param name="receiverNonce">16 bytes receiver nonce</param> /// <param name="sequenceNumber">Sequence number</param> public void Add(InvariantPeerNodeId peerNodeId, byte[] receiverNonce, byte txSequenceNumber, byte rxSequenceNumber) { lock (_synchObject) { if (!_table.ContainsKey(peerNodeId)) { _table.Add(peerNodeId, new SpanContainer(receiverNonce, txSequenceNumber, rxSequenceNumber)); } else if (_table.ContainsKey(peerNodeId) && _table[peerNodeId].SpanState == SpanStates.None) { _table[peerNodeId].SetReceiversNonceState(receiverNonce); _table[peerNodeId].TxSequenceNumber = txSequenceNumber; _table[peerNodeId].RxSequenceNumber = rxSequenceNumber; } else { throw new InvalidOperationException("Nonce with specified peerNodeId already exists"); } BackupTxSequenceNumber(peerNodeId); } }