Exemple #1
0
 public void SetUInt32(DhcpPacketOptionId id, UInt32 value)
 {
     value = (UInt32)IPAddress.HostToNetworkOrder((int)value);
     SetBytes(id, BitConverter.GetBytes(value));
 }
Exemple #2
0
        public void SetString(DhcpPacketOptionId id, String value)
        {
            var bytes = Encoding.ASCII.GetBytes(value);

            SetBytes(id, bytes);
        }
Exemple #3
0
 public Byte[] GetBytes(DhcpPacketOptionId id)
 {
     return(_options.ContainsKey(id) ? _options[id].Data : null);
 }
Exemple #4
0
 public void SetByte(DhcpPacketOptionId id, Byte value)
 {
     SetBytes(id, new Byte[] { value });
 }
Exemple #5
0
 public String GetString(DhcpPacketOptionId id, String defaultValue = null)
 {
     return(_options.ContainsKey(id) ? Encoding.ASCII.GetString(_options[id].Data, 0, _options[id].Data.Length) : defaultValue);
 }
Exemple #6
0
 public IPAddress GetIpAAddress(DhcpPacketOptionId id, IPAddress defaultValue = null)
 {
     return(_options.ContainsKey(id) ? new IPAddress(_options[id].Data) : defaultValue);
 }
Exemple #7
0
 public Byte GetByte(DhcpPacketOptionId id, Byte defaultValue = 0)
 {
     return(_options.ContainsKey(id) ? _options[id].Data[0] : defaultValue);
 }
Exemple #8
0
        public UInt32 GetUInt32(DhcpPacketOptionId id, UInt32 defaultValue = 0)
        {
            var number = _options.ContainsKey(id) ? BitConverter.ToUInt32(_options[id].Data, 0) : defaultValue;

            return((UInt32)IPAddress.NetworkToHostOrder((int)number));
        }
Exemple #9
0
 public Boolean Remove(DhcpPacketOptionId id)
 {
     return(_options.Remove(id));
 }
Exemple #10
0
 public Boolean Exists(DhcpPacketOptionId id)
 {
     return(_options.ContainsKey(id));
 }
Exemple #11
0
 public DhcpPacketOption(DhcpPacketOptionId id, Byte[] data)
 {
     Id   = id;
     Data = data;
 }
Exemple #12
0
        public void SetBytes(DhcpPacketOptionId id, Byte[] value)
        {
            var option = new DhcpPacketOption(id, value);

            _options[id] = option;
        }
Exemple #13
0
        public void SetIpAAddress(DhcpPacketOptionId id, IPAddress value)
        {
            var bytes = value.GetAddressBytes();

            SetBytes(id, bytes);
        }