summaryrefslogtreecommitdiff
path: root/common/test/test_cmsg.cpp
blob: a5a859f5f16c0a176e470673af72d53a2c70ef5c (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include "tfe_types.h"
#include "tfe_utils.h"
#include "tfe_cmsg.h"

int main()
{
    return 0;
}

/*
int main(){
	//init
	struct tfe_cmsg *cmsg = tfe_cmsg_init();

	//set
	uint32_t value = 0x12345678;
	int ret = tfe_cmsg_set(cmsg, TFE_CMSG_TCP_RESTORE_SEQ, (const unsigned char*)(&value), 4);
	printf("tfe_cmsg_set: ret is %d\n", ret);

	//get TCP_RESTORE_INFO_TLV_SEQ
	uint16_t size = -1;
	unsigned char *value1 = NULL;
	ret = tfe_cmsg_get(cmsg, TFE_CMSG_TCP_RESTORE_SEQ, &size, &value1);
	printf("tfe_cmsg_get: ret is %d, type is TCP_RESTORE_INFO_TLV_SEQ, value is 0x%02x, value_size is %d\n", ret, ((uint32_t*)value1)[0], size);

	//get_serialize_size
	size = tfe_cmsg_serialize_size_get(cmsg);
	printf("tfe_cmsg_serialize_size_get: size is %d\n", size);

	//serialize
	unsigned char buff[size];
	uint16_t serialize_len = -1;
	ret = tfe_cmsg_serialize(cmsg, buff, size, &serialize_len);
	printf("tfe_cmsg_serialize: ret is %d, serialize_len is %d, serialize result is:   ", ret, serialize_len);
	for(int i = 0; i < serialize_len; i++){
		printf("%02x ", buff[i]);
	}
	printf("\n");

	//deserialize
	struct tfe_cmsg *cmsg1 = NULL;
	ret = tfe_cmsg_deserialize(buff, serialize_len, &cmsg1);
	printf("tfe_cmsg_deserialize: ret is %d\n", ret);

	//get TCP_RESTORE_INFO_TLV_SEQ
	size = -1;
	unsigned char *value2 = NULL;
	ret = tfe_cmsg_get(cmsg1, TFE_CMSG_TCP_RESTORE_SEQ, &size, &value2);
	printf("tfe_cmsg_get: ret is %d, type is TCP_RESTORE_INFO_TLV_SEQ, value is 0x%02x, value_size is %d\n", ret, ((uint32_t*)value2)[0], size);
}
*/