【发布时间】:2020-06-30 10:48:48
【问题描述】:
我可以从 char* 负载中填充结构的所有字段吗?
例如,如果我的结构是:
struct ether_header {
u_char ether_dhost[6];
u_char ether_shost[6];
u_short ether_type;
};
如何构建我的
char payload[MAXLEN];
所以
// equivalent to assigning "abcde" to eth_hdr->shost, eth_hdr->dhost
// and any dummy numeric value to eth_hdr->ether_type*
struct ether_header *eth_hdr = (struct ether_header *) payload;
【问题讨论】:
标签: c memory struct char ethernet