39 const char *message = reason;
43 char *endofflags = strstr(m,
"]");
46 if (m[0] ==
'[' && endofflags)
48 message = strstr(reason,
"]") + 1;
51 const char *token = strtok(m,
"[,");
54 if (!strncmp(token,
"backoff ", strlen(
"backoff ")))
58 msg(
D_PUSH,
"invalid AUTH_FAIL,TEMP flag: %s", token);
62 else if (!strncmp(token,
"advance ", strlen(
"advance ")))
64 token += strlen(
"advance ");
65 if (!strcmp(token,
"no"))
69 else if (!strcmp(token,
"remote"))
74 else if (!strcmp(token,
"addr"))
84 token = strtok(NULL,
"[,");
90 if (!message || message[0] !=
':')
107 long long i = strtoll(str, &endptr, 10);
109 if (
i < INT_MIN || (positive &&
i < 0) || *endptr !=
'\0' ||
i > INT_MAX)
123 long long i = strtoll(str, &endptr, 10);
125 if (
i < 0 || *endptr !=
'\0' ||
i > INT_MAX)
127 msg(msglevel,
"Cannot parse argument '%s' as non-negative integer", str);
138 long long i = strtoll(str, &endptr, 10);
140 if (
i < INT_MIN || *endptr !=
'\0' ||
i > INT_MAX)
142 msg(msglevel,
"Cannot parse argument '%s' as integer", str);
150atoi_constrained(
const char *str,
int *value,
const char *name,
int min,
int max,
int msglevel)
155 long long i = strtoll(str, &endptr, 10);
156 if (
i < INT_MIN || *endptr !=
'\0' ||
i > INT_MAX)
158 msg(msglevel,
"%s: Cannot parse '%s' as integer", name, str);
161 if (i < min || i > max)
165 msg(msglevel,
"%s: Must be an integer >= %d, not %lld",
170 msg(msglevel,
"%s: Must be an integer between %d and %d, not %lld",
181 "dhcp-option",
"dns",
182 "ifconfig",
"ifconfig-ipv6",
183 "push-continuation",
"redirect-gateway",
184 "redirect-private",
"route",
185 "route-gateway",
"route-ipv6",
186 "route-metric",
"topology",
187 "tun-mtu",
"keepalive" };
193 bool opt_is_updatable =
false;
210 if (!(line)[*
i + 1] || (line)[*
i + 1] ==
'-')
218 size_t len = strlen(&line[*
i]);
220 for (
int j = 0; j < count; ++j)
228 && (!line[*
i + opt_len] || line[*
i + opt_len] ==
' '))
230 opt_is_updatable =
true;
235 if (!opt_is_updatable)
239 msg(
D_PUSH,
"Pushed dispensable option is not updatable: '%s'. Ignoring.", line);
243 msg(
M_WARN,
"Pushed option is not updatable: '%s'.", line);
265 msg(
D_LOW,
"Pushed option accepted by filter: '%s'", line);
270 msg(
D_PUSH,
"Pushed option removed by filter: '%s'", line);
276 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)
#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
bool check_push_update_option_flags(char *line, int *i, unsigned int *flags)
Checks the formatting and validity of options inside push-update messages.
bool atoi_constrained(const char *str, int *value, const char *name, int min, int max, int msglevel)
Converts a str to an integer if the string can be represented as an integer number and is between min...
static const char * updatable_options[]
int positive_atoi(const char *str, int msglevel)
Converts a str to a positive number if the string represents a postive integer number.
int atoi_warn(const char *str, int msglevel)
Converts a str to an integer if the string can be represented as an integer number.
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.
#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