【发布时间】:2024-01-15 13:26:01
【问题描述】:
下面是我试图通读的代码 sn-p。
swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf)
{
u_int caplen = hdr->caplen;
u_int length = hdr->len;
struct sll_header *shdr = (struct sll_header *)buf;
uint16_t protocol;
pcap_can_socketcan_hdr *chdr;
if (caplen < (u_int) sizeof(struct sll_header) ||
length < (u_int) sizeof(struct sll_header)) {
/* Not enough data to have the protocol field */
return;
}
【问题讨论】:
-
看起来像 C 代码。可能是 C++,但它不是惯用的 C++。
-
这只是一个类型转换。
标签: c pointers character structure