Exemple #1
0
 public bool ContainsActiveBursts(NormalBurst burst)
 {
     lock (ActiveBursts)
     {
         return(ActiveBursts.Contains(burst));
     }
 }
Exemple #2
0
 public void RemoveActiveBurst(NormalBurst burst)
 {
     lock (ActiveBursts)
     {
         ActiveBursts.Remove(burst);
     }
 }
Exemple #3
0
 public void AddActiveBurst(NormalBurst burst)
 {
     lock (ActiveBursts)
     {
         ActiveBursts.AddLast(burst);
     }
 }
Exemple #4
0
 public void AddUsedBurst(NormalBurst burst)
 {
     if (LogBursts)
     {
         lock (UsedBursts)
         {
             UsedBursts.AddLast(burst);
         }
     }
 }
Exemple #5
0
        private StatusLamp GetLamp(NormalBurst burst)
        {
            lock (BurstLampMap)
            {
                if (BurstLampMap.ContainsKey(burst))
                {
                    return(BurstLampMap[burst]);
                }
            }

            StatusLamp lamp = new StatusLamp();

            lamp.Margin = new Padding(1);
            lamp.Width  = 20;
            lamp.Height = 20;

            lamp.MouseEnter += (object sender, EventArgs e) =>
            {
                lock (lblDetails)
                {
                    CurrentHoveredBurst = burst;
                    lblDetails.Text     = "[" + burst.Name + "], ARFCN: " + burst.ARFCN + " TS: " + burst.TimeSlot + ", " + BurstStatusMap[burst];
                }
            };

            lamp.MouseLeave += (object sender, EventArgs e) =>
            {
                lock (lblDetails)
                {
                    CurrentHoveredBurst = null;
                    lblDetails.Text     = "---";
                }
            };

            lock (BurstLampMap)
            {
                BurstStatusMap.Add(burst, "---");
                BurstLampMap.Add(burst, lamp);
            }

            RebuildLamps();

            return(lamp);
        }
Exemple #6
0
        public void Handle(GSMParameters param, NormalBurst source, L3Handler l3, byte[] l2Data, int startOffset)
        {
            if (param.PacketDumper != null)
            {
                param.PacketDumper.WriteL2Data(l2Data);
            }

            Builder.Length = 0;

            /* BCCH and CCCH packets have pseudo L2 headers (GSM 04.07 11.3.1) */
            if (source.GetType() == typeof(BCCHBurst) || source.GetType() == typeof(CCCHBurst))
            {
                Builder.Append("Pseudo L2 Header").Append(Environment.NewLine);

                if (source.ChannelEncrypted)
                {
                    Builder.Append("======= encrypted =======").Append(Environment.NewLine);
                }

                /* call LUA script */
                if (param.LuaVm != null)
                {
                    LuaHelpers.CallFunction(param.LuaVm, "L2DataReceived", true, source, null, param);
                }

                /* pass to L3 handler if not empty and skip pseudo length */
                if (!PacketIsEmpty(l2Data, 1))
                {
                    l3.Handle(l2Data, 1, param);
                }
            }
            else
            {
                /* always show empty/multiframe messages if requested */
                ShowMessage = ShowAllMessages;

                /* show if encrypted */
                if (source.ChannelEncrypted)
                {
                    ShowMessage |= ShowCryptedMessages;
                    Builder.Append("======= encrypted =======").Append(Environment.NewLine);
                }

                L2Data.Payload     = l2Data;
                L2Data.StartOffset = startOffset;

                /* call LUA script */
                if (param.LuaVm != null)
                {
                    LuaHelpers.CallFunction(param.LuaVm, "L2DataReceived", true, source, L2Data, param);
                }

                if (L3Handler.ExceptFieldsEnabled || ShowMessage)
                {
                    Builder.Append("SAPI: ").Append(L2Data.SAPI).Append("  C/R: ").Append((L2Data.CR ? "1" : "0")).Append("  EA: ").Append((L2Data.EA ? "1" : "0")).Append("  ");
                    Builder.Append("M: ").Append((L2Data.M ? "1" : "0")).Append("  ");
                    Builder.Append("EL: ").Append((L2Data.EL ? "1" : "0")).Append("  ");
                    Builder.Append("L: ").Append(L2Data.Length).Append("  ");

                    switch (L2Data.FrameFormat)
                    {
                    case eFrameFormat.S_Format:
                        Builder.Append("S Format, N(R)=").Append(L2Data.NR).Append(" S=").Append(L2Data.S).Append(" ").Append((eSupervisory)L2Data.S);
                        break;

                    case eFrameFormat.U_Format:
                        Builder.Append("U Format, U=").Append(L2Data.U).Append(" ").Append((eUnnumbered)L2Data.U);
                        break;

                    case eFrameFormat.I_Format:
                        Builder.Append("I Format, N(R)=").Append(L2Data.NR).Append(" N(S)=").Append(L2Data.NS).Append(" ");
                        break;
                    }
                }

                /* check if there is enough space in the buffer */
                if (L2Data.Length + packetBufferOffset <= packetBuffer.Length && L2Data.Length + L2Data.DataStart <= L2Data.Payload.Length)
                {
                    /* dont buffer when its the same frame number (retransmission) */
                    if (!L2Data.M || LastNS < L2Data.NS)
                    {
                        Array.Copy(L2Data.Payload, L2Data.DataStart, packetBuffer, packetBufferOffset, L2Data.Length);
                        packetBufferOffset += L2Data.Length;
                        LastNS              = L2Data.NS;
                    }
                    else
                    {
                        if (L3Handler.ExceptFieldsEnabled || ShowMessage)
                        {
                            Builder.Append("!! Retransmission !! ");
                        }
                    }
                }
                else
                {
                    if (DumpFaulty)
                    {
                        Builder.Append("Faulty length?! Length = ").Append((packetBufferOffset + L2Data.Length)).Append(Environment.NewLine);
                        Builder.Append("Raw L2 data").Append(Environment.NewLine);
                        Builder.Append("    ").Append(DumpBytes(l2Data)).Append(Environment.NewLine);
                        ShowMessage = true;
                    }
                }

                /* that counter is just for convinience */
                NumPackets++;

                /* when reached the last packet, pass it to L3 handler */
                if (!L2Data.M)
                {
                    if (L3Handler.ExceptFieldsEnabled || ShowMessage)
                    {
                        if (NumPackets > 1)
                        {
                            Builder.Append("(packet ").Append(NumPackets).Append(", total ").Append(packetBufferOffset).Append(" bytes)").Append(Environment.NewLine);
                        }
                        else
                        {
                            Builder.Append(Environment.NewLine);
                        }
                    }

                    /* but only pass it through when there is any data */
                    if (packetBufferOffset > 0)
                    {
                        /* allocate a new array with the correct size */
                        byte[] buf = new byte[packetBufferOffset];
                        Array.Copy(packetBuffer, buf, buf.Length);

                        if (!PacketIsEmpty(buf))
                        {
                            l3.Handle(buf, 0, param);
                        }
                    }

                    /* reset the buffer etc */
                    packetBufferOffset = 0;
                    for (int pos = 0; pos < packetBuffer.Length; pos++)
                    {
                        packetBuffer[pos] = 0xCC;
                    }
                    NumPackets = 0;
                    LastNS     = -1;
                }
                else if (L3Handler.ExceptFieldsEnabled || ShowMessage)
                {
                    Builder.Append("(packet ").Append(NumPackets).Append(")").Append(Environment.NewLine);
                }
            }

            if (DumpRawData && (L3Handler.ExceptFieldsEnabled || ShowMessage))
            {
                Builder.Append("Raw L2 data").Append(Environment.NewLine);
                Builder.Append("    ").Append(DumpBytes(l2Data)).Append(Environment.NewLine);
            }

            StatusMessage = Builder.ToString();
        }
Exemple #7
0
 public void Handle(GSMParameters param, NormalBurst source, L3Handler l3, byte[] l2Data)
 {
     Handle(param, source, l3, l2Data, 0);
 }