Make route and netstat share the same struct progops (and initialization code)diff -r1.4 -r1.5 src/sbin/route/prog_ops.h
(martin)
--- src/sbin/route/prog_ops.h 2020/04/02 18:32:31 1.4
+++ src/sbin/route/prog_ops.h 2020/04/03 16:20:52 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: prog_ops.h,v 1.4 2020/04/02 18:32:31 christos Exp $ */ | 1 | /* $NetBSD: prog_ops.h,v 1.5 2020/04/03 16:20:52 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -20,68 +20,89 @@ | @@ -20,68 +20,89 @@ | |||
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #ifndef _PROG_OPS_H_ | 29 | #ifndef _PROG_OPS_H_ | |
30 | #define _PROG_OPS_H_ | 30 | #define _PROG_OPS_H_ | |
31 | 31 | |||
32 | #include <sys/types.h> | 32 | #include <sys/types.h> | |
33 | #include <sys/sysctl.h> | |||
33 | 34 | |||
34 | #ifndef CRUNCHOPS | 35 | #ifndef CRUNCHOPS | |
35 | /* XXX: Keep same order with netstat! */ | 36 | /* | |
37 | * This is shared between netstat and route (as they share some code) | |||
38 | */ | |||
39 | struct sysctlnode; | |||
36 | struct prog_ops { | 40 | struct prog_ops { | |
37 | int (*op_init)(void); | 41 | int (*op_init)(void); | |
38 | 42 | |||
39 | int (*op_socket)(int, int, int); | 43 | int (*op_socket)(int, int, int); | |
40 | int (*op_setsockopt)(int, int, int, const void *, socklen_t); | 44 | int (*op_setsockopt)(int, int, int, const void *, socklen_t); | |
41 | 45 | |||
42 | 46 | |||
43 | int (*op_open)(const char *, int, ...); | 47 | int (*op_open)(const char *, int, ...); | |
44 | pid_t (*op_getpid)(void); | 48 | pid_t (*op_getpid)(void); | |
45 | 49 | |||
46 | ssize_t (*op_read)(int, void *, size_t); | 50 | ssize_t (*op_read)(int, void *, size_t); | |
47 | ssize_t (*op_write)(int, const void *, size_t); | 51 | ssize_t (*op_write)(int, const void *, size_t); | |
48 | 52 | |||
53 | int (*op_shutdown)(int, int); | |||
54 | ||||
49 | int (*op_sysctl)(const int *, u_int, void *, size_t *, | 55 | int (*op_sysctl)(const int *, u_int, void *, size_t *, | |
50 | const void *, size_t); | 56 | const void *, size_t); | |
51 | 57 | |||
52 | int (*op_shutdown)(int, int); | 58 | int (*op_sysctlbyname)(const char *, void *, size_t *, | |
59 | const void *, size_t); | |||
60 | ||||
61 | int (*op_sysctlgetmibinfo)(const char *, int *, u_int *, | |||
62 | char *, size_t *, struct sysctlnode **, int); | |||
63 | ||||
64 | int (*op_sysctlnametomib)(const char *, int *, size_t *); | |||
53 | }; | 65 | }; | |
54 | extern const struct prog_ops prog_ops; | 66 | extern const struct prog_ops prog_ops; | |
55 | 67 | |||
56 | #define prog_init prog_ops.op_init | 68 | #define prog_init prog_ops.op_init | |
57 | 69 | |||
58 | #define prog_socket prog_ops.op_socket | 70 | #define prog_socket prog_ops.op_socket | |
59 | #define prog_setsockopt prog_ops.op_setsockopt | 71 | #define prog_setsockopt prog_ops.op_setsockopt | |
60 | 72 | |||
61 | #define prog_open prog_ops.op_open | 73 | #define prog_open prog_ops.op_open | |
62 | #define prog_getpid prog_ops.op_getpid | 74 | #define prog_getpid prog_ops.op_getpid | |
63 | 75 | |||
64 | #define prog_read prog_ops.op_read | 76 | #define prog_read prog_ops.op_read | |
65 | #define prog_write prog_ops.op_write | 77 | #define prog_write prog_ops.op_write | |
66 | 78 | |||
79 | #define prog_shutdown prog_ops.op_shutdown | |||
80 | ||||
67 | #define prog_sysctl prog_ops.op_sysctl | 81 | #define prog_sysctl prog_ops.op_sysctl | |
68 | 82 | |||
69 | #define prog_shutdown prog_ops.op_shutdown | 83 | #define prog_sysctlbyname prog_ops.op_sysctlbyname | |
84 | #define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo | |||
85 | #define prog_sysctlnametomib prog_ops.op_sysctlnametomib | |||
70 | 86 | |||
71 | #else | 87 | #else | |
72 | #define prog_init ((int (*)(void))NULL) | 88 | #define prog_init ((int (*)(void))NULL) | |
73 | 89 | |||
74 | #define prog_socket socket | 90 | #define prog_socket socket | |
75 | #define prog_setsockopt setsockopt | 91 | #define prog_setsockopt setsockopt | |
76 | 92 | |||
77 | #define prog_open open | 93 | #define prog_open open | |
78 | #define prog_getpid getpid | 94 | #define prog_getpid getpid | |
79 | 95 | |||
80 | #define prog_read read | 96 | #define prog_read read | |
81 | #define prog_write write | 97 | #define prog_write write | |
82 | 98 | |||
83 | #define prog_sysctl sysctl | |||
84 | #define prog_shutdown shutdown | 99 | #define prog_shutdown shutdown | |
100 | ||||
101 | #define prog_sysctl sysctl | |||
102 | #define prog_sysctlbyname sysctlbyname | |||
103 | #define prog_sysctlgetmibinfo sysctlgetmibinfo | |||
104 | #define prog_sysctlnametomib sysctlnametomib | |||
105 | ||||
85 | #endif | 106 | #endif | |
86 | 107 | |||
87 | #endif /* _PROG_OPS_H_ */ | 108 | #endif /* _PROG_OPS_H_ */ |
--- src/sbin/route/route_hostops.c 2020/04/02 18:32:31 1.2
+++ src/sbin/route/route_hostops.c 2020/04/03 16:20:52 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: route_hostops.c,v 1.2 2020/04/02 18:32:31 christos Exp $ */ | 1 | /* $NetBSD: route_hostops.c,v 1.3 2020/04/03 16:20:52 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,40 +18,46 @@ | @@ -18,40 +18,46 @@ | |||
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #ifndef lint | 30 | #ifndef lint | |
31 | __RCSID("$NetBSD: route_hostops.c,v 1.2 2020/04/02 18:32:31 christos Exp $"); | 31 | __RCSID("$NetBSD: route_hostops.c,v 1.3 2020/04/03 16:20:52 martin Exp $"); | |
32 | #endif /* !lint */ | 32 | #endif /* !lint */ | |
33 | 33 | |||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> | |
35 | #include <sys/socket.h> | 35 | #include <sys/socket.h> | |
36 | #include <sys/sysctl.h> | 36 | #include <sys/sysctl.h> | |
37 | 37 | |||
38 | #include <fcntl.h> | 38 | #include <fcntl.h> | |
39 | #include <unistd.h> | 39 | #include <unistd.h> | |
40 | 40 | |||
41 | #include "prog_ops.h" | 41 | #include "prog_ops.h" | |
42 | 42 | |||
43 | const struct prog_ops prog_ops = { | 43 | const struct prog_ops prog_ops = { | |
44 | 44 | |||
45 | .op_socket = socket, | 45 | .op_socket = socket, | |
46 | .op_setsockopt = setsockopt, | 46 | .op_setsockopt = setsockopt, | |
47 | 47 | |||
48 | .op_open = open, | 48 | .op_open = open, | |
49 | .op_getpid = getpid, | 49 | .op_getpid = getpid, | |
50 | 50 | |||
51 | .op_read = read, | 51 | .op_read = read, | |
52 | .op_write = write, | 52 | .op_write = write, | |
53 | 53 | |||
54 | .op_shutdown = shutdown, | |||
55 | ||||
54 | .op_sysctl = sysctl, | 56 | .op_sysctl = sysctl, | |
55 | 57 | |||
56 | .op_shutdown = shutdown, | 58 | .op_sysctlbyname = sysctlbyname, | |
59 | ||||
60 | .op_sysctlgetmibinfo = sysctlgetmibinfo, | |||
61 | ||||
62 | .op_sysctlnametomib = sysctlnametomib, | |||
57 | }; | 63 | }; |
--- src/sbin/route/route_rumpops.c 2020/04/02 18:32:31 1.2
+++ src/sbin/route/route_rumpops.c 2020/04/03 16:20:52 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: route_rumpops.c,v 1.2 2020/04/02 18:32:31 christos Exp $ */ | 1 | /* $NetBSD: route_rumpops.c,v 1.3 2020/04/03 16:20:52 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,43 +18,53 @@ | @@ -18,43 +18,53 @@ | |||
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #ifndef lint | 30 | #ifndef lint | |
31 | __RCSID("$NetBSD: route_rumpops.c,v 1.2 2020/04/02 18:32:31 christos Exp $"); | 31 | __RCSID("$NetBSD: route_rumpops.c,v 1.3 2020/04/03 16:20:52 martin Exp $"); | |
32 | #endif /* !lint */ | 32 | #endif /* !lint */ | |
33 | 33 | |||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> | |
35 | #include <sys/socket.h> | 35 | #include <sys/socket.h> | |
36 | 36 | |||
37 | #include <unistd.h> | 37 | #include <unistd.h> | |
38 | 38 | |||
39 | #include <rump/rump.h> | 39 | #include <rump/rump.h> | |
40 | #include <rump/rump_syscalls.h> | 40 | #include <rump/rump_syscalls.h> | |
41 | #include <rump/rumpclient.h> | 41 | #include <rump/rumpclient.h> | |
42 | 42 | |||
43 | #include "prog_ops.h" | 43 | #include "prog_ops.h" | |
44 | 44 | |||
45 | const struct prog_ops prog_ops = { | 45 | const struct prog_ops prog_ops = { | |
46 | .op_init = rumpclient_init, | 46 | .op_init = rumpclient_init, | |
47 | 47 | |||
48 | .op_socket = rump_sys_socket, | 48 | .op_socket = rump_sys_socket, | |
49 | .op_setsockopt = rump_sys_setsockopt, | 49 | .op_setsockopt = rump_sys_setsockopt, | |
50 | 50 | |||
51 | .op_open = rump_sys_open, | 51 | .op_open = rump_sys_open, | |
52 | .op_getpid = rump_sys_getpid, | 52 | .op_getpid = rump_sys_getpid, | |
53 | 53 | |||
54 | .op_read = rump_sys_read, | 54 | .op_read = rump_sys_read, | |
55 | .op_write = rump_sys_write, | 55 | .op_write = rump_sys_write, | |
56 | 56 | |||
57 | .op_shutdown = rump_sys_shutdown, | |||
58 | ||||
57 | .op_sysctl = rump_sys___sysctl, | 59 | .op_sysctl = rump_sys___sysctl, | |
58 | 60 | |||
59 | .op_shutdown = rump_sys_shutdown, | 61 | /* | |
62 | * The following are only indirected through ops because | |||
63 | * santizers get confused otherwise. | |||
64 | */ | |||
65 | .op_sysctlbyname = sysctlbyname, | |||
66 | ||||
67 | .op_sysctlgetmibinfo = sysctlgetmibinfo, | |||
68 | ||||
69 | .op_sysctlnametomib = sysctlnametomib, | |||
60 | }; | 70 | }; |
--- src/usr.bin/netstat/netstat_hostops.c 2019/08/18 04:14:40 1.2
+++ src/usr.bin/netstat/netstat_hostops.c 2020/04/03 16:20:51 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: netstat_hostops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $ */ | 1 | /* $NetBSD: netstat_hostops.c,v 1.3 2020/04/03 16:20:51 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -18,30 +18,17 @@ | @@ -18,30 +18,17 @@ | |||
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | #ifndef lint | 30 | #ifndef lint | |
31 | __RCSID("$NetBSD: netstat_hostops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $"); | 31 | __RCSID("$NetBSD: netstat_hostops.c,v 1.3 2020/04/03 16:20:51 martin Exp $"); | |
32 | #endif /* !lint */ | 32 | #endif /* !lint */ | |
33 | 33 | |||
34 | #include <sys/types.h> | 34 | #include "../../sbin/route/route_hostops.c" | |
35 | #include <sys/sysctl.h> | |||
36 | ||||
37 | #include "prog_ops.h" | |||
38 | ||||
39 | const struct prog_ops prog_ops = { | |||
40 | .op_sysctl = sysctl, | |||
41 | ||||
42 | .op_sysctlbyname = sysctlbyname, | |||
43 | ||||
44 | .op_sysctlgetmibinfo = sysctlgetmibinfo, | |||
45 | ||||
46 | .op_sysctlnametomib = sysctlnametomib, | |||
47 | }; |
--- src/usr.bin/netstat/netstat_rumpops.c 2019/08/18 04:14:40 1.2
+++ src/usr.bin/netstat/netstat_rumpops.c 2020/04/03 16:20:51 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: netstat_rumpops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $ */ | 1 | /* $NetBSD: netstat_rumpops.c,v 1.3 2020/04/03 16:20:51 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -16,38 +16,14 @@ | @@ -16,38 +16,14 @@ | |||
16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include "../../sbin/route/route_rumpops.c" | |
30 | #ifndef lint | |||
31 | __RCSID("$NetBSD: netstat_rumpops.c,v 1.2 2019/08/18 04:14:40 kamil Exp $"); | |||
32 | #endif /* !lint */ | |||
33 | ||||
34 | #include <sys/types.h> | |||
35 | #include <sys/sysctl.h> | |||
36 | ||||
37 | #include <rump/rump.h> | |||
38 | #include <rump/rumpclient.h> | |||
39 | #include <rump/rump_syscalls.h> | |||
40 | ||||
41 | #include "prog_ops.h" | |||
42 | ||||
43 | const struct prog_ops prog_ops = { | |||
44 | .op_init = rumpclient_init, | |||
45 | ||||
46 | .op_sysctl = rump_sys___sysctl, | |||
47 | ||||
48 | .op_sysctlbyname = sysctlbyname, | |||
49 | ||||
50 | .op_sysctlgetmibinfo = sysctlgetmibinfo, | |||
51 | ||||
52 | .op_sysctlnametomib = sysctlnametomib, | |||
53 | }; |
--- src/usr.bin/netstat/Attic/prog_ops.h 2019/08/18 04:14:40 1.3
+++ src/usr.bin/netstat/Attic/prog_ops.h 2020/04/03 16:20:51 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: prog_ops.h,v 1.3 2019/08/18 04:14:40 kamil Exp $ */ | 1 | /* $NetBSD: prog_ops.h,v 1.4 2020/04/03 16:20:51 martin Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -16,53 +16,15 @@ | @@ -16,53 +16,15 @@ | |||
16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #ifndef _PROG_OPS_H_ | |||
30 | #define _PROG_OPS_H_ | |||
31 | 29 | |||
32 | #include <sys/types.h> | 30 | #include "../../sbin/route/prog_ops.h" | |
33 | ||||
34 | #ifndef CRUNCHOPS | |||
35 | struct sysctlnode; | |||
36 | ||||
37 | struct prog_ops { | |||
38 | int (*op_init)(void); | |||
39 | ||||
40 | int (*op_sysctl)(const int *, u_int, void *, size_t *, | |||
41 | const void *, size_t); | |||
42 | ||||
43 | /* Indirection needed for sanitizers. */ | |||
44 | ||||
45 | int (*op_sysctlbyname)(const char *, void *, size_t *, | |||
46 | const void *, size_t); | |||
47 | ||||
48 | int (*op_sysctlgetmibinfo)(const char *, int *, u_int *, | |||
49 | char *, size_t *, struct sysctlnode **, int); | |||
50 | ||||
51 | int (*op_sysctlnametomib)(const char *, int *, size_t *); | |||
52 | }; | |||
53 | extern const struct prog_ops prog_ops; | |||
54 | ||||
55 | #define prog_init prog_ops.op_init | |||
56 | #define prog_sysctl prog_ops.op_sysctl | |||
57 | #define prog_sysctlbyname prog_ops.op_sysctlbyname | |||
58 | #define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo | |||
59 | #define prog_sysctlnametomib prog_ops.op_sysctlnametomib | |||
60 | #else | |||
61 | #define prog_init ((int (*)(void))NULL) | |||
62 | #define prog_sysctl sysctl | |||
63 | #define prog_sysctlbyname sysctlbyname | |||
64 | #define prog_sysctlgetmibinfo sysctlgetmibinfo | |||
65 | #define prog_sysctlnametomib sysctlnametomib | |||
66 | #endif | |||
67 | ||||
68 | #endif /* _PROG_OPS_H_ */ |