public void DataRequest( MacAddressingMode srcAddrMode, MacAddress dstAddr, UInt16 dstPanId, ref Frame msdu, Byte msduHandle, TxOptions options, SecurityOptions securityOptions, DataConfirmHandler handler) { TaskDataRequest task = new TaskDataRequest( srcAddrMode, dstAddr, dstPanId, msdu, msduHandle, options, securityOptions, handler); if (!_taskQueue.Add(task)) { Frame.Release(ref msdu); if (handler != null) { handler.Invoke(this, msduHandle, MacEnum.Congested); } } msdu = null; // in any case, remove frame ownership from caller }
public TaskDataRequest( MacAddressingMode srcAddrMode, MacAddress dstAddr, UInt16 dstPANId, Frame msdu, Byte msduHandle, TxOptions options, SecurityOptions securityOptions, DataConfirmHandler handler) : base(TaskType.DataRequest) { this.srcAddrMode = srcAddrMode; this.dstAddr = dstAddr; this.dstPANId = dstPANId; this.msdu = msdu; this.msduHandle = msduHandle; this.options = options; this.securityOptions = securityOptions; this.handler = handler; }
/// <summary> /// Send a Mac SDU using context information. SrcAddr is automatically choosen. /// </summary> /// <param name="msdu">The frame to sent.</param> /// <param name="context">Sent context. If null, frame is broadcasted</param> private void MacDataRequestReal( bool useExtAddr, UInt16 nextHopAddrShort, UInt64 nextHopAddrExt, ref Frame sdu, Byte sduHandle, DataConfirmHandler handler) { // srcAddr: always use short addr when available MacAddressingMode srcAddrMode = new MacAddressingMode(); if (_addrShort == cUnallocatedShortAddr) srcAddrMode = MacAddressingMode.ExtendedAddress; else srcAddrMode = MacAddressingMode.ShortAddress; MacAddress dstAddr = new MacAddress(); if (useExtAddr) dstAddr.ExtendedAddress = nextHopAddrExt; else dstAddr.ShortAddress = nextHopAddrShort; byte msduHandle; Mac.DataConfirmHandler macHandler; bool broadcast = (!useExtAddr) && IsMulticast(nextHopAddrShort); if (!broadcast || handler != null) { // need a send context MessageContext.Context context = _messageContext.GetFreeContext(); if (context == null) { // busy if (handler != null) handler.Invoke(_net, sduHandle, Status.Busy); Frame.Release(ref sdu); return; } context.useExtAddr = useExtAddr; context.nextHopShort = nextHopAddrShort; context.nextHopExt = nextHopAddrExt; context.dataSduHandle = sduHandle; context.dataHandler = handler; macHandler = MacDataConfirmHandler; msduHandle = context.macSduHandle; } else { macHandler = null; msduHandle = MessageContext.cHandleDontCare; } TxOptions tx = new TxOptions(); if (!broadcast) tx.AcknowledgedTransmission = true; _mac.DataRequest( srcAddrMode, dstAddr, _panId, ref sdu, msduHandle, tx, new SecurityOptions(), macHandler); Frame.Release(ref sdu); }
public void DataRequest( MacAddressingMode srcAddrMode, MacAddress dstAddr, UInt16 dstPanId, ref Frame msdu, Byte msduHandle, TxOptions options, SecurityOptions securityOptions, DataConfirmHandler handler) { TaskDataRequest task = new TaskDataRequest( srcAddrMode, dstAddr, dstPanId, msdu, msduHandle, options, securityOptions, handler); if (!_taskQueue.Add(task)) { Frame.Release(ref msdu); if (handler != null) handler.Invoke(this, msduHandle, MacEnum.Congested); } msdu = null; // in any case, remove frame ownership from caller }
public MacAddress(UInt64 extendedAddress) { _mode = MacAddressingMode.ExtendedAddress; _shortAddress = 0; _extendedAddress = extendedAddress; }
public MacAddress(UInt16 shortAddress) { _mode = MacAddressingMode.ShortAddress; _shortAddress = shortAddress; _extendedAddress = 0; }