Packet Sniffer SDK DLL Edition

HNLBHosts wrapper for C#

 Previous Next

File: HNLBHosts.cs

using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Runtime.InteropServices;

namespace microOLAP.PSSDK
{
    /// <summary>
    /// Summary description for HNLBHosts.
    /// </summary>
    public partial class HNLBHosts : Component
    {
        #region DLL exports

        /// <summary>
        /// Returns the address type, defined in the HNLBHosts object.
        /// </summary>
        /// <param name="hLbHst"></param>
        /// <returns></returns>
        [DllImport("pssdk.dll", EntryPoint = "LbHstGetAddrType")]
        private static extern int LbHstGetAddrType(IntPtr hLbHst);

        /// <summary>
        /// Returns the IPv4 address of the local host, participating in TCP session.
        /// </summary>
        /// <param name="hLbHst"></param>
        /// <returns></returns>
        [DllImport("pssdk.dll", EntryPoint = "LbHstGetLocalIPv4")]
        private static extern uint LbHstGetLocalIPv4(IntPtr hLbHst);

        /// <summary>
        /// LbHstGetRemoteIPv4 - Returns the IPv4 address of the remote host, participating in TCP session.
        /// </summary>
        /// <param name="hLbHst"></param>
        /// <returns></returns>
        [DllImport("pssdk.dll", EntryPoint = "LbHstGetRemoteIPv4")]
        private static extern uint LbHstGetRemoteIPv4(IntPtr hLbHst);

        /// <summary>
        /// LbHstGetLocalPort - Returns the port number of the local host, participating in TCP session.
        /// </summary>
        /// <param name="hLbHst"></param>
        /// <returns></returns>
        [DllImport("pssdk.dll", EntryPoint = "LbHstGetLocalPort")]
        private static extern ushort LbHstGetLocalPort(IntPtr hLbHst);

        /// <summary>
        /// Returns the port number of the remote host, participating in TCP session.
        /// </summary>
        /// <param name="hLbHst"></param>
        /// <returns></returns>
        [DllImport("pssdk.dll", EntryPoint = "LbHstGetRemotePort")]
        private static extern ushort LbHstGetRemotePort(IntPtr hLbHst);

        #endregion

        /// <summary>
        /// Handle of the HNLBHosts object.
        /// </summary>
        private IntPtr hLbHst = IntPtr.Zero;

        /// <summary>
        /// Constructor of the component.
        /// </summary>
        public HNLBHosts()
        {
            InitializeComponent();
        }

        #region HNLBHosts properties

        /// <summary>
        /// Checks if the HNLBHosts object has been created correctly.
        /// </summary>
        [Browsable(false)]
        public bool IsValid
        {
            get
            {
                return (hLbHst != IntPtr.Zero);
            }
        }

        /// <summary>
        /// Sets/Returns HNLBHosts object handle.
        /// </summary>
        [Browsable(false)]
        public IntPtr Handle
        {
            get
            {
                return hLbHst;
            }
            set
            {
                hLbHst = value;
            }
        }

        /// <summary>
        /// Returns the address type, defined in the HNLBHosts object.
        /// </summary>
        [Browsable(false)]
        public HNLBAddrType AddrType
        {
            get
            {
                return (HNLBAddrType)LbHstGetAddrType(hLbHst);
            }
        }

        /// <summary>
        /// Returns the IPv4 address of the local host, participating in TCP session.
        /// </summary>
        [Browsable(false)]
        public uint LocalIPv4
        {
            get
            {
                return LbHstGetLocalIPv4(hLbHst);
            }
        }

        /// <summary>
        /// Returns the IPv4 address of the remote host, participating in TCP session.
        /// </summary>
        [Browsable(false)]
        public uint RemoteIPv4
        {
            get
            {
                return LbHstGetRemoteIPv4(hLbHst);
            }
        }

        /// <summary>
        /// Returns the port number of the local host, participating in TCP session.
        /// </summary>
        [Browsable(false)]
        public ushort LocalPort
        {
            get
            {
                return LbHstGetLocalPort(hLbHst);
            }
        }

        /// <summary>
        /// Returns the port number of the remote host, participating in TCP session.
        /// </summary>
        [Browsable(false)]
        public ushort RemotePort
        {
            get
            {
                return LbHstGetRemotePort(hLbHst);
            }
        }

        #endregion
    }
}
See also:HNLBHosts, All wrappers in one ZIP archive