Пример #1
0
 public static String GetName(TSIP_Header header)
 {
     if (header != null)
     {
         if (header.Type == tsip_header_type_t.Dummy)
         {
             return((header as TSIP_HeaderDummy).Name);
         }
         else
         {
             return(TSIP_Header.GetName(header.Type));
         }
     }
     return("unknown-header");
 }
Пример #2
0
 public static String ToString(TSIP_Header header, Boolean with_name, Boolean with_crlf, Boolean with_params)
 {
     if (header != null)
     {
         String @params = String.Empty;
         if (with_params)
         {
             foreach (TSK_Param param in header.Params)
             {
                 @params += String.Format(!String.IsNullOrEmpty(param.Value) ? "{0}{1}={2}":"{0}{1}", header.ParamSeparator, param.Name, param.Value);
             }
         }
         return(String.Format("{0}{1}{2}{3}{4}",
                              with_name ? header.Name : String.Empty,
                              with_name ? ": " : String.Empty,
                              header.Value,
                              @params,
                              with_crlf ? "\r\n" : String.Empty));
     }
     return(String.Empty);
 }
Пример #3
0
        public static char GetParamSeparator(TSIP_Header header)
        {
            if (header != null)
            {
                switch (header.Type)
                {
                case tsip_header_type_t.Authorization:
                case tsip_header_type_t.Proxy_Authorization:
                case tsip_header_type_t.Proxy_Authenticate:
                case tsip_header_type_t.WWW_Authenticate:
                {
                    return(',');
                }

                default:
                {
                    return(';');
                }
                }
            }
            return(';');
        }
Пример #4
0
        public Boolean AddHeaders(TSIP_Header[] headers)
        {
            if (headers == null) // not error
            {
                return true;
            }

            foreach(TSIP_Header header in headers)
            {
                if (header == null) continue;

                switch(header.Type)
                {
                    case TSIP_Header.tsip_header_type_t.Via:
                        {
                            if(this.FirstVia == null)
                            {
                                this.FirstVia = (header as TSIP_HeaderVia);
                                continue;
                            }
                            break;
                        }

                        case TSIP_Header.tsip_header_type_t.From:
                        {
                            if(this.From == null)
                            {
                                this.From = (header as TSIP_HeaderFrom);
                                continue;
                            }
                            break;
                        }

                        case TSIP_Header.tsip_header_type_t.To:
                        {
                            if(this.To == null)
                            {
                                this.To = (header as TSIP_HeaderTo);
                                continue;
                            }
                            break;
                        }

                        case TSIP_Header.tsip_header_type_t.Contact:
                        {
                            if(this.Contact == null)
                            {
                                this.Contact = (header as TSIP_HeaderContact);
                                continue;
                            }
                            break;
                        }

                        case TSIP_Header.tsip_header_type_t.Call_ID:
                        {
                            if(this.CallId == null)
                            {
                                this.CallId = (header as TSIP_HeaderCallId);
                                continue;
                            }
                            break;
                        }

                        case TSIP_Header.tsip_header_type_t.CSeq:
                        {
                            if(this.CSeq == null)
                            {
                                this.CSeq = (header as TSIP_HeaderCSeq);
                                continue;
                            }
                            break;
                        }

                        case TSIP_Header.tsip_header_type_t.Content_Type:
                        {
                            if(this.ContentType == null)
                            {
                                this.ContentType = (header as TSIP_HeaderContentType);
                                continue;
                            }
                            break;
                        }

                        case TSIP_Header.tsip_header_type_t.Content_Length:
                        {
                            if(this.ContentLength == null)
                            {
                                this.ContentLength = (header as TSIP_HeaderContentLength);
                                continue;
                            }
                            break;
                        }
                }

                this.Headers.Add(header);
            }

            return true;
        }
Пример #5
0
 public Boolean AddHeader(TSIP_Header header)
 {
     if (header != null)
     {
         return this.AddHeaders(new TSIP_Header[] { header });
     }
     return false;
 }
Пример #6
0
 public String ToString(Boolean with_name, Boolean with_crlf, Boolean with_params)
 {
     return(TSIP_Header.ToString(this, with_name, with_crlf, with_params));
 }
Пример #7
0
 public static String ToString(TSIP_Header header, Boolean with_name, Boolean with_crlf, Boolean with_params)
 {
     if (header != null)
     {
         String @params = String.Empty;
         if (with_params)
         {
             foreach(TSK_Param param in header.Params)
             {
                 @params += String.Format(!String.IsNullOrEmpty(param.Value) ? "{0}{1}={2}":"{0}{1}", header.ParamSeparator, param.Name, param.Value);
             }
         }
         return String.Format("{0}{1}{2}{3}{4}",
             with_name ? header.Name : String.Empty,
             with_name ? ": " : String.Empty,
             header.Value,
             @params,
             with_crlf ? "\r\n" : String.Empty);
     }
     return String.Empty;
 }
Пример #8
0
        public static char GetParamSeparator(TSIP_Header header)
        {
            if (header != null)
            {
                switch (header.Type)
                {
                    case tsip_header_type_t.Authorization:
                    case tsip_header_type_t.Proxy_Authorization:
                    case tsip_header_type_t.Proxy_Authenticate:
                    case tsip_header_type_t.WWW_Authenticate:
                    {
                        return ',';
                    }

                default:
                    {
                        return ';';
                    }
                }
            }
            return ';';
        }
Пример #9
0
 public static String GetName(TSIP_Header header)
 {
     if (header != null)
     {
         if (header.Type == tsip_header_type_t.Dummy)
         {
             return (header as TSIP_HeaderDummy).Name;
         }
         else{
             return TSIP_Header.GetName(header.Type);
         }
     }
     return "unknown-header";
 }