Api RouterOSv3

Hi!
I try to send login cmomand usgin API. I use C++.
First i send /login command. I send ASCII code (6) + “/login” + ASCII code(0). Server return the response:
!done
=ret=xxxxxxxxxxxxxxx

And now.. i don’t know how i send the command:
/login
=name=admin
=response=xxxxxxxxxxxxxxxxxxxxxxx

I don’t understand how use this packets…

any idea?

hiz
i know how work..
after receive
!done
=ret=xxxxxxxxxxxxxxx

i send

/login
=name=admin
=response=00xxxxxx
where xxxx => make md5 digest of “\x00” + password + xxxxxxxxx before received but don’t work

Example of this with example of wiki…
/login
!done
=ret=ebddd18303a54111e2dea05a92ab46b4


my response…
/login
=name=admin
=response=001ea726ed53ae38520c8334f82d44c9f2

this code → 001ea726ed53ae38520c8334f82d44c9f2 I don’t know how to create. I know apply md5 digest of (password,ret,“\x00”) but not work

md5 digest should be made of “\x00”, password and ret (in this order). And note that ret should be converted to binary string by taking every two characters as hexadecimal representing one byte.

hi,

what is the password used in the example of the wiki? If i know de password i can find how do the method..

I do.. ret = 642345B3…
64 = 100
23 = 35
etc..

and chr(100) = d
chr(35) = #
etc…

and i have digest of “\x00” and psw (not password) and “d#…”

but not work..
i recive !trap=message=cannot log in

You should add “00” to the beginning of the response. That should make it work.

And password in the example probably is empty.

Trace:

/login

!done
=ret=cbd69749b5cc96fbb0847ced208d80fc

r1 = bytes(203,214,151,73,…,252)
r = ËÖ—IµÌ–û°„|í

It does not look that your conversion if result to hexadecimal is correct. result1 has a lot of 3Fs (that corresponds to ?), but none of ‘?’ is in your original result.

The problem is in codification… in example the byte ‘b4’ is a special character but in Windows.. is a different special character..

Hiz forum!
now i can connect to mikrotik using api (no python).
My question now is..
What kind of commands are aviable in beta5?
getall,listen,remove,more? (enable?disable?)

if i send command: /interface/vlan/remove
=name=vlan1
not work, i recive: argument error

You should use getall to get all interfaces like “/interface/vlan/getall” (see
API doc on wiki). You should provide values returned in =.id, to =numbers
like this =numbers=*1. Next versions will require to pass it in =.id
parameter.

I.e. you should send command: /interface/vlan/remove
=numbers=*1

You can print ids in console using command “:put [/interface vlan find]”.

Oh thx,
i supose in the future versions we can remove one item without print this command (find) in console.
i waiting for new versions!!! :astonished: :astonished:

I have another question.. for discovery neighboors you use a protocol for this.. this protocol is private? thx for all!

  1. you can already use numbers without print in v3
  2. yes, it’s private for now

Hi,
now i send command /interface/vlan/getall
and recive parametres of vlan1. vlan1 have *5 id
if i send /interface/vlan/remove
=numbers=*5
i not recive nothing, the socket waiting for response from the server (mikrotik)

Hello,

Using the python example on the wiki I am successful at making a connection and submitting a few commands. However, the example of /user/active/listen just hangs the connection - waiting for a response from RouterOS. It seems many commands just hang there … does beta6 work with the example in the wiki ?

Also, does the listen command similiar to the ‘monitor’ command?

Can you give me an example of how to monitor tx/rx bytes on an ethernet interface using the API? Would it be /interface/monitor=0/listen or something ?

Thx,
Sam

‘listen’ command is meant to receive asynchronous notifications about events in particular menu.

what you want will be possible in Beta7, we are working on new wiki example, and help. There are a lot of new API features in Beta7

Excellent. We are integrating the v3 api into our new listmanager program.

Can we add a /ip firewall address-list entry and assign a TTL (like the dynamic add-src-to-addresslist action) using the API?

keep up the good work.

Sam

Docs updated: http://wiki.mikrotik.com/wiki/API

Oh! good! tomorrow I will test new commands!
Thx normis!

Do you mean pass in \x00 as a string, or chr(0) ?

Should I be using ASCII encoding, or UTF7/8 ?

Sam

Here is some debug … I’ve been working on this for hours and can’t seem to figure it out… dang!

/login

!done
=ret=0e0f9cb1066f16bdde3683c8b3549031

Hex: 0e Dec: 14
Hex: 0f Dec: 15
Hex: 9c Dec: 156
Hex: b1 Dec: 177
Hex: 06 Dec: 6
Hex: 6f Dec: 111
Hex: 16 Dec: 22
Hex: bd Dec: 189
Hex: de Dec: 222
Hex: 36 Dec: 54
Hex: 83 Dec: 131
Hex: c8 Dec: 200
Hex: b3 Dec: 179
Hex: 54 Dec: 84
Hex: 90 Dec: 144
Hex: 31 Dec: 49

Binary Ret: œ±o½Þ6ƒÈ³T