在mac

时间:2015-11-05 20:36:57

标签: c++ macos sockets ip

我试图纠正一些套接字编程的东西,我在尝试制作cpp文件时面临以下错误,我在OS X 10.11上:

user-router / sm.cpp:84:3:错误:未知类型名称' iphdr'

这是特定部分的代码:

void SimulatedMachine::run () {
// TODO: write your business logic here...
struct ethernet_header {
byte  dst[6];
byte  src[6];
uint16 type;
} __attribute__ ((packed));

const int frameLength = sizeof (ethernet_header) + 100;
byte *data = new byte[frameLength];

ethernet_header *eth = (ethernet_header *) data;
memset (eth->dst, 255, 6); // broadcast address
memcpy (eth->src, iface[0].mac, 6);
eth->type = htons (0x0800);

iphdr *packet = (iphdr *) (data + sizeof (ethernet_header));
packet->version = 4;
packet->ihl = 5;
packet->tot_len = htons (100);

Frame frame (frameLength, data);
sendFrame (frame, 0); // sends frame on interface 0
delete[] data;
cerr << "now ./free.sh and check the pcap log file to see the sent packet" <<      endl;
}

因为iphdr应该存在于我所包含的内容中。

感谢任何帮助。

0 个答案:

没有答案