Exemple #1
0
        public void PackTest(string message, bool compact)
        {
            // Arrange
            _packet = new SipPacket(compact);

            var offset = 0;
            var bytes  = new byte[0];

            if (compact)
            {
                foreach (var item in _compactMapper)
                {
                    message = message.Replace(item.Key, item.Value);
                }
            }
            var lines = message.Split("\r\n", StringSplitOptions.RemoveEmptyEntries);

            // Act
            UnpackTest(message);
            _packet.Pack(ref bytes, ref offset);
            var newLine = Encoding.ASCII.GetString(bytes).Split("\r\n", StringSplitOptions.RemoveEmptyEntries);

            // Assert
            Assert.AreNotEqual(offset, 0);
            Assert.AreEqual(offset, bytes.Length);
            CollectionAssert.AreEquivalent(lines, newLine);
        }
Exemple #2
0
        public void Setup()
        {
            _compactMapper = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase)
            {
                { "\r\nVia:", "\r\nv:" },
                { "\r\nFrom:", "\r\nf:" },
                { "\r\nTo:", "\r\nt:" },
                { "\r\nCall-ID:", "\r\ni:" },
                { "\r\nContact:", "\r\nm:" },
                { "\r\nContent-Type:", "\r\nc:" },
                { "\r\nContent-Length:", "\r\nl:" },
            };

            _via = new SipVia()
            {
                Protocol = "UDP",
                Aliase   = "192.168.56.1:5061",
                Branch   = "z9hG4bKPj3e715762683b4c95b5609f613dcee8bf",
            };
            _from = new SipUri("115", "192.168.56.105", "94b1fa2000614ec090b2c45af2d4cee1");
            _to   = new SipUri("31337", "192.168.56.105", "as56ee551e");

            _callId = "c7e6ad40e49e44d4b665d621c4627149";
            _cseq   = 16564;
            _packet = new SipPacket();
        }
Exemple #3
0
        public void ParseProtocol(Packet packet, StatisticsRecord statisticsRecord)
        {
            SipPacket sipPacket = (SipPacket)packet;

            statisticsRecord.ApplicationLayer = sipPacket.GetType().Name.Replace("Packet", "");
        }