]> granicus.if.org Git - strace/blob - tests/nfnetlink_osf.c
Update copyright headers
[strace] / tests / nfnetlink_osf.c
1 /*
2  * Copyright (c) 2017 JingPiao Chen <chenjingpiao@gmail.com>
3  * Copyright (c) 2017-2018 The strace developers.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8
9 #include "tests.h"
10
11 #ifdef HAVE_LINUX_NETFILTER_XT_OSF_H
12
13 # include <stdio.h>
14 # include <sys/socket.h>
15 # include "netlink.h"
16 # include <linux/ip.h>
17 # include <linux/tcp.h>
18 # include <linux/netfilter/nfnetlink.h>
19 # include <linux/netfilter/xt_osf.h>
20
21 static void
22 test_nlmsg_type(const int fd)
23 {
24         long rc;
25         struct nlmsghdr nlh = {
26                 .nlmsg_len = sizeof(nlh),
27                 .nlmsg_flags = NLM_F_REQUEST,
28         };
29
30         nlh.nlmsg_type = NFNL_SUBSYS_OSF << 8 | OSF_MSG_ADD;
31         rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
32         printf("sendto(%d, {len=%u"
33                ", type=NFNL_SUBSYS_OSF<<8|OSF_MSG_ADD"
34                ", flags=NLM_F_REQUEST, seq=0, pid=0}"
35                ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
36                fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
37
38         nlh.nlmsg_type = NFNL_SUBSYS_OSF << 8 | 0xff;
39         rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
40         printf("sendto(%d, {len=%u"
41                ", type=NFNL_SUBSYS_OSF<<8|0xff /* OSF_MSG_??? */"
42                ", flags=NLM_F_REQUEST, seq=0, pid=0}"
43                ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
44                fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
45 }
46
47 int
48 main(void)
49 {
50         skip_if_unavailable("/proc/self/fd/");
51
52         int fd = create_nl_socket(NETLINK_NETFILTER);
53
54         test_nlmsg_type(fd);
55
56         puts("+++ exited with 0 +++");
57
58         return 0;
59 }
60
61 #else
62
63 SKIP_MAIN_UNDEFINED("HAVE_LINUX_NETFILTER_XT_OSF_H")
64
65 #endif