Skip to content

dj3mu/tik4net

 
 

Repository files navigation

tik4net

Unique complex mikrotik API communication solution.

The tik4net project provides easy to use API to connect and manage mikrotik routers via mikrotik API protocol. It has 3 parts:

  • Basic ADO.NET like API - to perform R/W access to mikrotik in both sync and async code (tik4net.dll).
  • O/R mapper like highlevel API with imported mikrotik strong-typed entities. (tik4net.objects.dll)
  • Tools - semi-automatic generators of custom entity C# code (for usage with tik4net.objects.dll)

Features

Binaries

Getting started and documentation

Project wiki:

Examples:

   using (ITikConnection connection = ConnectionFactory.CreateConnection(TikConnectionType.Api_v2)) // Use TikConnectionType.Api for mikrotikversion prior v6.45
   {
      connection.Open(HOST, USER, PASS);
   ITikCommand cmd = connection.CreateCommand("/system/identity/print");
   var identity = cmd.ExecuteScalar(); 
   Console.WriteLine("Identity: {0}", identity);
   var logs = connection.LoadList<Log>();
   foreach (Log log in logs)
   {
       Console.WriteLine("{0}[{1}]: {2}", log.Time, log.Topics, log.Message);
   }
   var firewallFilter = new FirewallFilter()
   {
      Chain = FirewallFilter.ChainType.Forward,
      Action = FirewallFilter.ActionType.Accept,
   };
   connection.Save(firewallFilter);
   ITikCommand torchCmd = connection.CreateCommand("/tool/torch", 
      connection.CreateParameter("interface", "ether1"), 
      connection.CreateParameter("port", "any"),
      connection.CreateParameter("src-address", "0.0.0.0/0"),
      connection.CreateParameter("dst-address", "0.0.0.0/0"));

  torchCmd.ExecuteAsync(response =>
      {
         Console.WriteLine("Row: " + response.GetResponseField("tx"));
      });
  Console.WriteLine("Press ENTER");
  Console.ReadLine();
  torchCmd.Cancel();

Builded binaries (dlls) could be downloaded from mikrotik official forum.

Looking for help

  • Importing other classes
  • Looking for betatesters

Roadmap

  • create highlevel classes for all mikrotik entities (you can still generate your own classes)
  • create tiklink project - easy use-to wrapper over mikrotik router with fluent API
  • convert examples to separate unittests (in progress)

Future:

  • create and contribute to tiktop (see linux iftop) project

REMARKS: This project is rewritten version of deprecated tik4net at googlecode (last version was 0.9.7.)

Licenses

  • Apache 2.0.

About

Manage mikrotik routers with .NET C# code via ADO.NET like API or enjoy O/R mapper like highlevel api.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.2%
  • Batchfile 0.8%