OpenVPN
|
#include "syshead.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <setjmp.h>
#include <cmocka.h>
#include "options.h"
#include "test_common.h"
#include "mock_msg.h"
Go to the source code of this file.
Data Structures | |
union | tokens_parameter |
Macros | |
#define | A_TIMES_256 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAO" |
#define | PARSE_LINE_TST(string) |
#define | LargestIntegralType uintmax_t |
Functions | |
void | add_option (struct options *options, char *p[], bool is_inline, const char *file, int line, const int level, const msglvl_t msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) |
void | remove_option (struct context *c, struct options *options, char *p[], bool is_inline, const char *file, int line, const msglvl_t msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) |
Resets options found in the PUSH_UPDATE message that are preceded by the - flag. | |
void | update_option (struct context *c, struct options *options, char *p[], bool is_inline, const char *file, int line, const int level, const msglvl_t msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es, unsigned int *update_options_found) |
Processes an option to update. | |
void | usage (void) |
static void | test_parse_line (void **state) |
static void | read_single_config (struct options *options, const char *config) |
static int | check_tokens (const LargestIntegralType value, const LargestIntegralType expected) |
static void | test_read_config (void **state) |
int | main (void) |
#define A_TIMES_256 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAO" |
Definition at line 73 of file test_options_parse.c.
#define LargestIntegralType uintmax_t |
Definition at line 209 of file test_options_parse.c.
#define PARSE_LINE_TST | ( | string | ) |
void add_option | ( | struct options * | options, |
char * | p[], | ||
bool | is_inline, | ||
const char * | file, | ||
int | line, | ||
const int | level, | ||
const msglvl_t | msglevel, | ||
const unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct env_set * | es | ||
) |
Definition at line 41 of file test_options_parse.c.
Referenced by test_read_config().
|
static |
Definition at line 219 of file test_options_parse.c.
References tokens_parameter::as_int, tokens_parameter::as_pointer, i, and MAX_PARMS.
Referenced by test_read_config().
int main | ( | void | ) |
Definition at line 308 of file test_options_parse.c.
References test_parse_line(), and test_read_config().
|
static |
Definition at line 192 of file test_options_parse.c.
References CLEAR, es, M_INFO, OPT_P_DEFAULT, and read_config_string().
Referenced by test_read_config().
void remove_option | ( | struct context * | c, |
struct options * | options, | ||
char * | p[], | ||
bool | is_inline, | ||
const char * | file, | ||
int | line, | ||
const msglvl_t | msglevel, | ||
const unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct env_set * | es | ||
) |
Resets options found in the PUSH_UPDATE message that are preceded by the -
flag.
This function is used in push-updates to reset specified options. The number of parameters p
must always be 1. If the permission is verified, all related options are erased or reset to their default values. Upon successful permission verification (by VERIFY_PERMISSION()), option_types_found
is filled with the flag corresponding to the option.
c | The context structure. |
options | A pointer to the options structure. |
p | An array of strings containing the options and their parameters. |
is_inline | A boolean indicating if the option is inline. |
file | The file where the function is called. |
line | The line number where the function is called. |
msglevel | The message level. |
permission_mask | The permission mask used by VERIFY_PERMISSION(). |
option_types_found | A pointer to the variable where the flags corresponding to the options found are stored. |
es | The environment set structure. |
Definition at line 52 of file test_options_parse.c.
|
static |
Definition at line 76 of file test_options_parse.c.
References A_TIMES_256, gc, gc_free(), gc_new(), i, MAX_PARMS, PARSE_LINE_TST, and res.
Referenced by main().
|
static |
Definition at line 249 of file test_options_parse.c.
References A_TIMES_256, add_option(), check_tokens(), CLEAR, options::dns_options, dns_options::gc, options::gc, gc_free(), gc_init(), options::gc_owned, MAX_PARMS, and read_single_config().
Referenced by main().
void update_option | ( | struct context * | c, |
struct options * | options, | ||
char * | p[], | ||
bool | is_inline, | ||
const char * | file, | ||
int | line, | ||
const int | level, | ||
const msglvl_t | msglevel, | ||
const unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct env_set * | es, | ||
unsigned int * | update_options_found | ||
) |
Processes an option to update.
It first checks whether it has already received an option of the same type within the same update message. If the option has already been received, it calls add_option(). Otherwise, it deletes all existing values related to that option before calling add_option().
c | The context structure. |
options | A pointer to the options structure. |
p | An array of strings containing the options and their parameters. |
is_inline | A boolean indicating if the option is inline. |
file | The file where the function is called. |
line | The line number where the function is called. |
level | The level of the option. |
msglevel | The message level for logging. |
permission_mask | The permission mask used by VERIFY_PERMISSION(). |
option_types_found | A pointer to the variable where the flags corresponding to the options found are stored. |
es | The environment set structure. |
update_options_found | A pointer to the variable where the flags corresponding to the update options found are stored, used to check if an option of the same type has already been processed by update_option() within the same push-update message. |
Definition at line 60 of file test_options_parse.c.
void usage | ( | void | ) |
Definition at line 68 of file test_options_parse.c.