Audiovox P965 Datasheet Page 60

  • Download
  • Add to my manuals
  • Print
  • Page
    / 280
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 59
API in C using winsock
57
API in C using winsock
This is an implementation of RouterOS API written on C that using winsock2 for compatibility with Windows
operation systems. It's based on API in C
[1]
(You should use all sources from here, except mikrotik-api.c, that
incompatible with Windows). Use compatible mikrotik-api.c source from below.
If your compiler does not support "#pragma comment", add ws2_32.lib to your linker manually.
RouterOS API Source file (mikrotik-api.c)
/********************************************************************
* Some definitions
* Word = piece of API code
* Sentence = multiple words
* Block = multiple sentences (usually in response to a sentence request)
*
int fdSock;
int iLoginResult;
struct Sentence stSentence;
struct Block stBlock;
fdSock = apiConnect("10.0.0.1", 8728);
// attempt login
iLoginResult = login(fdSock, "admin", "adminPassword");
if (!iLoginResult)
{
apiDisconnect(fdSock);
printf("Invalid username or password.\n");
exit(1);
}
// initialize, fill and send sentence to the API
initializeSentence(&stSentence);
addWordToSentence(&stSentence, "/interface/getall");
writeSentence(fdSock, &stSentence);
// receive and print block from the API
stBlock = readBlock(fdSock);
printBlock(&stBlock);
apiDisconnect(fdSock);
********************************************************************/
// C implementation of Mikrotik's API rewritten for Winsock2 (for windows)
Page view 59
1 2 ... 55 56 57 58 59 60 61 62 63 64 65 ... 279 280

Comments to this Manuals

No comments