danikf / tik4net

Manage mikrotik routers with .NET C# code via ADO.NET like API or enjoy O/R mapper like highlevel api.
Apache License 2.0
174 stars 93 forks source link

Dbii Networks interface #26

Closed AsafMag closed 6 years ago

AsafMag commented 6 years ago

When I try to configure the red interface of Dbii Networks, an "unknown parameter" exception is thrown. As much as I researched, this is because of the default-name parameter.

How can I remove it?

danikf commented 6 years ago

Hi,

Could you please provide some code?

Thanks, D

Dne ne 1. dub 2018 8:24 uživatel AsafMag notifications@github.com napsal:

When I try to configure the red interface of Dbii Networks, an "unknown parameter" exception is thrown. As much as I researched, this is because of the default-name parameter.

How can I remove it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/danikf/tik4net/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/ANIZGqMHkoWpd2UhvMkKv7vVtdaqaDikks5tkHKdgaJpZM4TCuv7 .

AsafMag commented 6 years ago
var redInterface = connection.LoadAll<InterfaceWireless>().First(wlan => wlan.Name == "red");

connection.Save(redInterface);

Have to say that I encountered many more problems with the library, including trap interrupted exceptions a second after I start a sniff command, strangely without any unusual bytes sent to TCP 8728 compared to other libraries in different languages.

danikf commented 6 years ago

Hi, I am not sure which version of library/mikrotik do you use, but I am 100% sure that your example works like a charm. I am using various versions of mikrotiks, but for unitesting I am using 6.10 version (virtual image).

Instead of sniffer I would recommend you to hook OnWriteRow event on connection to see what is going to the mikrotik router. See https://github.com/danikf/tik4net/wiki/Communication-debugging-&-testing

And finaly - if you want to achieve "standard" library behavior with full control of communication, you can use pure connection commands - see https://github.com/danikf/tik4net/wiki/Low-level-API

BTW - 8728 is standard port for mikrotik API and 'trap interupted' is standard behavior when you send bad request :-)

As last point - there could be problem with encoding some exotic characters (names/comments) - see https://github.com/danikf/tik4net/wiki/How-to-use-tik4net-library#how-to-encode-non-ascii-characters.

D

AsafMag commented 6 years ago

I think this problem is specific to Dbii's interfaces http://www.dbii.com/f36N-PRO.html I'll try to find some answers and update

danikf commented 6 years ago

Hi, you can try to use lowlevel API or use "usedFieldsFilter" (last optional parameter in Save method) to specify fields you have modified (to avoid "full save"). D

AsafMag commented 6 years ago

I'm using it now, but it's pretty ugly - it makes the user have to know the underlying strings, which is a bad idea for a wrapping library in my opinion.

danikf commented 6 years ago

Hi,

in this case - I am not sure - default-name seams to be R/O in mikrotik. So you could try to patch tik4net sources by setting the property to R/O (parameter in attribute) - this will instruct engine to skip it during save. But the filed default-name is not present in InterfaceWireless, so I expect you tried to use "Intrerface" and not "InterfaceWireless" ...

Other libraries usually publish just Send/Read API because of variability of mikrotik commands and types. So wrapping-up the strings could be sometimes tricky ...

D

2018-04-01 12:59 GMT+02:00 AsafMag notifications@github.com:

I'm using it now, but it's pretty ugly - it makes the user have to know the underlying strings, which is a bad idea for a wrapping library in my opinion.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/danikf/tik4net/issues/26#issuecomment-377778919, or mute the thread https://github.com/notifications/unsubscribe-auth/ANIZGmvJm_Jcieh02i9dUdu6AM6q2RCEks5tkLMCgaJpZM4TCuv7 .

AsafMag commented 6 years ago

I think I figured the cause of the interrupted bug - both interfaces stop sniffing because of the done / interrupted response to the first one to finish (cancel).

I found that requesting a /cancel for a specific tag returns a trap interrupted for the tags of all the open sniffers. This is not the behavior in another library I use with a different language.

Do you have an idea on how to solve this? I know it is possible.

danikf commented 6 years ago

Hi,

if the appropriate .tag is send with "cancel" command, than it is mikrotik feature :-) If not, than it is possibly bug in tik4net. I am not sure if it is possible to sniff more than one interface in one time in mikrotik because of linux background logic behind the sniffer ...

D

2018-04-01 15:25 GMT+02:00 AsafMag notifications@github.com:

I think I figured the interrupted bug - both interfaces stop sniffing because of the done / interrupted response to the first one to finish (cancel).

Do you have an idea how to solve this?

AsafMag commented 6 years ago

It is possible

danikf commented 6 years ago

Hi, not sure about sniffer (do you reallu use /tool/sniffer?), but /tool/torch seams to have "singleton" behavior by design.

And in console script it looks like:

/tool/torch
=interface=ether1
.tag=1

/tool/torch
=interface=wlan1
.tag=2

!re
.....
.....

/cancel
=.tag=2
!trap
=category=2
=message=interrupted
.tag=1

!trap
=category=2
=message=interrupted
.tag=2

!done
.tag=1

!done
.tag=2

So - one cancel and two canceled commands ... And no exception/error callback from API. This is correct behavoir of API and understandable behavior of mikrotik router.

D

RaelKbg commented 6 years ago

Hi

when I'm trying to reset-counters im getting a 'no such command' error.

Please help, this is my code: var cmd= connection.CreateCommandAndParameters("/tool/user-manager/user/reset-counters ", "?=numbers", txtreset.Text);

danikf commented 6 years ago

Hi RaelKbg - please use your thread with proper name :-)

D

RaelKbg commented 6 years ago

Hi danikf

please specify. I used the same code to print where download-used > and it worked fine.

danikf commented 6 years ago

Don't use Issue with name "Dbii Networks interface" dor discussion about different topic please ...

AsafMag commented 6 years ago

Hi,

Actually I use interface/wireless/sniffer/sniff

AsafMag commented 6 years ago

? :-)

RaelKbg commented 6 years ago

Hi AsafMag

Im sorted thank you.

AsafMag commented 6 years ago

About the sniffing cancellation - opened issue #35 , closing this one.