From: Florian Forster Date: Thu, 19 Nov 2009 11:51:20 +0000 (+0100) Subject: Login handlers: Check status code of replies. X-Git-Tag: librouteros-0.1.0~16 X-Git-Url: https://git.octo.it/?p=routeros-api.git;a=commitdiff_plain;h=b8e0e6c287dc269a734f517dd56dfc224b732790 Login handlers: Check status code of replies. --- diff --git a/src/main.c b/src/main.c index 4ad7e8f..1c9fefe 100644 --- a/src/main.c +++ b/src/main.c @@ -638,6 +638,12 @@ static int login2_handler (mt_connection_t *c, const mt_reply_t *r, /* {{{ */ printf ("login2_handler has been called.\n"); reply_dump (r); + if (strcmp (r->status, "done") != 0) + { + mt_debug ("login2_handler: Unexpected status: %s.\n", r->status); + return (EPROTO); + } + return (0); } /* }}} int login2_handler */ @@ -709,9 +715,22 @@ static int login_handler (mt_connection_t *c, const mt_reply_t *r, /* {{{ */ if (r == NULL) return (EINVAL); + /* The expected result looks like this: + * -- 8< -- + * !done + * =ret=ebddd18303a54111e2dea05a92ab46b4 + * -- >8 -- + */ + printf ("login_handler has been called.\n"); reply_dump (r); + if (strcmp (r->status, "done") != 0) + { + mt_debug ("login_handler: Unexpected status: %s.\n", r->status); + return (EPROTO); + } + login_data = user_data; if (login_data == NULL) return (EINVAL);