public static void InitializeAsync(Action <int> callback) { var reader = new SipMessageReader(); reader.LoadTables(); ThreadPool.QueueUserWorkItem((stateInfo) => { callback(reader.CompileParseMethod()); }); }
public bool IsAccepted(SipMessageReader reader) { return reader.ContentType.Type.Equals(type) && reader.ContentType.Subtype.Equals(subtype) && reader.To.AddrSpec.User.StartsWith(userPrefix); }
public void Load() { var dfa = new SipMessageReader(); dfa.LoadTables(@"..\..\..\Sip.Message\Sip.Message.dfa"); dfa.SetDefaultValue(); dfa.Parse(new byte[] { 0 }, 0, 1); }
public bool CanFork(SipMessageReader response) { if (response.StatusCode.Value != 407 && response.StatusCode.Value != 401) return false; return trunk.UpdateChallenge(response.GetAnyChallenge()); }
protected SipMessageWriter GenerateResponse(SipMessageReader reader, StatusCodes statusCode) { var writer = GetWriter(); writer.WriteResponse(reader, statusCode); return writer; }
public void WriteHeader(SipMessageReader reader, int index) { Write(reader.Headers[index].Name, C.HCOLON); int headerBegin = reader.Headers[index].Value.Begin; switch (reader.Headers[index].HeaderName) { case HeaderNames.CallId: callId = CreateRange(reader.CallId, headerBegin); break; case HeaderNames.From: fromAddrspec = CreateRange(reader.From.AddrSpec.Value, headerBegin); fromTag = CreateRange(reader.From.Tag, headerBegin); fromEpid = CreateRange(reader.From.Epid, headerBegin); break; case HeaderNames.To: toAddrspec = CreateRange(reader.To.AddrSpec.Value, headerBegin); toTag = CreateRange(reader.To.Tag, headerBegin); toEpid = CreateRange(reader.To.Epid, headerBegin); break; case HeaderNames.CSeq: Method = reader.CSeq.Method; CSeq = reader.CSeq.Value; break; } Write(reader.Headers[index].Value, C.CRLF); }
public void GenerateForwardedRequest(SipMessageWriter writer, SipMessageReader reader, ArraySegment<byte> content, ConnectionAddresses fromConnectionAddress, int serverTransactionId) { Tracer.WriteInformation("LocalProxie.GenerateForwardedRequest"); recordRouteIndex = reader.Count.RecordRouteCount; writer.WriteRequestLine(reader.Method, binding.AddrSpec); //var msReceivedCid = fromConnectionAddress.ToLowerHexChars(serverTransactionId); //writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId, msReceivedCid); //writer.WriteRecordRoute(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, msReceivedCid); writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId); writer.WriteRecordRoute(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint); bool writeContact = true; for (int i = 0; i < reader.Count.HeaderCount; i++) { switch (reader.Headers[i].HeaderName) { case HeaderNames.MaxForwards: { int maxForwards = (reader.MaxForwards == int.MinValue) ? 70 : reader.MaxForwards; writer.WriteMaxForwards(maxForwards - 1); } break; case HeaderNames.Authorization: case HeaderNames.ProxyAuthorization: // remove exact authorization header break; case HeaderNames.To: writer.WriteToHeader(reader, i, binding.Epid); break; case HeaderNames.Contact: if (writeContact) { writer.WriteContact(reader.Contact[0].AddrSpec.User, binding.ConnectionAddresses.LocalEndPoint, binding.ConnectionAddresses.Transport, reader.Contact[0].SipInstance); writeContact = false; } break; default: writer.WriteHeader(reader, i); break; } } if (reader.ContentLength == int.MinValue) writer.WriteContentLength(content.Count); writer.WriteCustomHeaders(); writer.WriteCRLF(); writer.Write(content); }
public Dialog Create(SipMessageReader message, int localTag, ConnectionAddresses connectionAddresses) { var dialog = new Dialog(message, localTag, connectionAddresses); dictionary.Add(dialog.Id, dialog); return dialog; }
public void WriteResponse(SipMessageReader request, StatusCodes statusCode, ByteArrayPart localTag) { WriteStatusLine(statusCode); CopyViaToFromCallIdRecordRouteCSeq(request, statusCode, localTag); WriteContentLength(0); WriteCustomHeaders(); WriteCRLF(); }
public IncomingMessage(Transports transport, IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, int connectionId, SipMessageReader reader, ArraySegment<byte> readerData, ArraySegment<byte> contentData) { ConnectionAddresses = new ConnectionAddresses(transport, localEndPoint, remoteEndPoint, connectionId); Reader = reader; Header = readerData; Content = contentData; }
public IncomingMessage(ConnectionAddresses connectionAddresses, Connection connection) { ConnectionAddresses = connectionAddresses; Reader = connection.Reader; Header = connection.Header; Content = connection.Content; }
public bool IsChanged(SipMessageReader reader, int contactIndex) { return AddrSpec != reader.Contact[contactIndex].AddrSpec.Value || SipInstance != reader.Contact[contactIndex].SipInstance || Epid != reader.From.Epid || CallId != reader.CallId; }
public IncomingMessage(Connection connection) { ConnectionAddresses = new ConnectionAddresses(GetTransport(connection), connection.LocalEndPoint, new IPEndPoint(connection.RemoteEndPoint.Address, connection.RemoteEndPoint.Port), connection.Id); Reader = connection.Reader; Header = connection.Header; Content = connection.Content; }
/// <summary> /// DEPRECATED!!! Не удобно читать код, не видно откуда CallLegTransactionDoesNotExist /// </summary> public Dialog GetOrCreate(SipMessageReader reader, ConnectionAddresses connectionAddresses, out StatusCodes statusCode) { var dialog = GetOrCreate(reader, connectionAddresses); statusCode = (dialog == null) ? StatusCodes.CallLegTransactionDoesNotExist : StatusCodes.OK; return dialog; }
public static SipMessageReader GetEmpty() { connectionId = -1; if (Value == null) Value = new SipMessageReader(); Value.SetDefaultValue(); return Value; }
public Dialog GetOrCreate(SipMessageReader reader, ConnectionAddresses connectionAddresses) { Dialog dialog = null; if (reader.To.Tag.IsInvalid) dialog = Create(reader, NewLocalTag(), connectionAddresses); else dialog = Get(reader); return dialog; }
public void GenerateForwardedRequest(SipMessageWriter writer, SipMessageReader reader, ArraySegment<byte> content, ConnectionAddresses fromConnectionAddress, int serverTransactionId) { dialog2 = new Dialog(reader, tag, fromConnectionAddress); //trunk.AddDialog2(tag, dialog2); ///////////////////////////////////////////////////////////////////////////////// writer.WriteRequestLine(reader.Method, dialog1.RemoteUri); //var msReceivedCid = fromConnectionAddress.ToLowerHexChars(serverTransactionId); //writer.WriteVia(dialog1.Transport, dialog1.LocalEndPoint, TransactionId, msReceivedCid); writer.WriteVia(dialog1.Transport, dialog1.LocalEndPoint, TransactionId); for (int i = 0; i < reader.Count.HeaderCount; i++) { switch (reader.Headers[i].HeaderName) { case HeaderNames.MaxForwards: writer.WriteMaxForwards((reader.MaxForwards == int.MinValue) ? 69 : reader.MaxForwards - 1); break; case HeaderNames.Contact: writer.WriteContact(dialog1.LocalEndPoint, dialog1.Transport); break; case HeaderNames.To: writer.WriteTo(dialog1.RemoteUri, dialog1.RemoteTag); break; case HeaderNames.From: writer.WriteFrom(reader.From.AddrSpec.Value, tag); break; case HeaderNames.Authorization: break; default: writer.WriteHeader(reader, i); break; case HeaderNames.Via: via = reader.Headers[i].Value.DeepCopy(); break; } } if (reader.ContentLength == int.MinValue) writer.WriteContentLength(content.Count); writer.WriteCustomHeaders(); writer.WriteCRLF(); writer.Write(content); }
public static void Update(int currentConnectionId, ArraySegment<byte> header) { connectionId = currentConnectionId; if (Value == null) Value = new SipMessageReader(); Value.SetDefaultValue(); Value.Parse(header.Array, header.Offset, header.Count); Value.SetArray(header.Array); }
public IncomingMessage(ServerAsyncEventArgs e, SipMessageReader reader, ArraySegment<byte> content) { if (e.LocalEndPoint.Protocol != ServerProtocol.Udp) throw new ArgumentException(); ConnectionAddresses = new ConnectionAddresses(Transports.Udp, e.LocalEndPoint, new IPEndPoint(e.RemoteEndPoint.Address, e.RemoteEndPoint.Port), ServerAsyncEventArgs.AnyNewConnectionId); Reader = reader; Content = content; Header = new ArraySegment<byte>(e.Buffer, e.Offset, e.BytesTransferred - content.Count); }
public void SetUp() { { var dfa = new SipMessageReader(); dfa.LoadTables(@"..\..\..\Server\dll\Sip.Message.dfa"); dfa.SetDefaultValue(); dfa.Parse(new byte[] { 0 }, 0, 1); } { HttpMessageReader.LoadTables(@"..\..\..\Server\dll\"); var dfa = new HttpMessageReader(); dfa.SetDefaultValue(); dfa.Parse(new byte[] { 0 }, 0, 1); } }
public Binding(SipMessageReader reader, int contactIndex, int expires1, ConnectionAddresses connectionAddresses) { ConnectionAddresses = connectionAddresses; int length = reader.Contact[contactIndex].AddrSpec.Value.Length + reader.Contact[contactIndex].SipInstance.Length + reader.From.Epid.Length + reader.CallId.Length; bytes = new byte[length + 8 - length % 8]; marker1 = bytes.CopyFrom(reader.Contact[contactIndex].AddrSpec.Value, 0); marker2 = bytes.CopyFrom(reader.Contact[contactIndex].SipInstance, marker1); marker3 = bytes.CopyFrom(reader.From.Epid, marker2); marker4 = bytes.CopyFrom(reader.CallId, marker3); Update(reader.CSeq.Value, expires1); }
private static ByteArrayPart GetDialogId(SipMessageReader message) { if (Dialog.HasValidId(message) == false) return ByteArrayPart.Invalid; int length = Dialog.GetIdLength(message); if (dialogIdBytes == null || dialogIdBytes.Length < length) dialogIdBytes = new byte[length]; var part = new ByteArrayPart() { Bytes = dialogIdBytes, Begin = 0, End = length, }; Dialog.GenerateId(message, part.Bytes); return part; }
private int Calculate(SipMessageReader request, out int routeCount1) { int length = request.CallId.Length + // 8 + request.From.Tag.Length + request.To.AddrSpec.Value.Length + request.From.AddrSpec.Value.Length + request.Contact[0].AddrSpec.Value.Length + request.From.Epid.Length; routeCount1 = 0; for (int i = 0; i < request.Count.HeaderCount; i++) if (request.Headers[i].HeaderName == HeaderNames.RecordRoute) { length += request.Headers[i].Value.Length + 2; routeCount1++; } return length; }
public Dialog(SipMessageReader response, ConnectionAddresses connectionAddresses) { this.transport = connectionAddresses.Transport; this.localEndPoint = connectionAddresses.LocalEndPoint; this.remoteEndPoint = connectionAddresses.RemoteEndPoint; localCseq = response.CSeq.Value; remoteCseq = 0; int length = Calculate(response, out routeCount) + response.To.Tag.Length; bytes = new byte[length]; marker1 = bytes.CopyFrom(response.CallId, 0); marker2 = bytes.CopyFrom(response.From.Tag, marker1); marker3 = bytes.CopyFrom(response.To.Tag, marker2); marker4 = bytes.CopyFrom(response.From.AddrSpec.Value, marker3); marker5 = bytes.CopyFrom(response.To.AddrSpec.Value, marker4); marker6 = bytes.CopyFrom(response.From.Epid, marker5); markerN = bytes.CopyFrom(response.Contact[0].AddrSpec.Value, marker6); CopyRecordRoute(response); }
private readonly int remoteCseq; // why readonly ?! public Dialog(SipMessageReader request, int localTag, ConnectionAddresses connectionAddresses) { this.transport = connectionAddresses.Transport; this.localEndPoint = connectionAddresses.LocalEndPoint; this.remoteEndPoint = connectionAddresses.RemoteEndPoint; localCseq = 0; remoteCseq = request.CSeq.Value; int length = Calculate(request, out routeCount) + 8; bytes = new byte[length]; marker1 = bytes.CopyFrom(request.CallId, 0); HexEncoding.GetLowerHexChars(localTag, bytes, marker1); marker2 = marker1 + 8; marker3 = bytes.CopyFrom(request.From.Tag, marker2); marker4 = bytes.CopyFrom(request.To.AddrSpec.Value, marker3); marker5 = bytes.CopyFrom(request.From.AddrSpec.Value, marker4); marker6 = bytes.CopyFrom(request.From.Epid, marker5); markerN = bytes.CopyFrom(request.Contact[0].AddrSpec.Value, marker6); CopyRecordRoute(request); }
public void WriteToHeader(SipMessageReader reader, int index, ByteArrayPart epid1) { if (reader.To.Epid.IsNotEmpty || epid1.Length <= 0) { WriteHeader(reader, index); } else { Write(C.To, C.HCOLON); int headerBegin = reader.Headers[index].Value.Begin; toAddrspec = CreateRange(reader.To.AddrSpec.Value, headerBegin); toTag = CreateRange(reader.To.Tag, headerBegin); Write(reader.Headers[index].Value); Write(C._epid_); toEpid = new Range(end, epid1.Length); Write(epid1); Write(C.CRLF); } }
private void ParseSipMessage(string message) { var bytes = Encoding.UTF8.GetBytes(message); sipExpected = new SipMessageReader(); sipExpected.SetDefaultValue(); int parsed = sipExpected.Parse(bytes, 0, bytes.Length); sipExpected.SetArray(bytes); if (sipExpected.ContentLength < 0) sipExpected.ContentLength = 0; sipHeader = message.Substring(0, parsed); sipContent = message.Substring(parsed); }
private void Validate(string messageText, bool addKeepAlive, int messagesCount, IEnumerable<int> splitSizes, bool detachBuffer, bool websocket) { var message = Encoding.UTF8.GetBytes(messageText); var expected = new SipMessageReader(); expected.SetDefaultValue(); int parsed = expected.Parse(message, 0, message.Length); expected.SetArray(message); if (expected.ContentLength < 0) expected.ContentLength = 0; var expectedUri = expected.RequestUri.Value.ToString(); var content = Encoding.UTF8.GetString(message, parsed, message.Length - parsed); if (addKeepAlive) message = Encoding.UTF8.GetBytes("\r\n\r\n" + messageText + "\r\n\r\n\r\n\r\n\r\n\r\n"); var extra = new byte[0]; if (websocket) extra = PrepareForWebsocket(message); var stream = CreateStream(messagesCount, extra, message); int headersLength = messageText.IndexOf("\r\n\r\n") + 4; var headersText = messageText.Substring(0, headersLength); int oldUsedBuffers = EventArgsManager.Created - EventArgsManager.Queued; ServerAsyncEventArgs e = null; using (var connection = new Connection()) using (var threads = new Threads(connection)) { if (websocket) connection.UpgradeToWebsocket(); foreach (int splitSize in splitSizes) { int realMessageCount = 0; for (int offset = 0; offset < stream.Length; offset += splitSize) { var info = "Split by: " + splitSize + "; Message #: " + realMessageCount + "\r\nMessage Sizes: " + message.Length + " " + (message.Length - content.Length) + " " + content.Length; if (e == null) e = EventArgsManager.Get(); e.BytesTransferred = Math.Min(splitSize, stream.Length - offset); Buffer.BlockCopy(stream, offset, e.Buffer, e.Offset, e.BytesTransferred); bool closeConnection; for (bool repeat = true; repeat; ) { //repeat = connection.Proccess(ref e, out closeConnection); repeat = threads.Proccess(ref e, out closeConnection); Assert.IsFalse(closeConnection, info); if (connection.IsMessageReady) { var actualHeaders = Encoding.UTF8.GetString(connection.Header.Array, connection.Header.Offset, connection.Header.Count); Assert.AreEqual(expected.Method, connection.Reader.Method, info); Assert.AreEqual(expectedUri, connection.Reader.RequestUri.Value.ToString(), info); Assert.AreEqual(headersLength, connection.Header.Count); Assert.AreEqual(headersText, actualHeaders); Assert.AreEqual(expected.ContentLength, connection.Content.Count); if (expected.ContentLength > 0) Assert.AreEqual(content, Encoding.UTF8.GetString(connection.Content.Array, connection.Content.Offset, connection.Content.Count), info); BufferHandle handle = new BufferHandle(); if (detachBuffer) handle = connection.Dettach(ref e); connection.ResetState(); realMessageCount++; if (detachBuffer) handle.Free(); } } } EventArgsManager.Put(ref e); Assert.AreEqual(messagesCount, realMessageCount); } } Assert.AreEqual(oldUsedBuffers, EventArgsManager.Created - EventArgsManager.Queued); }
public void CopyViaToFromCallIdRecordRouteCSeq(SipMessageReader request, StatusCodes statusCode, ByteArrayPart localTag) { for (int i = 0; i < request.Count.HeaderCount; i++) { switch (request.Headers[i].HeaderName) { case HeaderNames.RecordRoute: case HeaderNames.Via: WriteHeader(request.Headers[i]); break; case HeaderNames.CallId: WriteCallId(request.CallId); break; case HeaderNames.CSeq: CSeq = request.CSeq.Value; Method = request.CSeq.Method; WriteHeader(request.Headers[i]); break; case HeaderNames.From: Write(C.From__); fromAddrspec = new Range(end + request.From.AddrSpec.Value.Begin - request.Headers[i].Value.Begin, request.From.AddrSpec.Value.Length); if (request.From.Tag.IsValid) { fromTag = new Range(end + request.From.Tag.Begin - request.Headers[i].Value.Begin, request.From.Tag.Length); } if (request.From.Epid.IsValid) { fromEpid = new Range(end + request.From.Epid.Begin - request.Headers[i].Value.Begin, request.From.Epid.Length); } Write(request.Headers[i].Value); WriteCRLF(); break; case HeaderNames.To: Write(C.To__); toAddrspec = new Range(end + request.To.AddrSpec.Value.Begin - request.Headers[i].Value.Begin, request.To.AddrSpec.Value.Length); if (request.To.Tag.IsValid) { toTag = new Range(end + request.To.Tag.Begin - request.Headers[i].Value.Begin, request.To.Tag.Length); } Write(request.Headers[i].Value); if (request.To.Tag.IsInvalid && localTag.IsValid && statusCode != StatusCodes.Trying && request.Method != Methods.Cancelm) { Write(C._tag_); toTag = new Range(end, localTag.Length); Write(localTag); } WriteCRLF(); break; } } }
public void CopyViaToFromCallIdRecordRouteCSeq(SipMessageReader request, StatusCodes statusCode) { CopyViaToFromCallIdRecordRouteCSeq(request, statusCode, GenerateTag()); }
public void GenerateForwardedRequest(SipMessageWriter writer, SipMessageReader reader, ArraySegment<byte> content, ConnectionAddresses fromConnectionAddress, int serverTransactionId) { //dialog2 = new Dialog(reader, fromTag, fromConnectionAddress); Dialog dialog1 = null; if (HexEncoding.TryParseHex8(reader.To.Tag, out tag)) dialog1 = trunk.GetDialog1(tag); else tag = DialogManager.NewLocalTag(); dialog2 = new Dialog(reader, tag, fromConnectionAddress); trunk.AddDialog2(tag, dialog2); ///////////////////////////////////////////////////////////////////////////////// writer.WriteRequestLine(reader.Method, binding.AddrSpec); //var msReceivedCid = fromConnectionAddress.ToLowerHexChars(serverTransactionId); //writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId, msReceivedCid); writer.WriteVia(binding.ConnectionAddresses.Transport, binding.ConnectionAddresses.LocalEndPoint, TransactionId); for (int i = 0; i < reader.Count.HeaderCount; i++) { switch (reader.Headers[i].HeaderName) { case HeaderNames.MaxForwards: writer.WriteMaxForwards((reader.MaxForwards == int.MinValue) ? 69 : reader.MaxForwards - 1); break; case HeaderNames.Contact: writer.WriteContact(binding.ConnectionAddresses.LocalEndPoint, binding.ConnectionAddresses.Transport); break; case HeaderNames.To: writer.WriteTo(trunk.ForwardCallToUri, (dialog1 != null) ? dialog1.RemoteTag : ByteArrayPart.Invalid); break; case HeaderNames.From: writer.WriteFrom(reader.From.AddrSpec.Value, tag); break; case HeaderNames.Authorization: break; default: writer.WriteHeader(reader, i); break; case HeaderNames.Via: via = reader.Headers[i].Value.DeepCopy(); break; } } if (reader.ContentLength == int.MinValue) writer.WriteContentLength(content.Count); writer.WriteCustomHeaders(); writer.WriteCRLF(); writer.Write(content); }
public bool CanFork(SipMessageReader response) { return false; }
private void GenerateRequest(SipMessageWriter writer, SipMessageReader reader, Methods method) { writer.WriteRequestLine(method, trunk.ForwardCallToUri); writer.WriteVia(ToConnectionAddresses.Transport, ToConnectionAddresses.LocalEndPoint, TransactionId); for (int i = 0; i < reader.Count.HeaderCount; i++) { switch (reader.Headers[i].HeaderName) { case HeaderNames.From: case HeaderNames.To: case HeaderNames.CallId: writer.WriteHeader(reader, i); break; } } writer.WriteMaxForwards(70); writer.WriteCseq(reader.CSeq.Value, method); writer.WriteContentLength(0); writer.WriteCustomHeaders(); writer.WriteCRLF(); }
public void CopyViaToFromCallIdRecordRouteCSeq(SipMessageReader request, StatusCodes statusCode, ByteArrayPart localTag) { for (int i = 0; i < request.Count.HeaderCount; i++) { HeaderNames headerName = request.Headers[i].HeaderName; switch (headerName) { case HeaderNames.From: { base.Write(SipMessageWriter.C.From__); int arg_111_0 = this.end + request.From.AddrSpec.Value.Begin - request.Headers[i].Value.Begin; BeginEndIndex value = request.From.AddrSpec.Value; this.fromAddrspec = new SipMessageWriter.Range(arg_111_0, value.Length); if (request.From.Tag.IsValid) { this.fromTag = new SipMessageWriter.Range(this.end + request.From.Tag.Begin - request.Headers[i].Value.Begin, request.From.Tag.Length); } if (request.From.Epid.IsValid) { this.fromEpid = new SipMessageWriter.Range(this.end + request.From.Epid.Begin - request.Headers[i].Value.Begin, request.From.Epid.Length); } base.Write(request.Headers[i].Value); base.WriteCRLF(); break; } case HeaderNames.CallId: base.WriteCallId(request.CallId); break; default: switch (headerName) { case HeaderNames.To: { base.Write(SipMessageWriter.C.To__); int arg_24F_0 = this.end + request.To.AddrSpec.Value.Begin - request.Headers[i].Value.Begin; BeginEndIndex value2 = request.To.AddrSpec.Value; this.toAddrspec = new SipMessageWriter.Range(arg_24F_0, value2.Length); if (request.To.Tag.IsValid) { this.toTag = new SipMessageWriter.Range(this.end + request.To.Tag.Begin - request.Headers[i].Value.Begin, request.To.Tag.Length); } base.Write(request.Headers[i].Value); if (request.To.Tag.IsInvalid && localTag.IsValid && statusCode != StatusCodes.Trying && request.Method != Methods.Cancelm) { base.Write(SipMessageWriter.C._tag_); this.toTag = new SipMessageWriter.Range(this.end, localTag.Length); base.Write(localTag); } base.WriteCRLF(); goto IL_329; } case HeaderNames.AllowEvents: goto IL_329; case HeaderNames.Via: break; case HeaderNames.CSeq: base.CSeq = request.CSeq.Value; base.Method = request.CSeq.Method; base.WriteHeader(request.Headers[i]); goto IL_329; default: if (headerName != HeaderNames.RecordRoute) { goto IL_329; } break; } base.WriteHeader(request.Headers[i]); break; } IL_329 :; } }
private void DestroyReaders(SipMessageReader[] readers, int skip, bool validate) { for (int i = 0; i < readers.Length; i++) Assert.IsFalse(SipMessageReader.IsArraySlotAvailable(readers[i].Index), "Slot #" + readers[i].Index); for (int i = skip; i < readers.Length; i++) { int index = readers[i].Index; readers[i].Dispose(); if (validate) Assert.IsTrue(SipMessageReader.IsArraySlotAvailable(index), "Slot #" + index); } }
private SipMessageReader[] CreateReaders(int qty) { int expectedIndex = -1; var readers = new SipMessageReader[qty]; for (int i = 0; i < qty; i++, expectedIndex += (expectedIndex >= 0) ? 1 : 0) { readers[i] = new SipMessageReader(); if (expectedIndex >= 0) Assert.AreEqual(expectedIndex, readers[i].Index); readers[i].SetDefaultValue(); } return readers; }
public void WriteResponse(SipMessageReader request, StatusCodes statusCode) { WriteResponse(request, statusCode, GenerateTag()); }