Beispiel #1
0
 private static void InsertData(Seq obj, string newDB)
 {
     if (CheckData(obj, newDB) == false)
     {
         CSeq.Insert(obj, new DAL());
     }
     ;
 }
Beispiel #2
0
        public void ParseCSeq()
        {
            string TestLine = "CSeq: 1 INVITE";
            CSeq   parsed   = CSeq.Parse(TestLine);

            Assert.NotNull(parsed);
            Assert.True(parsed.Sequence != 0);
        }
Beispiel #3
0
        public void Create_Sip_Cseq_Unsuccess(string cseq)
        {
            // *** ACT ***
            Action act = () => CSeq.Parse(cseq);

            // *** ACT ***
            Assert.Throws <SipParsingException>(act);
        }
Beispiel #4
0
        public void Create_Sip_Cseq_Success(string cseq, int expectedSqNumber, string expectedMethod)
        {
            // *** ACT ***
            CSeq cs = CSeq.Parse(cseq);

            // *** ASSERT ***
            Assert.Equal(expectedSqNumber, cs.SequenceNumber);
            Assert.Equal(expectedMethod, cs.Method);
        }
Beispiel #5
0
        public override string ToString()
        {
            var str = new StringBuilder(Environment.NewLine + "\r\n");

            str.AppendLine($"{ RequestType} {ServerAddress}{FileName} {RtspVersion}");
            str.Append($" {nameof(CSeq)}: {CSeq.Trim()}\r\n");
            if (RequestType != RtspRequestType.SETUP)
            {
                str.Append($" {nameof(Session)}: {Session}\r\n");
            }
            return(str.ToString());
        }
Beispiel #6
0
        private static bool CheckData(Seq obj, string newDB)
        {
            string q = "USE " + newDB + "; ";

            q += "SELECT * FROM " + SEQ.SEQ_TBL + " WHERE " + SEQ.SEQ_NAME + " = '" + obj.Seq_name + "'; ";

            using (IDataReader redr = new DAL().Listreader(q))
            {
                while (redr.Read() == true)
                {
                    obj.Seq_id = redr[SEQ.SEQ_ID].ToString();

                    CSeq.Update(obj, new DAL());

                    return(true);
                }
                return(false);
            }
        }
Beispiel #7
0
        private osip_message_t *ToNative()
        {
            osip_message_t *native;

            NativeMethods.osip_message_init(&native).ThrowOnError();

            native->sip_version = Marshal.StringToHGlobalAnsi(Version);
            native->from        = From != null
                    ? From.ToNative()
                    : osip_from_t.Null;

            native->to = To != null
                    ? To.ToNative()
                    : osip_from_t.Null;

            native->call_id = CallId != null
                    ? CallId.ToNative()
                    : osip_call_id_t.Null;

            native->cseq = CSeq != null
                    ? CSeq.ToNative()
                    : osip_cseq_t.Null;

            native->content_type = ContentType != null
                    ? ContentType.ToNative()
                    : osip_content_type_t.Null;

            native->mime_version = MimeVersion != null
                    ? MimeVersion.ToNative()
                    : osip_content_length_t.Null;

            if (this is SipRequest request)
            {
                native->sip_method = native->sip_method = Marshal.StringToHGlobalAnsi(request.Method);
                native->req_uri    = request.RequestUri != null
                    ? request.RequestUri.ToNative()
                    : osip_uri_t.Null;
            }
            else if (this is SipResponse response)
            {
                native->status_code   = response.StatusCode;
                native->reason_phrase = Marshal.StringToHGlobalAnsi(response.ReasonPhrase);
            }

            for (int i = 0; i < Vias.Count; i++)
            {
                osip_via_t *header = Vias[i].ToNative();
                NativeMethods.osip_list_add(&native->vias, header, i).ThrowOnError();
            }

            for (int i = 0; i < RecordRoutes.Count; i++)
            {
                osip_from_t *header = RecordRoutes[i].ToNative();
                NativeMethods.osip_list_add(&native->record_routes, header, i).ThrowOnError();
            }

            for (int i = 0; i < Routes.Count; i++)
            {
                osip_from_t *header = Routes[i].ToNative();
                NativeMethods.osip_list_add(&native->routes, header, i).ThrowOnError();
            }

            for (int i = 0; i < Contacts.Count; i++)
            {
                osip_from_t *header = Contacts[i].ToNative();
                NativeMethods.osip_list_add(&native->contacts, header, i).ThrowOnError();
            }

            for (int i = 0; i < Authorizations.Count; i++)
            {
                osip_authorization_t *header = Authorizations[i].ToNative();
                NativeMethods.osip_list_add(&native->authorizations, header, i).ThrowOnError();
            }

            for (int i = 0; i < WwwAuthenticates.Count; i++)
            {
                osip_www_authenticate_t *header = WwwAuthenticates[i].ToNative();
                NativeMethods.osip_list_add(&native->www_authenticates, header, i).ThrowOnError();
            }

            for (int i = 0; i < ProxyAuthenticates.Count; i++)
            {
                osip_www_authenticate_t *header = ProxyAuthenticates[i].ToNative();
                NativeMethods.osip_list_add(&native->proxy_authenticates, header, i).ThrowOnError();
            }

            for (int i = 0; i < ProxyAuthorizations.Count; i++)
            {
                osip_authorization_t *header = ProxyAuthorizations[i].ToNative();
                NativeMethods.osip_list_add(&native->proxy_authorizations, header, i).ThrowOnError();
            }

            for (int i = 0; i < CallInfos.Count; i++)
            {
                osip_call_info_t *header = CallInfos[i].ToNative();
                NativeMethods.osip_list_add(&native->call_infos, header, i).ThrowOnError();
            }

            for (int i = 0; i < Allows.Count; i++)
            {
                osip_content_length_t *header = Allows[i].ToNative();
                NativeMethods.osip_list_add(&native->allows, header, i).ThrowOnError();
            }

            for (int i = 0; i < ContentEncodings.Count; i++)
            {
                osip_content_length_t *header = ContentEncodings[i].ToNative();
                NativeMethods.osip_list_add(&native->content_encodings, header, i).ThrowOnError();
            }

            for (int i = 0; i < AlertInfos.Count; i++)
            {
                osip_call_info_t *header = AlertInfos[i].ToNative();
                NativeMethods.osip_list_add(&native->alert_infos, header, i).ThrowOnError();
            }

            for (int i = 0; i < ErrorInfos.Count; i++)
            {
                osip_call_info_t *header = ErrorInfos[i].ToNative();
                NativeMethods.osip_list_add(&native->error_infos, header, i).ThrowOnError();
            }

            for (int i = 0; i < Accepts.Count; i++)
            {
                osip_content_type_t *header = Accepts[i].ToNative();
                NativeMethods.osip_list_add(&native->accepts, header, i).ThrowOnError();
            }

            for (int i = 0; i < AcceptEncodings.Count; i++)
            {
                osip_accept_encoding_t *header = AcceptEncodings[i].ToNative();
                NativeMethods.osip_list_add(&native->accept_encodings, header, i).ThrowOnError();
            }

            for (int i = 0; i < AcceptLanguages.Count; i++)
            {
                osip_accept_encoding_t *header = AcceptLanguages[i].ToNative();
                NativeMethods.osip_list_add(&native->accept_languages, header, i).ThrowOnError();
            }

            for (int i = 0; i < AuthenticationInfos.Count; i++)
            {
                osip_authentication_info_t *header = AuthenticationInfos[i].ToNative();
                NativeMethods.osip_list_add(&native->authentication_infos, header, i).ThrowOnError();
            }

            for (int i = 0; i < ProxyAuthenticationInfos.Count; i++)
            {
                osip_authentication_info_t *header = ProxyAuthenticationInfos[i].ToNative();
                NativeMethods.osip_list_add(&native->proxy_authentication_infos, header, i).ThrowOnError();
            }

            for (int i = 0; i < OtherHeaders.Count; i++)
            {
                osip_header_t *header = OtherHeaders[i].ToNative();
                NativeMethods.osip_list_add(&native->headers, header, i).ThrowOnError();
            }

            for (int i = 0; i < Bodies.Count; i++)
            {
                osip_body_t *header = Bodies[i].ToNative();
                NativeMethods.osip_list_add(&native->bodies, header, i).ThrowOnError();
            }

            return(native);
        }