/// <summary>DhcpGetVersionStub</summary> public static void DhcpGetVersionStub ( ref UtilityDynamicHostConfigurationProtocolDHCPArgument utilityDynamicHostConfigurationProtocolDHCPArgument, ref string exceptionMessage ) { int dhcpGetVersion = -1; int majorVersion = -1; int minorVersion = -1; dhcpGetVersion = DhcpGetVersion ( utilityDynamicHostConfigurationProtocolDHCPArgument.server, ref majorVersion, ref minorVersion ); #if ( DEBUG ) System.Console.WriteLine ( "Dhcp Major Version: {0} | Minor Version: {1}", majorVersion, minorVersion ); #endif }
/// <summary>Stub</summary> public static void Stub ( ref UtilityDynamicHostConfigurationProtocolDHCPArgument utilityDynamicHostConfigurationProtocolDHCPArgument, ref string exceptionMessage ) { IntPtr[] enumInfoElements = null; IPAddress[] ipAddressDhcpEnumSubnets = null; DHCP_CLIENT_INFO[][] dhcpClientInfoEnumSubnetClient = null; DhcpGetVersionStub ( ref utilityDynamicHostConfigurationProtocolDHCPArgument, ref exceptionMessage ); DhcpEnumSubnetsStub ( ref utilityDynamicHostConfigurationProtocolDHCPArgument, ref exceptionMessage, ref ipAddressDhcpEnumSubnets, ref enumInfoElements ); DhcpEnumSubnetClientstub ( ref utilityDynamicHostConfigurationProtocolDHCPArgument, ref exceptionMessage, ref ipAddressDhcpEnumSubnets, ref enumInfoElements, ref dhcpClientInfoEnumSubnetClient ); }
/// <summary>The entry point for the application.</summary> /// <param name="argv">A list of command line arguments</param> public static void Main(String[] argv) { Boolean booleanParseCommandLineArguments = false; string exceptionMessage = null; UtilityDynamicHostConfigurationProtocolDHCPArgument utilityDynamicHostConfigurationProtocolDHCPArgument = null; utilityDynamicHostConfigurationProtocolDHCPArgument = new UtilityDynamicHostConfigurationProtocolDHCPArgument(); booleanParseCommandLineArguments = UtilityParseCommandLineArgument.ParseCommandLineArguments ( argv, utilityDynamicHostConfigurationProtocolDHCPArgument ); if (booleanParseCommandLineArguments == false) { // error encountered in arguments. Display usage message System.Console.Write ( UtilityParseCommandLineArgument.CommandLineArgumentsUsage(typeof(UtilityDynamicHostConfigurationProtocolDHCPArgument)) ); return; }//if ( booleanParseCommandLineArguments == false ) Stub ( ref utilityDynamicHostConfigurationProtocolDHCPArgument, ref exceptionMessage ); }
/// <summary>DhcpEnumSubnetsStub</summary> public static void DhcpEnumSubnetsStub ( ref UtilityDynamicHostConfigurationProtocolDHCPArgument utilityDynamicHostConfigurationProtocolDHCPArgument, ref string exceptionMessage, ref IPAddress[] ipAddress, ref IntPtr[] enumInfoElements ) { int dhcpEnumSubnets = -1; int elementsRead = -1; int elementsTotal = -1; int resumeHandle = 0; IntPtr enumInfo = IntPtr.Zero; DHCP_IP_ARRAY dhcpIPArray; ipAddress = null; dhcpEnumSubnets = DhcpEnumSubnets ( utilityDynamicHostConfigurationProtocolDHCPArgument.server, ref resumeHandle, PreferredMaximum, ref enumInfo, ref elementsRead, ref elementsTotal ); if (elementsTotal < 1) { return; } if (dhcpEnumSubnets == 0 && enumInfo != IntPtr.Zero) { dhcpIPArray = (DHCP_IP_ARRAY)Marshal.PtrToStructure ( enumInfo, typeof(DHCP_IP_ARRAY) ); ipAddress = new IPAddress[elementsTotal]; enumInfoElements = new IntPtr[elementsTotal]; enumInfoElements[0] = dhcpIPArray.Elements; for (int elementIndex = 0; elementIndex < elementsTotal; ++elementIndex) { ipAddress[elementIndex] = new IPAddress ( IPAddress.NetworkToHostOrder ( Marshal.ReadInt32(enumInfoElements[elementIndex]) ) ); #if ( DEBUG ) System.Console.WriteLine ( "[{0}]: IPAddress: {1} | Subnet Mask: {2}", elementIndex, ipAddress[elementIndex], Marshal.ReadInt32(enumInfoElements[elementIndex]) ); #endif if (elementIndex < elementsTotal - 1) { enumInfoElements[elementIndex + 1] = new IntPtr ( enumInfoElements[elementIndex].ToInt32() + IntPtr.Size ); } } } }
/// <summary>DhcpEnumSubnetClientstub</summary> public static void DhcpEnumSubnetClientstub ( ref UtilityDynamicHostConfigurationProtocolDHCPArgument utilityDynamicHostConfigurationProtocolDHCPArgument, ref string exceptionMessage, ref IPAddress[] ipAddress, ref IntPtr[] enumInfoElements, ref DHCP_CLIENT_INFO[][] dhcpClientInfo ) { int dhcpEnumSubnetClients; int clientsRead = -1; int clientsTotal = -1; int resumeHandle = 0; IntPtr clientInfo = IntPtr.Zero; IntPtr clientInfoClient = IntPtr.Zero; IntPtr clientInfoClients = IntPtr.Zero; DHCP_CLIENT_INFO_ARRAY dhcpClientInfoArray; dhcpClientInfo = null; if (ipAddress == null) { return; } dhcpClientInfo = new DHCP_CLIENT_INFO[ipAddress.Length][]; for (int ipAddressIndex = 0; ipAddressIndex < ipAddress.Length; ++ipAddressIndex) { dhcpEnumSubnetClients = DhcpEnumSubnetClients ( ipAddress[ipAddressIndex].ToString(), Marshal.ReadInt32(enumInfoElements[ipAddressIndex]), ref resumeHandle, PreferredMaximum, ref clientInfo, ref clientsRead, ref clientsTotal ); System.Console.WriteLine ( "dhcpEnumSubnetClients: {0}", dhcpEnumSubnetClients ); if (dhcpEnumSubnetClients == 0 && clientInfo != IntPtr.Zero) { dhcpClientInfoArray = ( DHCP_CLIENT_INFO_ARRAY )Marshal.PtrToStructure ( clientInfo, typeof(DHCP_CLIENT_INFO_ARRAY) ); dhcpClientInfo[ipAddressIndex] = new DHCP_CLIENT_INFO[dhcpClientInfoArray.NumElements]; clientInfoClients = dhcpClientInfoArray.Clients; for (int clientIndex = 0; clientIndex < clientsTotal; ++clientIndex) { clientInfoClient = Marshal.ReadIntPtr(clientInfoClients); dhcpClientInfo[ipAddressIndex][clientIndex] = ( DHCP_CLIENT_INFO )Marshal.PtrToStructure ( clientInfoClient, typeof(DHCP_CLIENT_INFO) ); #if ( DEBUG ) System.Console.WriteLine ( "IPAddress[{0}][{1}]: {2}", ipAddressIndex, clientIndex, dhcpClientInfo[ipAddressIndex][clientIndex] ); #endif clientInfoClient = new IntPtr ( clientInfoClients.ToInt32() + IntPtr.Size ); } } } }