Function prototypes should be included when compiling their
definitions so that it is clear to compilers and static
analyzers that they are not static.
This means that several declarations have to be moved to the
related header files which in turn have to be included by the
source files implementing them.
Generally speaking this also improves the coding style and
makes this code more consistent with the rest that already
follows this rule.
Cc: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171111161836.23356-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15820.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
... | ... |
@@ -462,6 +462,9 @@ void prng_bytes(uint8_t *output, int len); |
462 | 462 |
|
463 | 463 |
void prng_uninit(void); |
464 | 464 |
|
465 |
+/* an analogue to the random() function, but use prng_bytes */ |
|
466 |
+long int get_random(void); |
|
467 |
+ |
|
465 | 468 |
void test_crypto(struct crypto_options *co, struct frame *f); |
466 | 469 |
|
467 | 470 |
|
... | ... |
@@ -31,6 +31,7 @@ |
31 | 31 |
|
32 | 32 |
#include "error.h" |
33 | 33 |
#include "buffer.h" |
34 |
+#include "init.h" |
|
34 | 35 |
#include "misc.h" |
35 | 36 |
#include "win32.h" |
36 | 37 |
#include "socket.h" |
... | ... |
@@ -734,13 +735,6 @@ openvpn_exit(const int status) |
734 | 734 |
{ |
735 | 735 |
if (!forked) |
736 | 736 |
{ |
737 |
- void tun_abort(); |
|
738 |
- |
|
739 |
-#ifdef ENABLE_PLUGIN |
|
740 |
- void plugin_abort(void); |
|
741 |
- |
|
742 |
-#endif |
|
743 |
- |
|
744 | 737 |
tun_abort(); |
745 | 738 |
|
746 | 739 |
#ifdef _WIN32 |
... | ... |
@@ -64,6 +64,39 @@ |
64 | 64 |
|
65 | 65 |
#define IOW_READ (IOW_READ_TUN|IOW_READ_LINK) |
66 | 66 |
|
67 |
+extern counter_type link_read_bytes_global; |
|
68 |
+ |
|
69 |
+extern counter_type link_write_bytes_global; |
|
70 |
+ |
|
71 |
+void check_tls_dowork(struct context *c); |
|
72 |
+ |
|
73 |
+void check_tls_errors_co(struct context *c); |
|
74 |
+ |
|
75 |
+void check_tls_errors_nco(struct context *c); |
|
76 |
+ |
|
77 |
+#if P2MP |
|
78 |
+void check_incoming_control_channel_dowork(struct context *c); |
|
79 |
+ |
|
80 |
+void check_scheduled_exit_dowork(struct context *c); |
|
81 |
+ |
|
82 |
+void check_push_request_dowork(struct context *c); |
|
83 |
+#endif /* P2MP */ |
|
84 |
+ |
|
85 |
+#ifdef ENABLE_FRAGMENT |
|
86 |
+void check_fragment_dowork(struct context *c); |
|
87 |
+#endif /* ENABLE_FRAGMENT */ |
|
88 |
+ |
|
89 |
+void check_connection_established_dowork(struct context *c); |
|
90 |
+ |
|
91 |
+void check_add_routes_dowork(struct context *c); |
|
92 |
+ |
|
93 |
+void check_inactivity_timeout_dowork(struct context *c); |
|
94 |
+ |
|
95 |
+void check_server_poll_timeout_dowork(struct context *c); |
|
96 |
+ |
|
97 |
+void check_status_file_dowork(struct context *c); |
|
98 |
+ |
|
99 |
+void io_wait_dowork(struct context *c, const unsigned int flags); |
|
67 | 100 |
|
68 | 101 |
void pre_select(struct context *c); |
69 | 102 |
|
... | ... |
@@ -582,17 +582,17 @@ management_bytes_in(struct management *man, const int size) |
582 | 582 |
|
583 | 583 |
#ifdef MANAGEMENT_DEF_AUTH |
584 | 584 |
|
585 |
+void man_bytecount_output_server(struct management *man, |
|
586 |
+ const counter_type *bytes_in_total, |
|
587 |
+ const counter_type *bytes_out_total, |
|
588 |
+ struct man_def_auth_context *mdac); |
|
589 |
+ |
|
585 | 590 |
static inline void |
586 | 591 |
management_bytes_server(struct management *man, |
587 | 592 |
const counter_type *bytes_in_total, |
588 | 593 |
const counter_type *bytes_out_total, |
589 | 594 |
struct man_def_auth_context *mdac) |
590 | 595 |
{ |
591 |
- void man_bytecount_output_server(struct management *man, |
|
592 |
- const counter_type *bytes_in_total, |
|
593 |
- const counter_type *bytes_out_total, |
|
594 |
- struct man_def_auth_context *mdac); |
|
595 |
- |
|
596 | 596 |
if (man->connection.bytecount_update_seconds > 0 |
597 | 597 |
&& now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds |
598 | 598 |
&& (mdac->flags & (DAF_CONNECTION_ESTABLISHED|DAF_CONNECTION_CLOSED)) == DAF_CONNECTION_ESTABLISHED) |
... | ... |
@@ -96,11 +96,11 @@ mbuf_maximum_queued(const struct mbuf_set *ms) |
96 | 96 |
return (int) ms->max_queued; |
97 | 97 |
} |
98 | 98 |
|
99 |
+struct multi_instance *mbuf_peek_dowork(struct mbuf_set *ms); |
|
100 |
+ |
|
99 | 101 |
static inline struct multi_instance * |
100 | 102 |
mbuf_peek(struct mbuf_set *ms) |
101 | 103 |
{ |
102 |
- struct multi_instance *mbuf_peek_dowork(struct mbuf_set *ms); |
|
103 |
- |
|
104 | 104 |
if (mbuf_defined(ms)) |
105 | 105 |
{ |
106 | 106 |
return mbuf_peek_dowork(ms); |
... | ... |
@@ -52,9 +52,6 @@ const char **make_arg_array(const char *first, const char *parms, struct gc_aren |
52 | 52 |
|
53 | 53 |
const char **make_extended_arg_array(char **p, struct gc_arena *gc); |
54 | 54 |
|
55 |
-/* an analogue to the random() function, but use OpenSSL functions if available */ |
|
56 |
-long int get_random(void); |
|
57 |
- |
|
58 | 55 |
/* prepend a random prefix to hostname */ |
59 | 56 |
const char *hostname_randomize(const char *hostname, struct gc_arena *gc); |
60 | 57 |
|
... | ... |
@@ -170,6 +170,16 @@ void mroute_helper_add_iroute46(struct mroute_helper *mh, int netbits); |
170 | 170 |
|
171 | 171 |
void mroute_helper_del_iroute46(struct mroute_helper *mh, int netbits); |
172 | 172 |
|
173 |
+unsigned int mroute_extract_addr_ip(struct mroute_addr *src, |
|
174 |
+ struct mroute_addr *dest, |
|
175 |
+ const struct buffer *buf); |
|
176 |
+ |
|
177 |
+unsigned int mroute_extract_addr_ether(struct mroute_addr *src, |
|
178 |
+ struct mroute_addr *dest, |
|
179 |
+ struct mroute_addr *esrc, |
|
180 |
+ struct mroute_addr *edest, |
|
181 |
+ const struct buffer *buf); |
|
182 |
+ |
|
173 | 183 |
/* |
174 | 184 |
* Given a raw packet in buf, return the src and dest |
175 | 185 |
* addresses of the packet. |
... | ... |
@@ -182,16 +192,6 @@ mroute_extract_addr_from_packet(struct mroute_addr *src, |
182 | 182 |
const struct buffer *buf, |
183 | 183 |
int tunnel_type) |
184 | 184 |
{ |
185 |
- unsigned int mroute_extract_addr_ip(struct mroute_addr *src, |
|
186 |
- struct mroute_addr *dest, |
|
187 |
- const struct buffer *buf); |
|
188 |
- |
|
189 |
- unsigned int mroute_extract_addr_ether(struct mroute_addr *src, |
|
190 |
- struct mroute_addr *dest, |
|
191 |
- struct mroute_addr *esrc, |
|
192 |
- struct mroute_addr *edest, |
|
193 |
- const struct buffer *buf); |
|
194 |
- |
|
195 | 185 |
unsigned int ret = 0; |
196 | 186 |
verify_align_4(buf); |
197 | 187 |
if (tunnel_type == DEV_TYPE_TUN) |
... | ... |
@@ -536,11 +536,12 @@ clear_prefix(void) |
536 | 536 |
*/ |
537 | 537 |
#define MULTI_CACHE_ROUTE_TTL 60 |
538 | 538 |
|
539 |
+void multi_reap_process_dowork(const struct multi_context *m); |
|
540 |
+void multi_process_per_second_timers_dowork(struct multi_context *m); |
|
541 |
+ |
|
539 | 542 |
static inline void |
540 | 543 |
multi_reap_process(const struct multi_context *m) |
541 | 544 |
{ |
542 |
- void multi_reap_process_dowork(const struct multi_context *m); |
|
543 |
- |
|
544 | 545 |
if (m->reaper->last_call != now) |
545 | 546 |
{ |
546 | 547 |
multi_reap_process_dowork(m); |
... | ... |
@@ -552,8 +553,6 @@ multi_process_per_second_timers(struct multi_context *m) |
552 | 552 |
{ |
553 | 553 |
if (m->per_second_trigger != now) |
554 | 554 |
{ |
555 |
- void multi_process_per_second_timers_dowork(struct multi_context *m); |
|
556 |
- |
|
557 | 555 |
multi_process_per_second_timers_dowork(m); |
558 | 556 |
m->per_second_trigger = now; |
559 | 557 |
} |
... | ... |
@@ -90,6 +90,16 @@ is_occ_msg(const struct buffer *buf) |
90 | 90 |
|
91 | 91 |
void process_received_occ_msg(struct context *c); |
92 | 92 |
|
93 |
+void check_send_occ_req_dowork(struct context *c); |
|
94 |
+ |
|
95 |
+void check_send_occ_load_test_dowork(struct context *c); |
|
96 |
+ |
|
97 |
+void check_send_occ_msg_dowork(struct context *c); |
|
98 |
+ |
|
99 |
+/* |
|
100 |
+ * Inline functions |
|
101 |
+ */ |
|
102 |
+ |
|
93 | 103 |
static inline int |
94 | 104 |
occ_reset_op(void) |
95 | 105 |
{ |
... | ... |
@@ -102,8 +112,6 @@ occ_reset_op(void) |
102 | 102 |
static inline void |
103 | 103 |
check_send_occ_req(struct context *c) |
104 | 104 |
{ |
105 |
- void check_send_occ_req_dowork(struct context *c); |
|
106 |
- |
|
107 | 105 |
if (event_timeout_defined(&c->c2.occ_interval) |
108 | 106 |
&& event_timeout_trigger(&c->c2.occ_interval, |
109 | 107 |
&c->c2.timeval, |
... | ... |
@@ -119,8 +127,6 @@ check_send_occ_req(struct context *c) |
119 | 119 |
static inline void |
120 | 120 |
check_send_occ_load_test(struct context *c) |
121 | 121 |
{ |
122 |
- void check_send_occ_load_test_dowork(struct context *c); |
|
123 |
- |
|
124 | 122 |
if (event_timeout_defined(&c->c2.occ_mtu_load_test_interval) |
125 | 123 |
&& event_timeout_trigger(&c->c2.occ_mtu_load_test_interval, |
126 | 124 |
&c->c2.timeval, |
... | ... |
@@ -136,8 +142,6 @@ check_send_occ_load_test(struct context *c) |
136 | 136 |
static inline void |
137 | 137 |
check_send_occ_msg(struct context *c) |
138 | 138 |
{ |
139 |
- void check_send_occ_msg_dowork(struct context *c); |
|
140 |
- |
|
141 | 139 |
if (c->c2.occ_op >= 0) |
142 | 140 |
{ |
143 | 141 |
if (!TO_LINK_DEF(c)) |
... | ... |
@@ -121,6 +121,10 @@ pf_addr_test(const struct pf_context *src_pf, const struct context *src, |
121 | 121 |
} |
122 | 122 |
} |
123 | 123 |
|
124 |
+/* |
|
125 |
+ * Inline functions |
|
126 |
+ */ |
|
127 |
+ |
|
124 | 128 |
bool pf_cn_test(struct pf_set *pfs, const struct tls_multi *tm, const int type, |
125 | 129 |
const char *prefix); |
126 | 130 |
|
... | ... |
@@ -43,6 +43,10 @@ is_ping_msg(const struct buffer *buf) |
43 | 43 |
return buf_string_match(buf, ping_string, PING_STRING_SIZE); |
44 | 44 |
} |
45 | 45 |
|
46 |
+void check_ping_restart_dowork(struct context *c); |
|
47 |
+ |
|
48 |
+void check_ping_send_dowork(struct context *c); |
|
49 |
+ |
|
46 | 50 |
/* |
47 | 51 |
* Should we exit or restart due to ping (or other authenticated packet) |
48 | 52 |
* not received in n seconds? |
... | ... |
@@ -994,11 +994,11 @@ link_socket_set_outgoing_addr(const struct buffer *buf, |
994 | 994 |
} |
995 | 995 |
} |
996 | 996 |
|
997 |
+bool stream_buf_read_setup_dowork(struct link_socket *sock); |
|
998 |
+ |
|
997 | 999 |
static inline bool |
998 | 1000 |
stream_buf_read_setup(struct link_socket *sock) |
999 | 1001 |
{ |
1000 |
- bool stream_buf_read_setup_dowork(struct link_socket *sock); |
|
1001 |
- |
|
1002 | 1002 |
if (link_socket_connection_oriented(sock)) |
1003 | 1003 |
{ |
1004 | 1004 |
return stream_buf_read_setup_dowork(sock); |
... | ... |
@@ -1103,16 +1103,17 @@ link_socket_write_win32(struct link_socket *sock, |
1103 | 1103 |
|
1104 | 1104 |
#else /* ifdef _WIN32 */ |
1105 | 1105 |
|
1106 |
+size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock, |
|
1107 |
+ struct buffer *buf, |
|
1108 |
+ struct link_socket_actual *to); |
|
1109 |
+ |
|
1110 |
+ |
|
1106 | 1111 |
static inline size_t |
1107 | 1112 |
link_socket_write_udp_posix(struct link_socket *sock, |
1108 | 1113 |
struct buffer *buf, |
1109 | 1114 |
struct link_socket_actual *to) |
1110 | 1115 |
{ |
1111 | 1116 |
#if ENABLE_IP_PKTINFO |
1112 |
- size_t link_socket_write_udp_posix_sendmsg(struct link_socket *sock, |
|
1113 |
- struct buffer *buf, |
|
1114 |
- struct link_socket_actual *to); |
|
1115 |
- |
|
1116 | 1117 |
if (proto_is_udp(sock->info.proto) && (sock->sockflags & SF_USE_IP_PKTINFO) |
1117 | 1118 |
&& addr_defined_ipi(to)) |
1118 | 1119 |
{ |