using skyscraper5.Skyscraper.IO;

namespace skyscraper8.Ieee802_1AB.Model;

public class LldpCapabilities
{
    private readonly ushort capabilities;
    private readonly ushort enabledCapabilities;

    public LldpCapabilities(byte[] buffer)
    {
        MemoryStream ms = new MemoryStream(buffer);
        this.capabilities = ms.ReadUInt16BE();
        this.enabledCapabilities = ms.ReadUInt16BE();
    }

    public bool HasOther => (capabilities & 0x0001) != 0;
    public bool HasRepeater => (capabilities & 0x0002) != 0;
    public bool HasBridge => (capabilities & 0x0004) != 0;
    public bool HasWlanAccessPoint => (capabilities & 0x0008) != 0;
    public bool HasRouter => (capabilities & 0x0010) != 0;
    public bool HasTelephone => (capabilities & 0x0020) != 0;
    public bool HasDocsis => (capabilities & 0x0040) != 0;
    public bool IsStation => (capabilities & 0x0080) != 0;
    public bool HasCVLan => (capabilities & 0x0100) != 0;
    public bool HasSVLan => (capabilities & 0x0200) != 0;
    public bool HasTpmr => (capabilities & 0x0400) != 0;
    
    public bool EnabledOther => (enabledCapabilities & 0x0001) != 0;
    public bool EnabledRepeater => (enabledCapabilities & 0x0002) != 0;
    public bool EnabledBridge => (enabledCapabilities & 0x0004) != 0;
    public bool EnabledWlanAccessPoint => (enabledCapabilities & 0x0008) != 0;
    public bool EnabledRouter => (enabledCapabilities & 0x0010) != 0;
    public bool EnabledTelephone => (enabledCapabilities & 0x0020) != 0;
    public bool EnabledDocsis => (enabledCapabilities & 0x0040) != 0;
}