/// <summary> /// Generates an MIH Message based on a Link_Action_Response object. /// </summary> /// <param name="srcID">The source MIH ID.</param> /// <param name="dstID">The destination MIH ID</param> /// <param name="tid">The transaction ID, use the same as the request message.</param> /// <param name="laresp">The Link_Action_Response object to be the content of the message.</param> /// <returns>The MIH message to be sent to the MIHF.</returns> public static Message Link_Action_Response_Builder(ID srcID, ID dstID, ushort tid, Link_Action_Response laresp) { Message m = new Message(); m.MIHHeader = new MIHHeader(); MessageID mID = new MessageID(MessageID.ServiceIdentifier.COMMAND_SERVICE, MessageID.OperationCode.CONFIRM, (ushort)AIDCommandService.MIH_LINK_ACTIONS); m.MIHHeader.MID = mID; m.MIHHeader.TransactionID = tid; m.MIHHeader.VersionValue = 1; if (laresp.ScanResults.Count > 0) m.Payload = new Payload(dstID, srcID, Serialization.SerializeToTLV(TLV_VALUES.TLV_STATUS, BitConverter.GetBytes((int)laresp.Status).Take(1).ToArray()), Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_SCAN_RSP_LIST, Serialization.EncodingList(laresp.scanResultsAsByteArrayList().ToArray())), Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_AC_RESULT, BitConverter.GetBytes((int)laresp.Result).Take(1).ToArray())); else m.Payload = new Payload(dstID, srcID, Serialization.SerializeToTLV(TLV_VALUES.TLV_STATUS, BitConverter.GetBytes((int)laresp.Status).Take(1).ToArray()), Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_AC_RESULT, BitConverter.GetBytes((int)laresp.Result).Take(1).ToArray())); m.MIHHeader.PayloadLength = (ushort)m.Payload.PayloadValue.Length; return m; }