Exemplo n.º 1
0
 public Command GetCommand()
 {
     TABLE.Add(new CommandArgumentEntry("[string] [string]", false, "[interface name] [MAC address]"));
     CMD_SETMAC = new Command("SETMAC", TABLE, false, "Changes MAC address of the specified network interface.", ExecutionLevel.Administrator, CLIMode.Default);
     CMD_SETMAC.SetFunction(() =>
     {
         List <NetworkInterface> ifaces = new NetworkInterfaceDiscovery().GetInterfaces().Result.ToList();
         if (ifaces.Exists(x => x.Name == CMD_SETMAC.InputArgumentEntry.Arguments[0].Value.ToString()))
         {
             PhysicalAddressManagement p_mgmt = new PhysicalAddressManagement(ifaces.Find(x => x.Name == CMD_SETMAC.InputArgumentEntry.Arguments[0].Value.ToString()));
             if (Regex.IsMatch(CMD_SETMAC.InputArgumentEntry.Arguments[1].Value.ToString(), "^[0-9a-fA-F:]*$"))
             {
                 p_mgmt.SetAddress(CMD_SETMAC.InputArgumentEntry.Arguments[1].Value.ToString().Replace(":", ""));
             }
             else
             {
                 return("\nInvalid address!");
             }
         }
         else
         {
             return("\nInterface not found!");
         }
         return("");
     });
     return(CMD_SETMAC);
 }
Exemplo n.º 2
0
 public Command GetCommand()
 {
     TABLE.Add(new CommandArgumentEntry("[string]", false, "[interface name]"));
     CMD_RESETMAC = new Command("RESETMAC", TABLE, false, "Resets the MAC address of the specified network interface.", ExecutionLevel.Administrator, CLIMode.Default);
     CMD_RESETMAC.SetFunction(() =>
     {
         List <NetworkInterface> iface = new NetworkInterfaceDiscovery().GetInterfaces().Result.ToList();
         if (iface.Exists(x => x.Name == CMD_RESETMAC.InputArgumentEntry.Arguments[0].Value.ToString()))
         {
             PhysicalAddressManagement p_mgmt = new PhysicalAddressManagement(iface.Find(x => x.Name == CMD_RESETMAC.InputArgumentEntry.Arguments[0].Value.ToString()));
             p_mgmt.ResetAddress();
             return("");
         }
         else
         {
             return("\nInterface not found!");
         }
     });
     return(CMD_RESETMAC);
 }