39 const char *message = reason;
43 char *endofflags = strstr(m,
"]");
46 if (m[0] ==
'[' && endofflags)
48 message = strstr(reason,
"]") + 1;
52 const char *token =
strtok_r(m,
"[,", &lasts);
55 if (!strncmp(token,
"backoff ", strlen(
"backoff ")))
59 msg(
D_PUSH,
"invalid AUTH_FAIL,TEMP flag: %s", token);
63 else if (!strncmp(token,
"advance ", strlen(
"advance ")))
65 token += strlen(
"advance ");
66 if (!strcmp(token,
"no"))
70 else if (!strcmp(token,
"remote"))
75 else if (!strcmp(token,
"addr"))
85 token =
strtok_r(NULL,
"[,", &lasts);
91 if (!message || message[0] !=
':')
108 long long i = strtoll(str, &endptr, 10);
110 if (i < INT_MIN || (positive && i < 0) || *endptr !=
'\0' || i > INT_MAX)
124 long long i = strtoll(str, &endptr, 10);
126 if (i < 0 || *endptr !=
'\0' || i > INT_MAX)
128 msg(msglevel,
"Cannot parse argument '%s' as non-negative integer", str);
139 long long ll = strtoll(str, &endptr, 10);
141 if (ll < 0 || *endptr !=
'\0')
143 msg(msglevel,
"%s: Cannot parse '%s' as non-negative integer", name, str);
147 *value = (int64_t)ll;
155 long long i = strtoll(str, &endptr, 10);
157 if (i < INT_MIN || *endptr !=
'\0' || i > INT_MAX)
159 msg(msglevel,
"Cannot parse argument '%s' as integer", str);
172 long long i = strtoll(str, &endptr, 10);
173 if (i < INT_MIN || *endptr !=
'\0' || i > INT_MAX)
175 msg(msglevel,
"%s: Cannot parse '%s' as integer", name, str);
178 if (i < min || i > max)
182 msg(msglevel,
"%s: Must be an integer >= %d, not %lld",
187 msg(msglevel,
"%s: Must be an integer between %d and %d, not %lld",
198 "dhcp-option",
"dns",
199 "ifconfig",
"ifconfig-ipv6",
200 "push-continuation",
"redirect-gateway",
201 "redirect-private",
"route",
202 "route-gateway",
"route-ipv6",
203 "route-metric",
"topology",
204 "tun-mtu",
"keepalive" };
210 bool opt_is_updatable =
false;
227 if (!(line)[*i + 1] || (line)[*i + 1] ==
'-')
235 size_t len = strlen(&line[*i]);
237 for (
int j = 0; j < count; ++j)
245 && (!line[*i + opt_len] || line[*i + opt_len] ==
' '))
247 opt_is_updatable =
true;
252 if (!opt_is_updatable)
256 msg(
D_PUSH,
"Pushed dispensable option is not updatable: '%s'. Ignoring.", line);
260 msg(
M_WARN,
"Pushed option is not updatable: '%s'.", line);
282 msg(
D_LOW,
"Pushed option accepted by filter: '%s'", line);
287 msg(
D_PUSH,
"Pushed option removed by filter: '%s'", line);
293 msg(
M_WARN,
"Pushed option rejected by filter: '%s'.", line);
char * string_alloc(const char *str, struct gc_arena *gc)
static void gc_free(struct gc_arena *a)
static struct gc_arena gc_new(void)
char * strtok_r(char *s, const char *delim, char **last)
#define PUF_TYPE_ACCEPT
filter type to accept a matching option
#define PUF_TYPE_IGNORE
filter type to ignore a matching option
#define PUF_TYPE_REJECT
filter type to reject and trigger SIGUSR1
static const char * updatable_options[]
int atoi_warn(const char *str, msglvl_t msglevel)
Converts a str to an integer if the string can be represented as an integer number.
int positive_atoi(const char *str, msglvl_t msglevel)
Converts a str to a positive number if the string represents a postive integer number.
bool check_push_update_option_flags(char *line, int *i, uint64_t *flags)
Checks the formatting and validity of options inside push-update messages.
bool positive_atoll(const char *str, int64_t *value, const char *name, msglvl_t msglevel)
Converts a str to an integer if the string can be represented as an integer number and is >= 0.
bool apply_pull_filter(const struct options *o, char *line)
Filter an option line by all pull filters.
const char * parse_auth_failed_temp(struct options *o, const char *reason)
bool valid_integer(const char *str, bool positive)
Checks if the string is a valid integer by checking if it can be converted to an integer.
bool atoi_constrained(const char *str, int *value, const char *name, int min, int max, msglvl_t msglevel)
Converts a str to an integer if the string can be represented as an integer number and is between min...
#define PUSH_OPT_TO_REMOVE
#define PUSH_OPT_OPTIONAL
Garbage collection arena used to keep track of dynamically allocated memory.
struct pull_filter_list * pull_filter_list
struct pull_filter * head
struct pull_filter * next