我正在尝试使用sock_sendmsg()从驱动程序发送UDP数据包。
有几个关于如何使用sock_sendmsg()和msghdr填写UDP数据包并进行传输的指南,但它们都适用于较旧的内核版本。在3.13和4.8之间的某个时间,struct msghdr从:
改变Element row = doc.select("tr").get(0);
Element col = row.select("td").get(1);
String text = col.text();
System.out.println(text);
要:
struct msghdr {
void * msg_name; /* Socket name */
int msg_namelen; /* Length of name */
struct iovec * msg_iov; /* Data blocks */
__kernel_size_t msg_iovlen; /* Number of blocks */
void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
__kernel_size_t msg_controllen; /* Length of cmsg list */
unsigned int msg_flags;
};
而不是将msg_iov设置为指向带有数据的iovec:
struct msghdr {
void *msg_name; /* ptr to socket address structure */
int msg_namelen; /* size of socket address structure */
struct iov_iter msg_iter; /* data */
void *msg_control; /* ancillary data */
__kernel_size_t msg_controllen; /* ancillary data buffer length */
unsigned int msg_flags; /* flags on received message */
struct kiocb *msg_iocb; /* ptr to iocb for async requests */
};
现在有一个iov_iter结构:
struct msghdr msg = {};
struct iovec iov = {};
iov.iov_base = data;
iov.iov_len = dataLen;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
如何使用数据填写msghdr内部的iov_iter结构,以便将其传递给sock_sendmsg?
答案 0 :(得分:1)
经过一些游戏并阅读Ctx(lwn.net/Articles/625077)发布的指南后,我发现了。
Product_Code Date Price
A Jan 10.5
A Dec 11.2
B jun 8.1
...