2015-04-17 07:38:44 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include "wtp.h"
|
|
|
|
|
2016-03-03 19:51:42 +01:00
|
|
|
#include "cw/log.h"
|
|
|
|
#include "cw/dbg.h"
|
|
|
|
#include "cw/capwap.h"
|
|
|
|
#include "cw/capwap_items.h"
|
2016-03-13 02:40:55 +01:00
|
|
|
#include "cw/vendors.h"
|
2015-04-17 07:38:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
int image_update()
|
|
|
|
{
|
|
|
|
struct conn *conn = get_conn();
|
|
|
|
if (conn->capwap_state != CW_STATE_CONFIGURE) {
|
|
|
|
cw_log(LOG_ERR, "Current state not image update");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *ii = "/c1130";
|
2016-03-04 21:01:38 +01:00
|
|
|
mbag_set_bstrv(conn->outgoing, CW_ITEM_IMAGE_IDENTIFIER,
|
2015-04-17 07:38:44 +02:00
|
|
|
CW_VENDOR_ID_CISCO, (uint8_t *) ii, strlen(ii));
|
|
|
|
|
|
|
|
|
2018-03-05 10:06:18 +01:00
|
|
|
int rc = cw_send_request(conn, CAPWAP_MSG_IMAGE_DATA_REQUEST);
|
2015-04-17 07:38:44 +02:00
|
|
|
|
2018-03-17 16:21:23 +01:00
|
|
|
if (rc < 0) {h
|
2015-04-17 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != 0) {
|
|
|
|
cw_log(LOG_ERR, "AC rejected Image Data Request with code: %d - %s", rc,
|
|
|
|
cw_strresult(rc));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-18 11:20:24 +02:00
|
|
|
cw_dbg(DBG_INFO,"Ready to receive image ...");
|
2015-04-17 07:38:44 +02:00
|
|
|
|
|
|
|
conn->capwap_state=CW_STATE_IMAGE_DATA;
|
|
|
|
rc=-11;
|
|
|
|
while (conn->capwap_state == CW_STATE_IMAGE_DATA) {
|
|
|
|
rc = cw_read_messages(conn);
|
|
|
|
if (rc < 0) {
|
|
|
|
if (errno != EAGAIN)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printf("RC: %d %s\n",rc,strerror(errno));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|