Ejemplo n.º 1
0
        /// <summary>
        /// Gets the native representation of this attribute. The caller is responsible to free the memory allocated in this method with a call to <see cref="FreeNativeAttribute"/>.
        /// </summary>
        /// <returns>The native representation of this attribute.</returns>
        internal RADIUS_ATTRIBUTE GetNativeAttribute()
        {
            if (this.radiusAttribute == null)
            {
                this.radiusAttribute = new RADIUS_ATTRIBUTE {
                    dwAttrType = this.attributeId
                };
                this.SetAttributeValue();
            }

            return(this.radiusAttribute);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Releases the memory allocated during a call to <see cref="GetNativeAttribute"/>
        /// </summary>
        internal void FreeNativeAttribute()
        {
            if (this.radiusAttribute == null)
            {
                return;
            }

            var ip = this.value as IPAddress;

            if (ip != null && ip.AddressFamily == AddressFamily.InterNetworkV6)
            {
                Marshal.FreeHGlobal(this.radiusAttribute.Value.lpValue);
                this.radiusAttribute = null;
                return;
            }

            if (this.value is string ||
                this.value is byte[] ||
                this.value is VendorSpecificAttribute)
            {
                Marshal.FreeHGlobal(this.radiusAttribute.Value.lpValue);
                this.radiusAttribute = null;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RadiusAttribute"/> class.
 /// </summary>
 /// <param name="radiusAttributePtr">Pointer to the native attribute.</param>
 internal RadiusAttribute(IntPtr radiusAttributePtr)
 {
     this.radiusAttributePtr = radiusAttributePtr;
     this.radiusAttribute    = (RADIUS_ATTRIBUTE)Marshal.PtrToStructure(this.radiusAttributePtr, typeof(RADIUS_ATTRIBUTE));
 }