예제 #1
0
            public bool Read(BinaryReader br)
            {
                u32 bytes = br.ReadUInt32();

                // bit format:
                // aaaa aaaa iiic cccc cccc cccc cccc cccc

                // 8-bits : number of attributes
                Attributes = Convert.ToByte(bytes & 0xFF);

                // 3-bits : info flags
                RawInfo = Convert.ToByte((bytes >> 8) & 0x7);

                // 21-bits : number of child nodes
                u32 raw_children = (bytes >> 11) & 0x1FFFFF;

                // note: we store raw_children as u16 for alignment purposes
                // aaaa aaaa iiic cccc cccc cccc ccc- ---- (- = ignored)

#if DEBUG
                if (raw_children > 0xFFFF)
                {
                    //Console.WriteLine("Warning: huge number of child nodes");
                }
#endif

                Children = Convert.ToUInt16(raw_children & 0xFFFF);

                return(true);
            }
 public void Init(uint ip, ushort queryPort, ushort connectionPort)
 {
     this.ip             = ip;
     this.queryPort      = queryPort;
     this.connectionPort = connectionPort;
 }
예제 #3
0
 public NodeFlags()
 {
     Attributes = 0;
     RawInfo    = 0;
     Children   = 0;
 }
 /// <summary>
 /// If an instance is created with this constructor, there is no need to call Init.
 /// </summary>
 /// <param name="ip"></param>
 /// <param name="queryPort"></param>
 /// <param name="connectionPort"></param>
 public ServerNetworkAddress(uint ip, ushort queryPort, ushort connectionPort)
 {
     this.ip             = ip;
     this.queryPort      = queryPort;
     this.connectionPort = connectionPort;
 }