Пример #1
0
 public SyslogProtocol()
 {
     this.Seperator = Encoding.ASCII.GetBytes(SyslogValues.Seperator.ToString()).Single();
     Elements = new ProtocolElement[3];
     SyslogHeader header = new SyslogHeader(this.Seperator);
     header.Version = 1;
     Elements[0] = header;
     Elements[1] = new SyslogStructuredData();
     Elements[2] = new SyslogMessage();
 }
Пример #2
0
 public SyslogHeader(byte seperator)
     : base(seperator)
 {
     Elements = new ProtocolElement[6];
     Elements[0] = new SyslogPriorityVersion();
     Elements[1] = new SyslogTimestamp();
     Elements[2] = new SyslogHostname();
     Elements[3] = new SyslogAppname();
     Elements[4] = new SyslogProcID();
     Elements[5] = new SyslogMsgID();
 }
Пример #3
0
        public override void SetBytes(byte[] bytes)
        {
            int start = 0;
            int end   = 0;

            for (int ii = 0; ii < Elements.Length; ii++)
            {
                ProtocolElement element = Elements[ii];
                if (ii < Elements.Length - 1)
                {
                    if (element is ExtendedProtocolElement)
                    {
                        ExtendedProtocolElement xElement = (ExtendedProtocolElement)element;
                        if (xElement.Seperator == this.Seperator)
                        {
                            element.SetBytes(GetBytes(ref bytes, start, ref end, this.Seperator, xElement.Count()));
                        }
                        else
                        {
                            element.SetBytes(GetBytes(ref bytes, start, ref end, this.Seperator));
                        }
                    }
                    else
                    {
                        //ZU LETZT: Problem mit Seperator in Message (leerzeichen können in der nachricht sein)
                        element.SetBytes(GetBytes(ref bytes, start, ref end, this.Seperator));
                    }
                }
                else
                {
                    end = bytes.Length;
                    int    length = end - start;
                    byte[] pass   = new byte[length];
                    Array.Copy(bytes, start, pass, 0, end - start);
                    element.SetBytes(pass);
                }
                start = end + 1;
            }
        }