64,637
社区成员
发帖
与我相关
我的任务
分享
typedef struct {
uint8_t type;
uint16_t version;
uint16_t length;
uint8_t *protocol;
} __attribute__((packed)) a_header;
typedef struct {
uint32_t type : 8;
uint32_t length : 24;
uint8_t *payload;
} __attribute__((packed)) b_header;
a *a_hdr = (a_header *)packet; //packet为数据包
b_header *b_hdr = (b_header *)(&a_hdr->protocol);
if (b_hdr->type == MY_TYPE) {
return 1;
}
else {
return 0;
}
b_header *b_hdr = (b_header *)(&a_hdr->protocol);
b_header *b_hdr = (b_header *)(a_hdr->protocol);