2014-08-16 19:29:07 +02:00
|
|
|
/*
|
|
|
|
This file is part of libcapwap.
|
|
|
|
|
|
|
|
libcapwap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2015-03-17 01:10:08 +01:00
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
2014-08-16 19:29:07 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
/**
|
|
|
|
*@file
|
|
|
|
*@brief Image Data handling
|
|
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
|
2014-08-16 19:29:07 +02:00
|
|
|
#include "capwap.h"
|
|
|
|
|
|
|
|
#include "cw_log.h"
|
|
|
|
#include "cw_util.h"
|
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
#include <stdio.h>
|
2014-08-16 19:29:07 +02:00
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
int cw_readelem_image_identifier(struct cwimage_data *data, int type,uint8_t *msgelem, int len)
|
2014-08-16 19:29:07 +02:00
|
|
|
{
|
2015-03-29 09:35:11 +02:00
|
|
|
if (type != CW_ELEM_IMAGE_IDENTIFIER)
|
2014-08-16 19:29:07 +02:00
|
|
|
return 0;
|
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
data->vendor_id = ntohl(*((uint32_t*)msgelem));
|
|
|
|
|
|
|
|
if (len >= 1024) {
|
2015-03-31 08:04:03 +02:00
|
|
|
cw_dbg(DBG_MSG_ERR,"Image identifier too long (>1024), truncating");
|
2015-03-17 01:10:08 +01:00
|
|
|
len = 1024;
|
|
|
|
}
|
2014-08-16 19:29:07 +02:00
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
if ( data->identifier ){
|
|
|
|
memcpy(data->identifier,msgelem,len);
|
|
|
|
*(data->identifier+len)=0;
|
2014-08-16 19:29:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
static int imgdata_request(void * ptr,int type,uint8_t* msgelem,int len)
|
2014-08-16 19:29:07 +02:00
|
|
|
{
|
2015-03-29 01:55:06 +01:00
|
|
|
cw_dbg_msgelem(CW_MSG_IMAGE_DATA_REQUEST, type, msgelem, len);
|
2014-08-16 19:29:07 +02:00
|
|
|
|
|
|
|
|
2015-04-05 02:07:59 +02:00
|
|
|
cw_dbg(DBG_ALL,"Reading image data req msgelem, type=%d - %s ,len=%d\n",type,cw_strelem(type),len);
|
2014-08-16 19:29:07 +02:00
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
if (cw_readelem_image_identifier(ptr,type,msgelem,len))
|
2014-08-16 19:29:07 +02:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-17 01:10:08 +01:00
|
|
|
/**
|
|
|
|
* Read an image data request message
|
|
|
|
*/
|
|
|
|
void cw_read_image_data_request(struct cwimage_data *data, uint8_t * msg, int len)
|
2014-08-16 19:29:07 +02:00
|
|
|
{
|
2015-03-17 01:10:08 +01:00
|
|
|
cw_foreach_msgelem(msg,len,imgdata_request,data);
|
2014-08-16 19:29:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|