API bug

I use php script from wiki and I think I found new api bug.

Sometimes (it’s rather rare but when I run this script 100 times per day on 60 routers you can observe 40 scripts in invalid state) I get response from router (command is /interface/wireless/registration-table/getall) where first byte is correct encoded length of the following word but second byte is 0x00 and normal response starts from 3rd byte.

It causes that php script usually loop till i have to kill it (it looses synchronization and interprets bad bytes in following words as their length).

Example:

I can get this:

XY=wmm-enabled=true

where ord(X)=17 and Y=0x00.

As a response I read word as:

Y=wmm-enabled=tru

Then length of next word is ord(‘e’) where ‘e’ is from word ‘true’

Have you seen that?

Thanks

I made further investigation and found that one bug divided into two different bugs.

First is as described before and second is similar to this bug observed by another user:

http://forum.mikrotik.com/viewtopic.php?f=9&t=30687&hilit=0x00

I checked incoming data from router with wireshark and found that sometimes when word length byte is first data byte of tcp packet then it consists of one more byte.

This is screenshot from wireshark:
MikrotikBug.png
Beginning of packet is at byte 2C15. There are two bytes but the length of following word is only second one. First byte is unknown to me and I very dislike it cause it kills my script.

I can present wireshark packet dump if needed.

what version of RouterOS you are using and on what router. How large is your registration table.

Hi janisk,
we use mostly version 3.10 so that I have observed it only on 3.10. Number of items in registration table varies (from 16 to 45, depends on the router).

First problem is harmless becouse i can detect it but second problem is worse becouse sometimes it creates good formed length number (which is totally incorrect and it makes word length bigger than 127 even though it’s smaller or equal than 127).

Thank you

there where problems with API replies on older versions, i just do not remember when exactly they where fixed. So definitely upgrade to newer version of RouterOS at least 3.30 that has been there for some time already.