OpenVPN
|
#include "forward.h"
Go to the source code of this file.
Macros | |
#define | PUSH_MSG_ERROR 0 |
#define | PUSH_MSG_REQUEST 1 |
#define | PUSH_MSG_REPLY 2 |
#define | PUSH_MSG_REQUEST_DEFERRED 3 |
#define | PUSH_MSG_AUTH_FAILURE 4 |
#define | PUSH_MSG_CONTINUATION 5 |
#define | PUSH_MSG_ALREADY_REPLIED 6 |
#define | PUSH_MSG_UPDATE 7 |
#define | push_reply_cmd "PUSH_REPLY" |
#define | push_update_cmd "PUSH_UPDATE" |
#define | PUSH_OPT_TO_REMOVE (1 << 0) |
#define | PUSH_OPT_OPTIONAL (1 << 1) |
Enumerations | |
enum | push_update_type { UPT_BROADCAST = 0 , UPT_BY_CID = 1 } |
Functions | |
int | process_incoming_push_request (struct context *c) |
int | process_incoming_push_update (struct context *c, unsigned int permission_mask, unsigned int *option_types_found, struct buffer *buf, bool msg_sender) |
Handles the receiving of a push-update message and applies updates to the specified options. | |
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) |
bool | send_push_request (struct context *c) |
void | receive_auth_failed (struct context *c, const struct buffer *buffer) |
void | server_pushed_signal (struct context *c, const struct buffer *buffer, const bool restart, const int adv) |
void | receive_exit_message (struct context *c) |
void | server_pushed_info (const struct buffer *buffer, const int adv) |
void | receive_cr_response (struct context *c, const struct buffer *buffer) |
void | incoming_push_message (struct context *c, const struct buffer *buffer) |
void | clone_push_list (struct options *o) |
void | push_option (struct options *o, const char *opt, int msglevel) |
void | push_options (struct options *o, char **p, int msglevel, struct gc_arena *gc) |
void | push_reset (struct options *o) |
void | push_remove_option (struct options *o, const char *p) |
void | remove_iroutes_from_push_route_list (struct options *o) |
void | send_auth_failed (struct context *c, const char *client_reason) |
bool | send_auth_pending_messages (struct tls_multi *tls_multi, struct tls_session *session, const char *extra, unsigned int timeout) |
Sends the auth pending control messages to a client. | |
void | send_restart (struct context *c, const char *kill_msg) |
void | send_push_reply_auth_token (struct tls_multi *multi) |
Sends a push reply message only containin the auth-token to update the auth-token on the client. | |
void | receive_auth_pending (struct context *c, const struct buffer *buffer) |
Parses an AUTH_PENDING message and if in pull mode extends the timeout. | |
int | send_push_update (struct multi_context *m, const void *target, const char *msg, const push_update_type type, const int push_bundle_size) |
A function to send a PUSH_UPDATE control message from server to client(s). | |
bool | management_callback_send_push_update_broadcast (void *arg, const char *options) |
bool | management_callback_send_push_update_by_cid (void *arg, unsigned long cid, const char *options) |
enum push_update_type |
void clone_push_list | ( | struct options * | o | ) |
Definition at line 890 of file push.c.
References options::gc, push_list::head, M_FATAL, push_entry::next, push_entry::option, options::push_list, push_option_ex(), push_reset(), and string_alloc().
Referenced by options_detach().
Definition at line 501 of file push.c.
References BSTR, context::c2, cleanup(), D_PUSH, D_PUSH_ERRORS, do_up(), do_update(), context_2::es, event_timeout_clear(), gc, gc_free(), gc_new(), M_WARN, msg, context::options, options_postprocess_pull(), process_incoming_push_msg(), options::pull, pull_permission_mask(), PUSH_MSG_CONTINUATION, PUSH_MSG_ERROR, PUSH_MSG_REPLY, PUSH_MSG_UPDATE, options::push_option_types_found, context_2::push_request_interval, register_signal(), sanitize_control_message(), context::sig, status, and context_2::wait_for_connect.
Referenced by parse_incoming_control_channel_command().
bool management_callback_send_push_update_broadcast | ( | void * | arg, |
const char * | options | ||
) |
Definition at line 294 of file push_util.c.
References PUSH_BUNDLE_SIZE, RETURN_UPDATE_STATUS, send_push_update(), and UPT_BROADCAST.
Referenced by init_management_callback_multi().
bool management_callback_send_push_update_by_cid | ( | void * | arg, |
unsigned long | cid, | ||
const char * | options | ||
) |
Definition at line 302 of file push_util.c.
References PUSH_BUNDLE_SIZE, RETURN_UPDATE_STATUS, send_push_update(), and UPT_BY_CID.
Referenced by init_management_callback_multi().
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 1090 of file push.c.
References buf_string_compare_advance(), buffer::len, process_incoming_push_reply(), process_incoming_push_request(), process_incoming_push_update(), PUSH_MSG_ERROR, PUSH_MSG_REPLY, PUSH_MSG_REQUEST, push_reply_cmd, and push_update_cmd.
Referenced by incoming_push_message(), 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().
int process_incoming_push_request | ( | struct context * | c | ) |
Definition at line 974 of file push.c.
References context::c2, CAS_CONNECT_DONE, CAS_FAILED, gc, gc_free(), gc_new(), tls_multi::multi_state, now, openvpn_time(), prepare_push_reply(), PUSH_MSG_ALREADY_REPLIED, PUSH_MSG_AUTH_FAILURE, PUSH_MSG_ERROR, PUSH_MSG_REQUEST, PUSH_MSG_REQUEST_DEFERRED, send_auth_failed(), send_push_reply(), context_2::sent_push_reply_expiry, TLS_AUTHENTICATION_FAILED, tls_authentication_status(), TLS_AUTHENTICATION_SUCCEEDED, tls_client_reason(), and context_2::tls_multi.
Referenced by multi_client_connect_late_setup(), and process_incoming_push_msg().
int process_incoming_push_update | ( | struct context * | c, |
unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct buffer * | buf, | ||
bool | msg_sender | ||
) |
Handles the receiving of a push-update message and applies updates to the specified options.
This function processes a push-update message, validating its content and applying updates to the options specified in the message. It also handles split messages if the complete message has not yet been received.
c | The context for the operation. |
permission_mask | The permission mask specifying which options are allowed to be pulled. |
option_types_found | A pointer to a variable that will be filled with the types of options found in the message. |
buf | A buffer containing the received message. |
msg_sender | A boolean indicating if function is called by the message sender (server). |
PUSH_MSG_UPDATE
: The message was processed successfully, and the updates were applied.PUSH_MSG_CONTINUATION
: The message is a fragment of a larger message, and the program is waiting for the final part.PUSH_MSG_ERROR
: An error occurred during message processing, or the message is invalid. Definition at line 13 of file push_util.c.
References apply_push_options(), buf_read_u8(), context::c2, context_2::es, context::options, options::push_continuation, PUSH_MSG_CONTINUATION, PUSH_MSG_ERROR, PUSH_MSG_UPDATE, and throw_signal_soft().
Referenced by process_incoming_push_msg(), and send_single_push_update().
void push_option | ( | struct options * | o, |
const char * | opt, | ||
int | msglevel | ||
) |
Definition at line 884 of file push.c.
References options::gc, options::push_list, and push_option_ex().
Referenced by helper_client_server(), helper_keepalive(), helper_tcp_nodelay(), multi_client_connect_compress_migrate(), and push_options().
Definition at line 905 of file push.c.
References gc, make_extended_arg_array(), print_argv(), and push_option().
Referenced by add_option().
void push_remove_option | ( | struct options * | o, |
const char * | p | ||
) |
Definition at line 937 of file push.c.
References D_PUSH_DEBUG, push_entry::enable, push_list::head, msg, push_entry::next, push_entry::option, options::push_ifconfig_ipv4_blocked, options::push_ifconfig_ipv6_blocked, options::push_list, and streq.
Referenced by add_option().
void push_reset | ( | struct options * | o | ) |
Definition at line 931 of file push.c.
References CLEAR, and options::push_list.
Referenced by add_option(), and clone_push_list().
Definition at line 48 of file push.c.
References AR_INTERACT, AR_NOINTERACT, AR_NONE, ASSERT, auth_retry_get(), BLEN, BSTR, buf_string_compare_advance(), buf_string_match_head_str(), buffer::len, M_VERB0, management_auth_failure(), msg, options::no_advance, context::options, parse_auth_failed_temp(), options::pull, register_signal(), ssl_clean_auth_token(), ssl_purge_auth(), ssl_put_auth_challenge(), and UP_TYPE_AUTH.
Referenced by parse_incoming_control_channel_command().
Parses an AUTH_PENDING message and if in pull mode extends the timeout.
c | The context struct |
buffer | Buffer containing the control message with AUTH_PENDING |
Definition at line 336 of file push.c.
References context::c2, D_PUSH, key_state::established, get_primary_key(), buffer::len, max_uint(), min_uint(), msg, parse_auth_pending_keywords(), context_2::push_request_timeout, and context_2::tls_multi.
Referenced by parse_incoming_control_channel_command().
Definition at line 263 of file push.c.
References BLEN, BSTR, buf_advance(), buf_read_u8(), context::c2, D_PUSH, es, get_primary_key(), buffer::len, management_notify_client_cr_response(), key_state::mda_key_id, msg, tls_multi::session, context_2::tls_multi, TM_ACTIVE, verify_crresponse_plugin(), and verify_crresponse_script().
Referenced by parse_incoming_control_channel_command().
void receive_exit_message | ( | struct context * | c | ) |
Definition at line 189 of file push.c.
References D_STREAM_ERRORS, dmsg, buffer::len, management_notify(), MODE_SERVER, register_signal(), and schedule_exit().
Referenced by parse_incoming_control_channel_command().
void remove_iroutes_from_push_route_list | ( | struct options * | o | ) |
Definition at line 1120 of file push.c.
References CLEAR, D_PUSH, D_ROUTE_DEBUG, push_entry::enable, gc, gc_free(), gc_new(), get_ipv6_addr(), getaddr(), GETADDR_HOST_ORDER, push_list::head, options::iroutes, options::iroutes_ipv6, buffer::len, MAX_PARMS, msg, iroute::netbits, iroute_ipv6::netbits, netbits_to_netmask(), iroute::network, iroute_ipv6::network, push_entry::next, iroute::next, iroute_ipv6::next, push_entry::option, parse_line(), options::push_list, and SIZE.
Referenced by multi_client_connect_late_setup().
void send_auth_failed | ( | struct context * | c, |
const char * | client_reason | ||
) |
Definition at line 393 of file push.c.
References alloc_buf_gc(), BSTR, buf_printf(), D_PUSH, D_TLS_DEBUG, gc, gc_free(), gc_new(), buffer::len, msg, PUSH_BUNDLE_SIZE, reschedule_multi_process(), schedule_exit(), send_control_channel_string_dowork(), TM_ACTIVE, and TM_INITIAL.
Referenced by check_tls(), and process_incoming_push_request().
bool send_auth_pending_messages | ( | struct tls_multi * | tls_multi, |
struct tls_session * | session, | ||
const char * | extra, | ||
unsigned int | timeout | ||
) |
Sends the auth pending control messages to a client.
See doc/management-notes.txt under client-pending-auth for more details on message format
Definition at line 434 of file push.c.
References alloc_buf_gc(), key_state::auth_deferred_expire, BSTR, buf_printf(), D_PUSH, extract_iv_proto(), gc, gc_free(), gc_new(), tls_options::handshake_window, key_state::initial, IV_PROTO_AUTH_PENDING_KW, session::key, KS_PRIMARY, buffer::len, max_uint(), min_uint(), now, tls_multi::opt, tls_multi::peer_info, PUSH_BUNDLE_SIZE, tls_options::renegotiate_seconds, and send_control_channel_string_dowork().
Referenced by key_state_check_auth_pending_file(), and management_client_pending_auth().
void send_push_reply_auth_token | ( | struct tls_multi * | multi | ) |
Sends a push reply message only containin the auth-token to update the auth-token on the client.
Always pushes to the active session
multi | - The tls_multi structure belonging to the instance to push to |
Definition at line 772 of file push.c.
References alloc_buf_gc(), ASSERT, BSTR, buf_printf(), D_PUSH, push_entry::enable, gc, gc_free(), gc_new(), push_list::head, buffer::len, prepare_auth_token_push_reply(), PUSH_BUNDLE_SIZE, push_reply_cmd, send_control_channel_string_dowork(), tls_multi::session, and TM_ACTIVE.
Referenced by resend_auth_token_renegotiation().
bool send_push_request | ( | struct context * | c | ) |
Definition at line 563 of file push.c.
References context::c2, D_PUSH, D_STREAM_ERRORS, key_state::established, get_primary_key(), options::handshake_window, msg, now, context::options, key_state::peer_last_packet, context_2::push_request_timeout, register_signal(), send_control_channel_string(), context::sig, and context_2::tls_multi.
Referenced by check_push_request().
int send_push_update | ( | struct multi_context * | m, |
const void * | target, | ||
const char * | msg, | ||
const push_update_type | type, | ||
const int | push_bundle_size | ||
) |
A function to send a PUSH_UPDATE control message from server to client(s).
m | the multi_context, contains all the clients connected to this server. |
target | the target to which to send the message. It should be: NULL if type == UPT_BROADCAST , a mroute_addr * if type == UPT_BY_ADDR , a char * if type == UPT_BY_CN , an unsigned long * if type == UPT_BY_CID . |
msg | a string containing the options to send. |
type | the way to address the message (broadcast, by cid, by cn, by address). |
push_bundle_size | the maximum size of a bundle of pushed option. Just use PUSH_BUNDLE_SIZE macro. |
Definition at line 187 of file push_util.c.
References context::c2, multi_instance::context, gc, gc_free(), gc_malloc(), gc_new(), multi_instance::halt, hash_iterator_free(), hash_iterator_init(), hash_iterator_next(), options::ifconfig_ipv6_local, options::ifconfig_local, multi_context::iter, buffer::len, lookup_by_cid(), M_CLIENT, message_splitter(), msg, OPT_P_UP, context::options, tls_multi::peer_id, push_update_cmd, send_single_push_update(), context_2::tls_multi, update_vhash(), UPT_BROADCAST, UPT_BY_CID, and hash_element::value.
Referenced by management_callback_send_push_update_broadcast(), management_callback_send_push_update_by_cid(), test_send_push_msg0(), test_send_push_msg1(), test_send_push_msg10(), 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().
void send_restart | ( | struct context * | c, |
const char * | kill_msg | ||
) |
Definition at line 490 of file push.c.
References D_PUSH, buffer::len, schedule_exit(), and send_control_channel_string().
Referenced by management_kill_by_cid().
void server_pushed_info | ( | const struct buffer * | buffer, |
const int | adv | ||
) |
Definition at line 225 of file push.c.
References alloc_buf_gc(), BLEN, BSTR, buf_advance(), buf_printf(), buf_read_u8(), D_PUSH, D_PUSH_ERRORS, gc, gc_free(), gc_new(), buffer::len, management_notify_generic(), and msg.
Referenced by parse_incoming_control_channel_command().
void server_pushed_signal | ( | struct context * | c, |
const struct buffer * | buffer, | ||
const bool | restart, | ||
const int | adv | ||
) |
Definition at line 128 of file push.c.
References BLEN, BSTR, buf_advance(), buf_read_u8(), D_STREAM_ERRORS, i, buffer::len, management_notify(), msg, register_signal(), and ssl_purge_auth().
Referenced by parse_incoming_control_channel_command().