pmc: make the TLV length a functional result.

This patch lets the TLV length field of GET messages come from a
function. For now, the function still results in a length of two,
but the intent is to allow different values later.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2013-07-20 20:54:23 +02:00
parent b4b5487887
commit 4ae27d9179
1 changed files with 9 additions and 3 deletions

View File

@ -134,6 +134,11 @@ static int pmc_send(struct pmc *pmc, struct ptp_message *msg, int pdulen)
return 0;
}
static int pmc_tlv_datalen(struct pmc *pmc, int id)
{
return 0;
}
int pmc_get_transport_fd(struct pmc *pmc)
{
return pmc->fdarray.fd[FD_GENERAL];
@ -141,7 +146,7 @@ int pmc_get_transport_fd(struct pmc *pmc)
int pmc_send_get_action(struct pmc *pmc, int id)
{
int pdulen;
int datalen, pdulen;
struct ptp_message *msg;
struct management_tlv *mgt;
msg = pmc_message(pmc, GET);
@ -150,9 +155,10 @@ int pmc_send_get_action(struct pmc *pmc, int id)
}
mgt = (struct management_tlv *) msg->management.suffix;
mgt->type = TLV_MANAGEMENT;
mgt->length = 2;
datalen = pmc_tlv_datalen(pmc, id);
mgt->length = 2 + datalen;
mgt->id = id;
pdulen = msg->header.messageLength + sizeof(*mgt);
pdulen = msg->header.messageLength + sizeof(*mgt) + datalen;
msg->header.messageLength = pdulen;
msg->tlv_count = 1;
pmc_send(pmc, msg, pdulen);