use pen_type_t for PA Message Subtype
This commit is contained in:
@@ -68,14 +68,9 @@ struct private_pb_pa_msg_t {
|
||||
bool excl;
|
||||
|
||||
/**
|
||||
* PA Message Vendor ID
|
||||
* Vendor-specific PA Subtype
|
||||
*/
|
||||
u_int32_t vendor_id;
|
||||
|
||||
/**
|
||||
* PA Subtype
|
||||
*/
|
||||
u_int32_t subtype;
|
||||
pen_type_t subtype;
|
||||
|
||||
/**
|
||||
* Posture Validator Identifier
|
||||
@@ -124,8 +119,8 @@ METHOD(pb_tnc_msg_t, build, void,
|
||||
/* build message header */
|
||||
writer = bio_writer_create(64);
|
||||
writer->write_uint8 (writer, this->excl ? PA_FLAG_EXCL : PA_FLAG_NONE);
|
||||
writer->write_uint24(writer, this->vendor_id);
|
||||
writer->write_uint32(writer, this->subtype);
|
||||
writer->write_uint24(writer, this->subtype.vendor_id);
|
||||
writer->write_uint32(writer, this->subtype.type);
|
||||
writer->write_uint16(writer, this->collector_id);
|
||||
writer->write_uint16(writer, this->validator_id);
|
||||
msg_header = writer->get_buf(writer);
|
||||
@@ -145,8 +140,8 @@ METHOD(pb_tnc_msg_t, process, status_t,
|
||||
/* process message header */
|
||||
reader = bio_reader_create(this->encoding);
|
||||
reader->read_uint8 (reader, &flags);
|
||||
reader->read_uint24(reader, &this->vendor_id);
|
||||
reader->read_uint32(reader, &this->subtype);
|
||||
reader->read_uint24(reader, &this->subtype.vendor_id);
|
||||
reader->read_uint32(reader, &this->subtype.type);
|
||||
reader->read_uint16(reader, &this->collector_id);
|
||||
reader->read_uint16(reader, &this->validator_id);
|
||||
this->excl = ((flags & PA_FLAG_EXCL) != PA_FLAG_NONE);
|
||||
@@ -160,14 +155,14 @@ METHOD(pb_tnc_msg_t, process, status_t,
|
||||
}
|
||||
reader->destroy(reader);
|
||||
|
||||
if (this->vendor_id == PEN_RESERVED)
|
||||
if (this->subtype.vendor_id == PEN_RESERVED)
|
||||
{
|
||||
DBG1(DBG_TNC, "Vendor ID 0x%06x is reserved", PEN_RESERVED);
|
||||
*offset = 1;
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (this->subtype == PA_RESERVED_SUBTYPE)
|
||||
if (this->subtype.type == PA_RESERVED_SUBTYPE)
|
||||
{
|
||||
DBG1(DBG_TNC, "PA Subtype 0x%08x is reserved", PA_RESERVED_SUBTYPE);
|
||||
*offset = 4;
|
||||
@@ -184,11 +179,10 @@ METHOD(pb_tnc_msg_t, destroy, void,
|
||||
free(this);
|
||||
}
|
||||
|
||||
METHOD(pb_pa_msg_t, get_vendor_id, u_int32_t,
|
||||
private_pb_pa_msg_t *this, u_int32_t *subtype)
|
||||
METHOD(pb_pa_msg_t, get_subtype, pen_type_t,
|
||||
private_pb_pa_msg_t *this)
|
||||
{
|
||||
*subtype = this->subtype;
|
||||
return this->vendor_id;
|
||||
return this->subtype;
|
||||
}
|
||||
|
||||
METHOD(pb_pa_msg_t, get_collector_id, u_int16_t,
|
||||
@@ -230,7 +224,7 @@ pb_tnc_msg_t *pb_pa_msg_create_from_data(chunk_t data)
|
||||
.process = _process,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.get_vendor_id = _get_vendor_id,
|
||||
.get_subtype = _get_subtype,
|
||||
.get_collector_id = _get_collector_id,
|
||||
.get_validator_id = _get_validator_id,
|
||||
.get_body = _get_body,
|
||||
@@ -261,15 +255,14 @@ pb_tnc_msg_t *pb_pa_msg_create(u_int32_t vendor_id, u_int32_t subtype,
|
||||
.process = _process,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.get_vendor_id = _get_vendor_id,
|
||||
.get_subtype= _get_subtype,
|
||||
.get_collector_id = _get_collector_id,
|
||||
.get_validator_id = _get_validator_id,
|
||||
.get_body = _get_body,
|
||||
.get_exclusive_flag = _get_exclusive_flag,
|
||||
},
|
||||
.type = PB_MSG_PA,
|
||||
.vendor_id = vendor_id,
|
||||
.subtype = subtype,
|
||||
.subtype = { vendor_id, subtype },
|
||||
.collector_id = collector_id,
|
||||
.validator_id = validator_id,
|
||||
.excl = excl,
|
||||
|
||||
@@ -25,6 +25,8 @@ typedef struct pb_pa_msg_t pb_pa_msg_t;
|
||||
|
||||
#include "pb_tnc_msg.h"
|
||||
|
||||
#include <pen/pen.h>
|
||||
|
||||
/**
|
||||
* Class representing the PB-PA message type.
|
||||
*/
|
||||
@@ -38,10 +40,9 @@ struct pb_pa_msg_t {
|
||||
/**
|
||||
* Get PA Message Vendor ID and Subtype
|
||||
*
|
||||
* @param subtype PA Subtype
|
||||
* @return PA Message Vendor ID
|
||||
* @return Vendor-specific PA Subtype
|
||||
*/
|
||||
u_int32_t (*get_vendor_id)(pb_pa_msg_t *this, u_int32_t *subtype);
|
||||
pen_type_t (*get_subtype)(pb_pa_msg_t *this);
|
||||
|
||||
/**
|
||||
* Get Posture Collector ID
|
||||
|
||||
@@ -208,30 +208,31 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
|
||||
case PB_MSG_PA:
|
||||
{
|
||||
pb_pa_msg_t *pa_msg;
|
||||
u_int32_t msg_vid, msg_subtype;
|
||||
pen_type_t msg_subtype;
|
||||
u_int16_t imc_id, imv_id;
|
||||
chunk_t msg_body;
|
||||
bool excl;
|
||||
enum_name_t *pa_subtype_names;
|
||||
|
||||
pa_msg = (pb_pa_msg_t*)msg;
|
||||
msg_vid = pa_msg->get_vendor_id(pa_msg, &msg_subtype);
|
||||
msg_subtype = pa_msg->get_subtype(pa_msg);
|
||||
msg_body = pa_msg->get_body(pa_msg);
|
||||
imc_id = pa_msg->get_collector_id(pa_msg);
|
||||
imv_id = pa_msg->get_validator_id(pa_msg);
|
||||
excl = pa_msg->get_exclusive_flag(pa_msg);
|
||||
|
||||
pa_subtype_names = get_pa_subtype_names(msg_vid);
|
||||
pa_subtype_names = get_pa_subtype_names(msg_subtype.vendor_id);
|
||||
if (pa_subtype_names)
|
||||
{
|
||||
DBG2(DBG_TNC, "handling PB-PA message type '%N/%N' 0x%06x/0x%08x",
|
||||
pen_names, msg_vid, pa_subtype_names, msg_subtype,
|
||||
msg_vid, msg_subtype);
|
||||
pen_names, msg_subtype.vendor_id, pa_subtype_names,
|
||||
msg_subtype.type, msg_subtype.vendor_id, msg_subtype.type);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG2(DBG_TNC, "handling PB-PA message type '%N' 0x%06x/0x%08x",
|
||||
pen_names, msg_vid, msg_vid, msg_subtype);
|
||||
pen_names, msg_subtype.vendor_id, msg_subtype.vendor_id,
|
||||
msg_subtype.type);
|
||||
}
|
||||
|
||||
this->send_msg = TRUE;
|
||||
@@ -239,13 +240,15 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
|
||||
{
|
||||
tnc->imvs->receive_message(tnc->imvs, this->connection_id,
|
||||
excl, msg_body.ptr, msg_body.len,
|
||||
msg_vid, msg_subtype, imc_id, imv_id);
|
||||
msg_subtype.vendor_id,
|
||||
msg_subtype.type, imc_id, imv_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
tnc->imcs->receive_message(tnc->imcs, this->connection_id,
|
||||
excl, msg_body.ptr, msg_body.len,
|
||||
msg_vid, msg_subtype, imv_id, imc_id);
|
||||
msg_subtype.vendor_id,
|
||||
msg_subtype.type, imv_id, imc_id);
|
||||
}
|
||||
this->send_msg = FALSE;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user