好了,我把整个结构在这里,它的规范,在一些工业交换机实现的协议名为OpenFlow的,所以结构是这样的:填补了一个结构里的数组场
struct ofp_packet_in {
struct ofp_header header;
uint32_t buffer_id; /* ID assigned by datapath. */
uint16_t total_len; /* Full length of frame. */
uint16_t in_port; /* Port on which frame was received. */
uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
uint8_t pad;
uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word,
so the IP header is 32-bit aligned. The
amount of data is inferred from the length
field in the header. Because of padding,
offsetof(struct ofp_packet_in, data) ==
sizeof(struct ofp_packet_in) - 2. */
};
OFP_ASSERT(sizeof(struct ofp_packet_in) == 20);
现在我必须填写最后一个字段中的一些数据,即 - uint8_t data[0]
,这些数据可以变化,并且信息从标题内的长度字段收集。我必须建立一个数据包,并且必须输入数据。请看看。
请再次看到问题,编辑它。 – Abdullah 2012-02-04 10:35:40
我的答案适用于您更改的结构。用你需要的大小替换“+ 100”,并用'container-> data'来填充数据。 – Mat 2012-02-04 10:39:58
@ Mat,thnx mate。欢呼:) – Abdullah 2012-02-04 16:47:10