Exemplo n.º 1
0
        /// <summary>
        /// Generates an MIH Message based on a Link_Get_Parameters_Confirm 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="lgpconfirm">The Link_Event_SubscribeConfirm object to be the content of the message.</param>
        /// <returns>The MIH message to be sent to the MIHF.</returns>
        public static Message Get_Parameters_Response_Builder(ID srcID, ID dstID, ushort tid, Link_Get_Parameters_Confirm lgpconfirm)
        {
            Message m = new Message();
            m.MIHHeader = new MIHHeader();
            MessageID mID = new MessageID(MessageID.ServiceIdentifier.COMMAND_SERVICE, MessageID.OperationCode.CONFIRM, (ushort)AIDCommandService.MIH_LINK_GET_PARAMETERS);
            m.MIHHeader.MID = mID;
            m.MIHHeader.TransactionID = tid;
            m.MIHHeader.VersionValue = 1;

            byte[] st = new byte[1];
            st[0] = BitConverter.GetBytes((int)lgpconfirm.Status)[0];

            m.Payload = new Payload(srcID, dstID,
                Serialization.SerializeToTLV(TLV_VALUES.TLV_STATUS, st),
                Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_PARAMETERS_STATUS_LIST, Serialization.EncodingList(lgpconfirm.LinkParamListAsByteArray())),
                Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_STATES_RSP, Serialization.EncodingList(lgpconfirm.LinkStatesListAsByteArray())),
                Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_DESCRIPTOR_RSP, Serialization.EncodingList(lgpconfirm.LinkDescListAsByteArray())));

            m.MIHHeader.PayloadLength = (ushort)m.Payload.PayloadValue.Length;
            return m;
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method is called to handle a Get_Parameters request
        /// </summary>
        /// <param name="m">The serialized Get_Parameters_Request message.</param>
        public static void HandleGetParameters(Message m)
        {
            ConnectionHelper ch = Program.toMihf;
            ushort transactionID = m.MIHHeader.TransactionID;
            Payload.TLVIterator it = m.Payload.GetTLVIterator();
            ID srcID = new ID(new OctetString(it.Next().Value));
            ID dstID = new ID(new OctetString(it.Next().Value));
            Link_Get_Parameters_Request lgpr = new Link_Get_Parameters_Request(MIHDeserializer.DeserializeLinkParamRequest(it.Next()),
                new System.Collections.BitArray(it.Next().Value.Reverse().ToArray()),
                new System.Collections.BitArray(it.Next().Value.Reverse().ToArray()));

            Link_Get_Parameters_Confirm lgpc = new Link_Get_Parameters_Confirm();
            try
            {
                lgpc.LinkParametersStatusList = new List<Link_Param>(lgpr.LinkParametersRequest.Count);
                lgpc.LinkStatesRspList = new List<Link_Get_Parameters_Confirm.Link_States_Rsp>();
                lgpc.LinkDescRspList = new List<Link_Get_Parameters_Confirm.Link_Desc_Rsp>();
                foreach (Link_Param_Type lpt in lgpr.LinkParametersRequest)
                {
                    switch (lpt.AbsoluteType)
                    {
                        case Link_Param_Abs_Type.P80211_RSSI: lgpc.LinkParametersStatusList.Add(new Link_Param(lpt, Link_Param_802_11.GetRSSI_0)); break;
                        case Link_Param_Abs_Type.GEN_Data_Rate: lgpc.LinkParametersStatusList.Add(new Link_Param(lpt, Link_Param_Gen.DataRate_0)); break;
                        case Link_Param_Abs_Type.GEN_Sig_Strenth: lgpc.LinkParametersStatusList.Add(new Link_Param(lpt, Link_Param_Gen.SignalStrength_1)); break;
                        case Link_Param_Abs_Type.GEN_Packet_Error_Rate: lgpc.LinkParametersStatusList.Add(new Link_Param(lpt, Link_Param_Gen.PacketErrorRate_4)); break;
                    }
                }

                //-------LinkStates
                if (lgpr.LinkStatesRequest[0]) //OP_MODE
                    lgpc.LinkStatesRspList.Add(new Link_Get_Parameters_Confirm.Link_States_Rsp(Link_Get_Parameters_Confirm.Link_States_Rsp.Type.OP_MODE, (ushort)GenericInfo.WlanInterfaceInstance.OP_Mode_802_21));

                if (lgpr.LinkStatesRequest[1])
                    lgpc.LinkStatesRspList.Add(new Link_Get_Parameters_Confirm.Link_States_Rsp(Link_Get_Parameters_Confirm.Link_States_Rsp.Type.CHANNEL_ID, (ushort)GenericInfo.WlanInterfaceInstance.Channel));
                //-----------

                //-------LinkDesc
                if (lgpr.LinkDescriptorsRequest[0])
                    lgpc.LinkDescRspList.Add(new Link_Get_Parameters_Confirm.Link_Desc_Rsp(Link_Get_Parameters_Confirm.Link_Desc_Rsp.Type.NUM_CoS, 0)); //TODO (not supported)

                if (lgpr.LinkDescriptorsRequest[1])
                    lgpc.LinkDescRspList.Add(new Link_Get_Parameters_Confirm.Link_Desc_Rsp(Link_Get_Parameters_Confirm.Link_Desc_Rsp.Type.NUM_QUEUE, 1)); //TODO (not supported)
                //-----------

                lgpc.Status = STATUS.SUCCESS;
            }
            catch (Exception e) { lgpc.Status = STATUS.UNSPECIFIED_FAILURE;}

            Message toSend = ResponseBuilders.Get_Parameters_Response_Builder(dstID, srcID, m.MIHHeader.TransactionID, lgpc);

            if (Program.MESSAGE_DETAILS)
            {
                Console.WriteLine("Sending message: ("+m.MIHHeader.MID.AID+")");
                Connection.MIHProtocol.PacketReader.PrintMessage(toSend);
            }

            ch.Send(toSend.ByteValue);
        }
Exemplo n.º 3
0
        private void ResponseBuilder(List<Link_Param> linkParams)
        {
            Link_Get_Parameters_Confirm lgpc = new Link_Get_Parameters_Confirm();

            lgpc.Status = STATUS.SUCCESS;
            lgpc.LinkParametersStatusList = linkParams;

            Console.WriteLine(lgpc);
        }