/// <summary>
 /// Constructs an instance out of the precedence, gateway, algorithm and public key fields.
 /// </summary>
 /// <param name="precedence">
 /// Precedence for this record.
 /// Gateways listed in IPSECKEY records with lower precedence are to be attempted first.
 /// Where there is a tie in precedence, the order should be non-deterministic.
 /// </param>
 /// <param name="gateway">
 /// Indicates a gateway to which an IPsec tunnel may be created in order to reach the entity named by this
 /// resource record.
 /// </param>
 /// <param name="algorithm">Identifies the public key's cryptographic algorithm and determines the format of the public key field.</param>
 /// <param name="publicKey">Contains the algorithm-specific portion of the KEY RR RDATA.</param>
 public DnsResourceDataIpSecKey(byte precedence, DnsGateway gateway, DnsPublicKeyAlgorithm algorithm, DataSegment publicKey)
 {
     Precedence = precedence;
     Gateway    = gateway;
     Algorithm  = algorithm;
     PublicKey  = publicKey;
 }
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            if (length < 3)
            {
                return((DnsResourceData)null);
            }
            byte                  precedence  = dns[offsetInDns];
            DnsGatewayType        gatewayType = (DnsGatewayType)dns[offsetInDns + 1];
            DnsPublicKeyAlgorithm algorithm   = (DnsPublicKeyAlgorithm)dns[offsetInDns + 2];
            DnsGateway            instance    = DnsGateway.CreateInstance(gatewayType, dns, offsetInDns + 3, length - 3);

            if (instance == null)
            {
                return((DnsResourceData)null);
            }
            DataSegment publicKey = dns.Subsegment(offsetInDns + 3 + instance.Length, length - 3 - instance.Length);

            return((DnsResourceData) new DnsResourceDataIpSecKey(precedence, instance, algorithm, publicKey));
        }
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            if (length < ConstPartLength)
            {
                return(null);
            }

            byte                  precedence  = dns[offsetInDns + Offset.Precedence];
            DnsGatewayType        gatewayType = (DnsGatewayType)dns[offsetInDns + Offset.GatewayType];
            DnsPublicKeyAlgorithm algorithm   = (DnsPublicKeyAlgorithm)dns[offsetInDns + Offset.Algorithm];
            DnsGateway            gateway     = DnsGateway.CreateInstance(gatewayType, dns, offsetInDns + Offset.Gateway, length - ConstPartLength);

            if (gateway == null)
            {
                return(null);
            }
            DataSegment publicKey = dns.Subsegment(offsetInDns + ConstPartLength + gateway.Length, length - ConstPartLength - gateway.Length);

            return(new DnsResourceDataIpSecKey(precedence, gateway, algorithm, publicKey));
        }
Example #4
0
 public override bool Equals(DnsGateway other)
 {
     return(this.Equals(other as DnsGatewayIpV6));
 }
Example #5
0
 /// <summary>
 /// Two gateway representations are equal if they are of the same type and the value is the same.
 /// </summary>
 public override bool Equals(DnsGateway other)
 {
     return(Equals(other as DnsGatewayIpV4));
 }
 public override bool Equals(DnsGateway other)
 {
     return(this.Equals(other as DnsGatewayDomainName));
 }