summaryrefslogtreecommitdiff
path: root/protm.c
blob: 932efcac56b25a85babfbf234347e6278c4db3d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdbool.h>
#include <assert.h>
#include "protm.h"

size_t protm_size(const struct protm *pm) {
	switch (pm->type) {
		case PROTM_TYPE_ESTAB:
			return 2;

		case PROTM_TYPE_TERM:
			return 2;

		case PROTM_TYPE_DATA:
			return 7 + pm->data.size;

		case PROTM_TYPE_RR:
			return 3 + pm->rr.nrej;

		case PROTM_TYPE_RR_POLL:
			return 1;

		default:
			assert(false);
	}
}