36 in_options, out_options, scope, statements,
62 while (r && !(result && *result)) {
67#if defined (DEBUG_EXPRESSIONS)
75#if defined (DEBUG_EXPRESSIONS)
76 log_debug (
"exec: statements returns %d", status);
95#if defined (DEBUG_EXPRESSIONS)
107#if defined (DEBUG_EXPRESSIONS)
119#if defined (DEBUG_EXPRESSIONS)
134#if defined (DEBUG_EXPRESSIONS)
139 in_options, out_options, scope,
142#if defined (DEBUG_EXPRESSIONS)
143 log_debug (
"exec: switch: case %lx", (
unsigned long)e);
148 in_options, out_options, scope, e,
171#if defined (DEBUG_EXPRESSIONS)
173 ? (rc ?
"true" :
"false")
181 in_options, out_options, scope,
193#if defined (DEBUG_EXPRESSIONS)
195 (status ?
"succeeded" :
"failed"));
209 argv =
dmalloc((argc + 2) *
sizeof(*argv),
MDL);
221 log_debug(
"execute_statement argv[0] = %s", argv[0]);
225 memset (&ds, 0,
sizeof(ds));
234 memcpy(argv[i], ds.
data,
237 log_debug(
"execute_statement argv[%d] = %s", i, argv[i]);
241 log_debug(
"execute_statement failed argv[%d]", i);
251 if ((p = fork()) > 0) {
253 waitpid(p, &status, 0);
260 execvp(argv[0], argv);
261 log_error(
"Unable to execute %s: %m", argv[0]);
268 for (i = 0; i <= argc; i++) {
275 log_fatal(
"Impossible case at %s:%d (ENABLE_EXECUTE "
276 "is not defined).",
MDL);
285 out_options, scope, r ->
data.retval,
MDL);
286#if defined (DEBUG_EXPRESSIONS)
288 (status ?
"succeeded" :
"failed"));
295#if defined (DEBUG_EXPRESSIONS)
298 :
"<unnamed class>"));
304#if defined (DEBUG_EXPRESSIONS)
312#if defined (DEBUG_EXPRESSIONS)
315 ?
"supersede" :
"send"),
318 goto option_statement;
321#if defined (DEBUG_EXPRESSIONS)
325 goto option_statement;
328#if defined (DEBUG_EXPRESSIONS)
332 goto option_statement;
335#if defined (DEBUG_EXPRESSIONS)
355 log_error(
"set %s: can't allocate scope",
361#if defined (DEBUG_EXPRESSIONS)
392 in_options, out_options,
412#if defined (DEBUG_EXPRESSIONS)
414 (
binding && status ?
"" :
" (failed)"));
421 if (!scope || !*scope)
431#if defined (DEBUG_EXPRESSIONS)
433 (status ?
"found" :
"not found"));
440#if defined (DEBUG_EXPRESSIONS)
458 (e->data.let.name + 1),
476 in_options, out_options,
477 scope, e->data.set.expr,
MDL));
482#if defined (DEBUG_EXPRESSIONS)
483 log_debug(
"exec: let %s%s", e->data.let.name,
484 (
binding && status ?
"" :
"failed"));
488 if (!e->data.let.statements) {
489 }
else if (e->data.let.statements->op ==
491 e = e->data.let.statements;
499 in_options, out_options,
500 &ns, e->data.let.statements,
on_star);
507 memset (&ds, 0,
sizeof ds);
513#if defined (DEBUG_EXPRESSIONS)
519 case log_priority_fatal:
523 case log_priority_error:
527 case log_priority_debug:
531 case log_priority_info:
546 in_options, out_options, scope);
581 struct group *limiting_group;
613 for (limit = limiting_group; limit; limit = limit ->
next) {
621 in_options, out_options, scope,
637#if defined (POINTER_DEBUG)
646 if ((*ptr) ->
refcnt > 0) {
651 if ((*ptr) ->
refcnt < 0) {
653#if defined (DEBUG_RC_HISTORY)
654 dump_rc_history (*ptr);
656#if defined (POINTER_DEBUG)
666 switch ((*ptr) ->
op) {
668 if ((*ptr) ->
data.statements)
674 if ((*ptr) ->
data.on.statements)
680 if ((*ptr) ->
data.s_switch.statements)
683 if ((*ptr) ->
data.s_switch.expr)
689 if ((*ptr) ->
data.s_switch.expr)
695 if ((*ptr) ->
data.ie.expr)
698 if ((*ptr) ->
data.ie.tc)
701 if ((*ptr) ->
data.ie.fc)
707 if ((*ptr) ->
data.eval)
713 if ((*ptr) ->
data.eval)
719 if ((*ptr)->data.set.name)
721 if ((*ptr)->data.set.expr)
727 if ((*ptr)->data.unset)
732 if ((*ptr)->data.execute.command)
734 if ((*ptr)->data.execute.arglist)
744 if ((*ptr) ->
data.option)
764#if defined ENABLE_EXECUTE
768 const char *s, *t, *dot;
782 fprintf (
file,
"on ");
785 fprintf (
file,
"%sexpiry", s);
789 fprintf (
file,
"%scommit", s);
793 fprintf (
file,
"%srelease", s);
797 fprintf (
file,
" {");
810 fprintf (
file,
"switch (");
817 col,
indent,
" ",
"",
"{");
826 fprintf (
file,
"case ");
836 fprintf (
file,
"default: ");
841 fprintf (
file,
"if ");
853 fprintf (
file,
"} elsif ");
863 fprintf (
file,
"} else {");
873 fprintf (
file,
"eval ");
881 fprintf (
file,
"return;");
891 fprintf (
file,
"break;");
897 goto option_statement;
901 goto option_statement;
905 goto option_statement;
925 fprintf (
file,
"%s %s%s%s = ", s, t, dot,
927 col = (
indent + strlen (s) + strlen (t) +
945 fprintf (
file,
"set ");
958 fprintf (
file,
"unset ");
967 fprintf (
file,
"log ");
1001#ifdef ENABLE_EXECUTE
1020 log_fatal(
"Impossible case at %s:%d (ENABLE_EXECUTE "
1021 "is not defined).",
MDL);
1027 fprintf (
file,
"parse-vendor-option;");
1056 memset (&ds, 0,
sizeof ds);
1057 memset (&cd, 0,
sizeof cd);
1061 out_options, scope, expr,
1064 for (s = stmt; s; s = s -> next) {
1068 in_options, out_options,
1070 if (sub && cd.
len == ds.
len &&
1088 in_options, out_options,
1092 for (s = stmt; s; s = s->
next) {
1096 in_options, out_options,
1098 if (sub && n == c) {
1110 for (s = stmt; s; s = s->
next)
1121 int (*callback) (
struct
1124 void *vp,
int condp)
1129 for (foo = stmt; foo; foo = foo->
next) {
1130 if ((*callback) (foo, vp, condp) != 0)
#define rc_register(file, line, reference, addr, refcnt, d, f)
void data_string_forget(struct data_string *data, const char *file, int line)
int fundef_reference(struct fundef **ptr, struct fundef *src, const char *file, int line)
int executable_statement_reference(struct executable_statement **ptr, struct executable_statement *bp, const char *file, int line)
int binding_scope_reference(struct binding_scope **ptr, struct binding_scope *bp, const char *file, int line)
int binding_scope_allocate(struct binding_scope **ptr, const char *file, int line)
int binding_value_allocate(struct binding_value **cptr, const char *file, int line)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
void set_option(struct universe *universe, struct option_state *options, struct option_cache *option, enum statement_op op)
void parse_vendor_option(struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope)
Parse a vendor option (option 43)
int token_indent_data_string(FILE *file, int col, int indent, const char *prefix, const char *suffix, struct data_string *data)
int token_print_indent_concat(FILE *file, int col, int indent, const char *prefix, const char *suffix,...)
void indent_spaces(FILE *file, int indent)
int token_print_indent(FILE *file, int col, int indent, const char *prefix, const char *suffix, const char *buf)
void classify(struct packet *packet, struct class *class)
struct universe dhcp_universe
int execute_statements(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct executable_statement *statements, struct on_star *on_star)
void execute_statements_in_scope(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct group *group, struct group *limiting_group, struct on_star *on_star)
int executable_statement_foreach(struct executable_statement *stmt, int(*callback)(struct executable_statement *, void *, int), void *vp, int condp)
void write_statements(FILE *file, struct executable_statement *statements, int indent)
int executable_statement_dereference(struct executable_statement **ptr, const char *file, int line)
int find_matching_case(struct executable_statement **ep, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct expression *expr, struct executable_statement *stmt)
@ supersede_option_statement
@ default_option_statement
@ prepend_option_statement
@ append_option_statement
void * dmalloc(size_t, const char *, int)
void dfree(void *, const char *, int)
int log_error(const char *,...) __attribute__((__format__(__printf__
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__
struct binding * bindings
struct binding_scope * outer
enum binding_value::@135246253323115003010247222006030375211205217247 type
union binding_value::value value
struct binding_value * value
const unsigned char * data
struct executable_statement::@336221350347175166011011356261373334214214051201::@325210277324101252237043341265364212037303267157 s_switch
enum executable_statement::statement_op op
struct executable_statement * tc
struct executable_statement::@336221350347175166011011356261373334214214051201::@206325035353013171354256106236162033341037345150 set
enum executable_statement::@336221350347175166011011356261373334214214051201::@054036024254157344331216371041053101210136045205::@170066364270231075105257255130235107325336004011 priority
struct executable_statement::@336221350347175166011011356261373334214214051201::@114173066021273303314366177116061034061242304335 execute
struct executable_statement::@336221350347175166011011356261373334214214051201::@054036024254157344331216371041053101210136045205 log
struct executable_statement::@336221350347175166011011356261373334214214051201::@200067301215145050134342173232277303121035136232 ie
union executable_statement::@336221350347175166011011356261373334214214051201 data
struct expression * c_case
struct executable_statement::@336221350347175166011011356261373334214214051201::@206325035353013171354256106236162033341037345150 let
struct option_cache * option
struct expression * arglist
struct executable_statement * next
struct executable_statement * fc
struct executable_statement * statements
struct executable_statement::@336221350347175166011011356261373334214214051201::@240325212232200272321314266066265221125200273242 on
union expression::expr_union data
struct executable_statement * statements
struct executable_statement * on_commit
struct executable_statement * on_expiry
struct executable_statement * on_release
struct universe * universe
int binding_scope_dereference(struct binding_scope **ptr, const char *file, int line)
int write_expression(FILE *file, struct expression *expr, int col, int indent, int firstp)
int evaluate_expression(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct expression *expr, const char *file, int line)
struct binding * find_binding(struct binding_scope *scope, const char *name)
void expression_dereference(struct expression **eptr, const char *file, int line)
int evaluate_data_expression(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct expression *expr, const char *file, int line)
int is_data_expression(struct expression *expr)
int evaluate_boolean_expression(int *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct expression *expr)
int binding_value_dereference(struct binding_value **v, const char *file, int line)
int evaluate_numeric_expression(unsigned long *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct expression *expr)
struct expression::expr_union::@155243052250312351005066334172140274044155221273 arg