cwmsg_vaddelem dont't needs the number of parmateres anymore.

FossilOrigin-Name: 473507160fed34042c878440b123d8f74154f8aea1d5d7c5d7572178943842d1
This commit is contained in:
7u83@mail.ru 2015-03-19 19:45:03 +00:00
parent c6aed6d463
commit e40c67a002
5 changed files with 19 additions and 13 deletions

View File

@ -37,17 +37,21 @@ int conn_prepare_image_data_request(struct conn *conn, struct cwimage_data *data
if (conn->capwap_mode == CWMODE_CISCO) { if (conn->capwap_mode == CWMODE_CISCO) {
uint8_t type = 3; uint8_t type = 3;
uint16_t checksum = htons(lw_checksum(data->data, data->len)); uint16_t checksum = htons(lw_checksum(data->data, data->len));
cwmsg_vaddelem(cwmsg, CWMSGELEM_IMAGE_DATA, 3, cwmsg_vaddelem(cwmsg, CWMSGELEM_IMAGE_DATA,
&type, 1, &checksum, 2, data->data, data->len); &type, 1,
&checksum, 2,
data->data, data->len,
NULL);
return 0; return 0;
} }
/* standard capwap operation */ /* standard capwap operation */
cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_DATA, 2, cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_DATA,
&data->type, sizeof(data->type), &data->type, sizeof(data->type),
data->data, data->len data->data, data->len,
NULL
); );

View File

@ -27,7 +27,7 @@ extern void cwmsg_init(struct cwmsg * cwmsg, uint8_t *buffer, int type, int seqn
//int cwmsg_send(struct cwmsg * cwmsg, int seqnum, int rid, struct conn * conn); //int cwmsg_send(struct cwmsg * cwmsg, int seqnum, int rid, struct conn * conn);
// //
extern void cwmsg_addelem(struct cwmsg *msg,int type, const uint8_t *elem, int len); extern void cwmsg_addelem(struct cwmsg *msg,int type, const uint8_t *elem, int len);
extern void cwmsg_vaddelem(struct cwmsg *msg,int type,int n, ...); extern void cwmsg_vaddelem(struct cwmsg *msg,int type, ...);
extern void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo,struct wtpinfo * wtpinfo); extern void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo,struct wtpinfo * wtpinfo);
extern void cwmsg_addelem_ac_timestamp(struct cwmsg *msg); extern void cwmsg_addelem_ac_timestamp(struct cwmsg *msg);

View File

@ -23,7 +23,7 @@ void cwmsg_addelem_image_identifier(struct cwmsg *cwmsg,uint32_t vendor_id,uint8
{ {
// uint32_t net_vendor_id = htonl(vendor_id); // uint32_t net_vendor_id = htonl(vendor_id);
cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_IDENTIFIER,1,img,len); cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_IDENTIFIER,img,len,NULL);
// cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_IDENTIFIER,2,&net_vendor_id,sizeof(net_vendor_id),img,len); // cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_IDENTIFIER,2,&net_vendor_id,sizeof(net_vendor_id),img,len);
} }

View File

@ -22,19 +22,20 @@
#include "cwmsg.h" #include "cwmsg.h"
void cwmsg_vaddelem(struct cwmsg *msg,int type,int n, ...) void cwmsg_vaddelem(struct cwmsg *msg,int type, ...)
{ {
va_list vl; va_list vl;
va_start(vl,n); va_start(vl,type);
int i,len=0; int len=0;
for (i=0; i<n; i++){
uint8_t *data=va_arg(vl,uint8_t*); uint8_t *data;
while ( ( data = va_arg(vl,uint8_t*)) != 0 ){
int l=va_arg(vl,int); int l=va_arg(vl,int);
memcpy(msg->msgelems+4+msg->pos+len,data,l); memcpy(msg->msgelems+4+msg->pos+len,data,l);
len+=l; len+=l;
} }
uint32_t val = type<<16|len; uint32_t val = type<<16|len;
*((uint32_t*)(msg->msgelems+msg->pos))=htonl(val); *((uint32_t*)(msg->msgelems+msg->pos))=htonl(val);
msg->pos+=4+len; msg->pos+=4+len;

View File

@ -35,10 +35,11 @@ int cwsend_image_data_request(struct conn * conn, struct image_data * data, stru
uint8_t type=3; uint8_t type=3;
uint16_t checksum=0; uint16_t checksum=0;
cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_DATA, 2, cwmsg_vaddelem(cwmsg,CWMSGELEM_IMAGE_DATA,
&type, 1, &type, 1,
&checksum,2, &checksum,2,
data->data, data->len data->data, data->len,
NULL
); );