|
OpenVPN
|
#include <stdlib.h>#include <stdarg.h>#include <setjmp.h>#include <cmocka.h>#include "push.h"#include "options_util.h"#include "multi.h"#include "push_util.c"
Go to the source code of this file.
Macros | |
| #define | PUSH_BUNDLE_SIZE_TEST 184 |
| #define | expect_control_channel_strings(res) |
Functions | |
| void | throw_signal_soft (const int signum, const char *signal_text) |
| Throw a soft global signal. | |
| unsigned int | pull_permission_mask (const struct context *c) |
| void | unlearn_ifconfig (struct multi_context *m, struct multi_instance *mi) |
| void | unlearn_ifconfig_ipv6 (struct multi_context *m, struct multi_instance *mi) |
| void | update_vhash (struct multi_context *m, struct multi_instance *mi, const char *new_ip, const char *new_ipv6) |
| Update the vhash with new IP/IPv6 addresses in the multi_context when a push-update message containing ifconfig/ifconfig-ipv6 options is sent from the server. | |
| bool | options_postprocess_pull (struct options *options, struct env_set *es) |
| static void | reset_route_counters (void) |
| bool | apply_push_options (struct context *c, struct options *options, struct buffer *buf, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es, bool is_update) |
| int | process_incoming_push_msg (struct context *c, const struct buffer *buffer, bool honor_received_options, unsigned int permission_mask, unsigned int *option_types_found) |
| const char * | tls_common_name (const struct tls_multi *multi, const bool null) |
| Returns the common name field for the given tunnel. | |
| bool | send_control_channel_string (struct context *c, const char *str, msglvl_t msglevel) |
| struct multi_instance * | lookup_by_cid (struct multi_context *m, const unsigned long cid) |
| bool | mroute_extract_openvpn_sockaddr (struct mroute_addr *addr, const struct openvpn_sockaddr *osaddr, bool use_port) |
| unsigned int | extract_iv_proto (const char *peer_info) |
| Extracts the IV_PROTO variable and returns its value or 0 if it cannot be extracted. | |
| static void | test_incoming_push_message_basic (void **state) |
| static void | test_incoming_push_message_error1 (void **state) |
| static void | test_incoming_push_message_error2 (void **state) |
| static void | test_incoming_push_message_1 (void **state) |
| static void | test_incoming_push_message_bad_format (void **state) |
| static void | test_incoming_push_message_not_updatable_option (void **state) |
| static void | test_incoming_push_message_mix (void **state) |
| static void | test_incoming_push_message_mix2 (void **state) |
| static void | test_incoming_push_continuation_route_accumulation (void **state) |
| Test that routes accumulate correctly across multiple continuation messages. | |
| static void | test_send_push_msg0 (void **state) |
| static void | test_send_push_msg1 (void **state) |
| static void | test_send_push_msg2 (void **state) |
| static void | test_send_push_msg3 (void **state) |
| static void | test_send_push_msg4 (void **state) |
| static void | test_send_push_msg5 (void **state) |
| static void | test_send_push_msg6 (void **state) |
| static void | test_send_push_msg7 (void **state) |
| static void | test_send_push_msg8 (void **state) |
| static void | test_send_push_msg9 (void **state) |
| static void | test_send_push_msg10 (void **state) |
| static void | test_send_push_msg11 (void **state) |
| static void | test_send_push_msg12 (void **state) |
| static void | test_send_push_msg13 (void **state) |
| static void | test_send_push_msg14 (void **state) |
| static int | setup2 (void **state) |
| static int | teardown2 (void **state) |
| static int | setup (void **state) |
| static int | teardown (void **state) |
| int | main (void) |
Variables | |
| static int | route_reset_count = 0 |
| static int | route_add_count = 0 |
| char * | r0 [] |
| char * | r1 [] |
| char * | r3 [] |
| char * | r4 [] |
| char * | r5 [] |
| char * | r6 [] |
| char * | r7 [] |
| char * | r8 [] |
| char * | r9 [] |
| char * | r11 [] |
| char * | r12 [] |
| char * | r13 [] |
| char * | r14 [] |
| const char * | msg0 = "redirect-gateway local,route 192.168.1.0 255.255.255.0" |
| const char * | msg1 |
| const char * | msg2 = "" |
| const char * | msg3 = ",," |
| const char * | msg4 |
| const char * | msg5 |
| const char * | msg6 |
| const char * | msg7 = ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,," |
| const char * | msg8 |
| const char * | msg9 = "," |
| const char * | msg10 |
| const char * | msg11 |
| const char * | msg12 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a,abc" |
| const char * | msg13 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a," |
| const char * | msg14 = "a,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,a" |
| #define expect_control_channel_strings | ( | res | ) |
Definition at line 502 of file test_push_update_msg.c.
| #define PUSH_BUNDLE_SIZE_TEST 184 |
Definition at line 500 of file test_push_update_msg.c.
| bool apply_push_options | ( | struct context * | c, |
| struct options * | options, | ||
| struct buffer * | buf, | ||
| unsigned int | permission_mask, | ||
| unsigned int * | option_types_found, | ||
| struct env_set * | es, | ||
| bool | is_update | ||
| ) |
Definition at line 72 of file test_push_update_msg.c.
References add_option(), apply_pull_filter(), buf_parse(), check_push_update_option_flags(), CLEAR, D_PUSH_ERRORS, es, options::gc, buffer::len, M_OPTERR, MAX_PARMS, OPT_P_U_ROUTE, OPTION_PARM_SIZE, parse_line(), options::pull_filter_list, options::push_continuation, PUSH_OPT_OPTIONAL, PUSH_OPT_TO_REMOVE, options::push_update_options_found, remove_option(), route_add_count, route_reset_count, SIZE, and update_option().
Referenced by process_incoming_push_reply(), and process_push_update().
| unsigned int extract_iv_proto | ( | const char * | peer_info | ) |
Extracts the IV_PROTO variable and returns its value or 0 if it cannot be extracted.
| peer_info | peer info string to search for IV_PROTO |
Definition at line 193 of file test_push_update_msg.c.
References IV_PROTO_PUSH_UPDATE.
| struct multi_instance * lookup_by_cid | ( | struct multi_context * | m, |
| const unsigned long | cid | ||
| ) |
Definition at line 179 of file test_push_update_msg.c.
References multi_context::instances.
| int main | ( | void | ) |
Definition at line 690 of file test_push_update_msg.c.
References setup(), setup2(), teardown(), teardown2(), test_incoming_push_continuation_route_accumulation(), test_incoming_push_message_1(), test_incoming_push_message_bad_format(), test_incoming_push_message_basic(), test_incoming_push_message_error1(), test_incoming_push_message_error2(), test_incoming_push_message_mix(), test_incoming_push_message_mix2(), test_incoming_push_message_not_updatable_option(), test_send_push_msg0(), test_send_push_msg1(), test_send_push_msg10(), test_send_push_msg11(), test_send_push_msg12(), test_send_push_msg13(), test_send_push_msg14(), test_send_push_msg2(), test_send_push_msg3(), test_send_push_msg4(), test_send_push_msg5(), test_send_push_msg6(), test_send_push_msg7(), test_send_push_msg8(), and test_send_push_msg9().
| bool mroute_extract_openvpn_sockaddr | ( | struct mroute_addr * | addr, |
| const struct openvpn_sockaddr * | osaddr, | ||
| bool | use_port | ||
| ) |
Definition at line 185 of file test_push_update_msg.c.
Definition at line 52 of file test_push_update_msg.c.
| int process_incoming_push_msg | ( | struct context * | c, |
| const struct buffer * | buffer, | ||
| bool | honor_received_options, | ||
| unsigned int | permission_mask, | ||
| unsigned int * | option_types_found | ||
| ) |
Definition at line 133 of file test_push_update_msg.c.
References buf_string_compare_advance(), buffer::len, process_push_update(), PUSH_MSG_ERROR, PUSH_MSG_REPLY, PUSH_MSG_REQUEST, push_reply_cmd, and push_update_cmd.
Referenced by test_incoming_push_continuation_route_accumulation(), test_incoming_push_message_1(), test_incoming_push_message_bad_format(), test_incoming_push_message_basic(), test_incoming_push_message_error1(), test_incoming_push_message_error2(), test_incoming_push_message_mix(), test_incoming_push_message_mix2(), and test_incoming_push_message_not_updatable_option().
| unsigned int pull_permission_mask | ( | const struct context * | c | ) |
Definition at line 24 of file test_push_update_msg.c.
References OPT_P_COMP, OPT_P_DHCPDNS, OPT_P_ECHO, OPT_P_EXPLICIT_NOTIFY, OPT_P_MESSAGES, OPT_P_NCP, OPT_P_PEER_ID, OPT_P_PERSIST, OPT_P_PULL_MODE, OPT_P_PUSH_MTU, OPT_P_ROUTE, OPT_P_ROUTE_EXTRAS, OPT_P_SETENV, OPT_P_SHAPER, OPT_P_SOCKBUF, OPT_P_SOCKFLAGS, OPT_P_TIMER, and OPT_P_UP.
Referenced by test_incoming_push_continuation_route_accumulation(), test_incoming_push_message_1(), test_incoming_push_message_bad_format(), test_incoming_push_message_basic(), test_incoming_push_message_error1(), test_incoming_push_message_error2(), test_incoming_push_message_mix(), test_incoming_push_message_mix2(), and test_incoming_push_message_not_updatable_option().
|
static |
Definition at line 65 of file test_push_update_msg.c.
References route_add_count, and route_reset_count.
Referenced by test_incoming_push_continuation_route_accumulation().
Definition at line 172 of file test_push_update_msg.c.
References buffer::len.
|
static |
Definition at line 672 of file test_push_update_msg.c.
References context::options, options::pull, and options::route_nopull.
Referenced by main().
|
static |
Definition at line 647 of file test_push_update_msg.c.
References context::c2, multi_instance::context, options::disable_dco, multi_context::instances, context::options, context_2::tls_multi, and multi_context::top.
Referenced by main().
|
static |
Definition at line 682 of file test_push_update_msg.c.
Referenced by main().
|
static |
Definition at line 660 of file test_push_update_msg.c.
References multi_context::instances.
Referenced by main().
|
static |
Test that routes accumulate correctly across multiple continuation messages.
This test exposes a bug where update_options_found is reset to 0 for each continuation message, causing routes to be reset on each message instead of accumulating.
Expected behavior: routes should only be reset ONCE (when the first route is received), then all subsequent routes should accumulate.
Current bug: routes are reset on the first route of EACH continuation message.
Definition at line 344 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, msg1, msg2, msg3, process_incoming_push_msg(), pull_permission_mask(), PUSH_MSG_CONTINUATION, PUSH_MSG_UPDATE, reset_route_counters(), route_add_count, and route_reset_count.
Referenced by main().
|
static |
Definition at line 251 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 267 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 202 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 219 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 235 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 299 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 316 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_UPDATE.
Referenced by main().
|
static |
Definition at line 283 of file test_push_update_msg.c.
References alloc_buf(), buf_write(), free_buf(), buffer::len, process_incoming_push_msg(), pull_permission_mask(), and PUSH_MSG_ERROR.
Referenced by main().
|
static |
Definition at line 512 of file test_push_update_msg.c.
References expect_control_channel_strings, msg0, PUSH_BUNDLE_SIZE_TEST, r0, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 521 of file test_push_update_msg.c.
References expect_control_channel_strings, msg1, PUSH_BUNDLE_SIZE_TEST, r1, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 601 of file test_push_update_msg.c.
References msg10, PUSH_BUNDLE_SIZE_TEST, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 609 of file test_push_update_msg.c.
References expect_control_channel_strings, msg11, PUSH_BUNDLE_SIZE_TEST, r11, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 618 of file test_push_update_msg.c.
References expect_control_channel_strings, msg12, PUSH_BUNDLE_SIZE_TEST, r12, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 627 of file test_push_update_msg.c.
References expect_control_channel_strings, msg13, PUSH_BUNDLE_SIZE_TEST, r13, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 636 of file test_push_update_msg.c.
References expect_control_channel_strings, msg14, PUSH_BUNDLE_SIZE_TEST, r14, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 530 of file test_push_update_msg.c.
References msg2, PUSH_BUNDLE_SIZE_TEST, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 538 of file test_push_update_msg.c.
References expect_control_channel_strings, msg3, PUSH_BUNDLE_SIZE_TEST, r3, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 547 of file test_push_update_msg.c.
References expect_control_channel_strings, msg4, PUSH_BUNDLE_SIZE_TEST, r4, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 556 of file test_push_update_msg.c.
References expect_control_channel_strings, msg5, PUSH_BUNDLE_SIZE_TEST, r5, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 565 of file test_push_update_msg.c.
References expect_control_channel_strings, msg6, PUSH_BUNDLE_SIZE_TEST, r6, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 574 of file test_push_update_msg.c.
References expect_control_channel_strings, msg7, PUSH_BUNDLE_SIZE_TEST, r7, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 583 of file test_push_update_msg.c.
References expect_control_channel_strings, msg8, PUSH_BUNDLE_SIZE_TEST, r8, send_push_update(), and UPT_BY_CID.
Referenced by main().
|
static |
Definition at line 592 of file test_push_update_msg.c.
References expect_control_channel_strings, msg9, PUSH_BUNDLE_SIZE_TEST, r9, send_push_update(), and UPT_BY_CID.
Referenced by main().
| void throw_signal_soft | ( | const int | signum, |
| const char * | signal_text | ||
| ) |
Throw a soft global signal.
Used to register internally generated signals due to errors that require a restart or exit, or restart requests received from the server. A textual description of the signal may be provided.
Definition at line 18 of file test_push_update_msg.c.
| const char * tls_common_name | ( | const struct tls_multi * | multi, |
| const bool | null | ||
| ) |
Returns the common name field for the given tunnel.
| multi | The tunnel to return the common name for |
| null | Whether null may be returned. If not, "UNDEF" will be returned. |
Definition at line 158 of file test_push_update_msg.c.
References buffer::len.
| void unlearn_ifconfig | ( | struct multi_context * | m, |
| struct multi_instance * | mi | ||
| ) |
Definition at line 34 of file test_push_update_msg.c.
| void unlearn_ifconfig_ipv6 | ( | struct multi_context * | m, |
| struct multi_instance * | mi | ||
| ) |
Definition at line 40 of file test_push_update_msg.c.
| void update_vhash | ( | struct multi_context * | m, |
| struct multi_instance * | mi, | ||
| const char * | new_ip, | ||
| const char * | new_ipv6 | ||
| ) |
Update the vhash with new IP/IPv6 addresses in the multi_context when a push-update message containing ifconfig/ifconfig-ipv6 options is sent from the server.
| m | The multi_context |
| mi | The multi_instance of the client we are updating |
| new_ip | The new IPv4 address or NULL if no change |
| new_ipv6 | The new IPv6 address or NULL if no change |
Definition at line 46 of file test_push_update_msg.c.
| const char* msg0 = "redirect-gateway local,route 192.168.1.0 255.255.255.0" |
Definition at line 463 of file test_push_update_msg.c.
Referenced by test_send_push_msg0().
| const char* msg1 |
Definition at line 464 of file test_push_update_msg.c.
Referenced by test_incoming_push_continuation_route_accumulation(), test_send_push_msg1(), and ValidateOptions().
| const char* msg10 |
Definition at line 479 of file test_push_update_msg.c.
Referenced by test_send_push_msg10().
| const char* msg11 |
Definition at line 488 of file test_push_update_msg.c.
Referenced by test_send_push_msg11().
| const char* msg12 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a,abc" |
Definition at line 494 of file test_push_update_msg.c.
Referenced by test_send_push_msg12().
| const char* msg13 = "a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,,,,,,a," |
Definition at line 496 of file test_push_update_msg.c.
Referenced by test_send_push_msg13().
| const char* msg14 = "a,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,a" |
Definition at line 498 of file test_push_update_msg.c.
Referenced by test_send_push_msg14().
| const char* msg2 = "" |
Definition at line 466 of file test_push_update_msg.c.
Referenced by test_incoming_push_continuation_route_accumulation(), test_send_push_msg2(), and ValidateOptions().
| const char* msg3 = ",," |
Definition at line 467 of file test_push_update_msg.c.
Referenced by test_incoming_push_continuation_route_accumulation(), and test_send_push_msg3().
| const char* msg4 |
Definition at line 468 of file test_push_update_msg.c.
Referenced by test_send_push_msg4().
| const char* msg5 |
Definition at line 470 of file test_push_update_msg.c.
Referenced by test_send_push_msg5().
| const char* msg6 |
Definition at line 472 of file test_push_update_msg.c.
Referenced by test_send_push_msg6().
| const char* msg7 = ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,," |
Definition at line 474 of file test_push_update_msg.c.
Referenced by test_send_push_msg7().
| const char* msg8 |
Definition at line 475 of file test_push_update_msg.c.
Referenced by test_send_push_msg8().
| const char* msg9 = "," |
Definition at line 477 of file test_push_update_msg.c.
Referenced by test_send_push_msg9().
| char* r0[] |
Definition at line 392 of file test_push_update_msg.c.
Referenced by test_send_push_msg0().
| char* r1[] |
Definition at line 396 of file test_push_update_msg.c.
Referenced by add_block_local_item(), and test_send_push_msg1().
| char* r11[] |
Definition at line 439 of file test_push_update_msg.c.
Referenced by test_send_push_msg11().
| char* r12[] |
Definition at line 447 of file test_push_update_msg.c.
Referenced by test_send_push_msg12().
| char* r13[] |
Definition at line 452 of file test_push_update_msg.c.
Referenced by test_send_push_msg13().
| char* r14[] |
Definition at line 456 of file test_push_update_msg.c.
Referenced by test_send_push_msg14().
| char* r3[] |
Definition at line 402 of file test_push_update_msg.c.
Referenced by test_send_push_msg3().
| char* r4[] |
Definition at line 406 of file test_push_update_msg.c.
Referenced by test_send_push_msg4().
| char* r5[] |
Definition at line 412 of file test_push_update_msg.c.
Referenced by test_send_push_msg5().
| char* r6[] |
Definition at line 418 of file test_push_update_msg.c.
Referenced by add_route_connected_v6_net(), add_route_ipv6(), delete_route_connected_v6_net(), delete_route_ipv6(), delete_routes_v6(), init_route_ipv6(), init_route_ipv6_list(), route_ipv6_clear_host_bits(), setenv_route_ipv6(), setenv_routes_ipv6(), and test_send_push_msg6().
| char* r7[] |
Definition at line 424 of file test_push_update_msg.c.
Referenced by test_send_push_msg7().
| char* r8[] |
Definition at line 429 of file test_push_update_msg.c.
Referenced by test_send_push_msg8().
| char* r9[] |
Definition at line 435 of file test_push_update_msg.c.
Referenced by test_send_push_msg9().
|
static |
Definition at line 62 of file test_push_update_msg.c.
Referenced by apply_push_options(), reset_route_counters(), and test_incoming_push_continuation_route_accumulation().
|
static |
Definition at line 61 of file test_push_update_msg.c.
Referenced by apply_push_options(), reset_route_counters(), and test_incoming_push_continuation_route_accumulation().