1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/ctrl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "quicktun.h"
int main()
{
struct nl_handle *sock;
struct nl_msg *msg;
struct nl_cb *cb;
int family;
sock = nl_handle_alloc();
genl_connect(sock);
family = genl_ctrl_resolve(sock, "quicktun");
msg = nlmsg_alloc();
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_ECHO, QUICKTUN_CMD_CREATE_DEVICE, 1);
nla_put_u16(msg, QUICKTUN_A_MODE, QUICKTUN_MODE_IP);
nla_put_u32(msg, QUICKTUN_A_REMOTE_ADDRESS, inet_addr("192.168.0.2"));
nl_send_auto_complete(sock, msg);
nlmsg_free(msg);
cb = nl_cb_alloc(NL_CB_DEFAULT);
nl_cb_err(cb, NL_CB_DEBUG, NULL, NULL);
nl_recvmsgs(sock, cb);
return 0;
}
|