msg: Introduce a TLV list.
In order to support multiple TLVs per message, a list is needed. This patch adds the list to the message structure. This list will eventually replace the 'last_tlv' field. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
c8d9d05e7a
commit
22b894b687
12
msg.c
12
msg.c
|
@ -204,6 +204,7 @@ struct ptp_message *msg_allocate(void)
|
|||
if (m) {
|
||||
memset(m, 0, sizeof(*m));
|
||||
m->refcnt = 1;
|
||||
TAILQ_INIT(&m->tlv_list);
|
||||
}
|
||||
|
||||
return m;
|
||||
|
@ -447,12 +448,19 @@ void msg_print(struct ptp_message *m, FILE *fp)
|
|||
|
||||
void msg_put(struct ptp_message *m)
|
||||
{
|
||||
struct tlv_extra *extra;
|
||||
|
||||
m->refcnt--;
|
||||
if (!m->refcnt) {
|
||||
if (m->refcnt) {
|
||||
return;
|
||||
}
|
||||
pool_stats.count++;
|
||||
pool_debug("recycle", m);
|
||||
TAILQ_INSERT_HEAD(&msg_pool, m, list);
|
||||
while ((extra = TAILQ_FIRST(&m->tlv_list)) != NULL) {
|
||||
TAILQ_REMOVE(&m->tlv_list, extra, list);
|
||||
tlv_extra_recycle(extra);
|
||||
}
|
||||
TAILQ_INSERT_HEAD(&msg_pool, m, list);
|
||||
}
|
||||
|
||||
int msg_sots_missing(struct ptp_message *m)
|
||||
|
|
Loading…
Reference in New Issue