This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/common/test/test_cmsg.cpp

58 lines
1.6 KiB
C++
Raw Normal View History

#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);
}
*/