summaryrefslogtreecommitdiffstats
path: root/qtctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'qtctl.c')
-rw-r--r--qtctl.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/qtctl.c b/qtctl.c
new file mode 100644
index 0000000..e601ad9
--- /dev/null
+++ b/qtctl.c
@@ -0,0 +1,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_TYPE, QUICKTUN_TAP_DEV);
+ nla_put_u32(msg, QUICKTUN_A_REMOTE_ADDRESS, ntohl(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;
+}