5 #include <talloc/talloc.h>
9 #include "parser-conf.h"
10 #include "parser-utils.h"
13 static void pxe_finish(struct conf_context *conf)
15 discover_context_add_boot_option(conf->dc, conf->parser_info);
18 static void pxe_process_pair(struct conf_context *ctx,
19 const char *name, char *value)
21 struct discover_boot_option *opt = ctx->parser_info;
24 /* quirk in the syslinux config format: initrd can be separated
26 if (!name && !strncasecmp(value, "initrd=", strlen("initrd="))) {
28 value += strlen("initrd=");
34 if (streq(name, "LABEL")) {
38 opt = discover_boot_option_create(ctx->dc, ctx->dc->device);
39 ctx->parser_info = opt;
41 opt->option->name = talloc_strdup(opt, value);
42 opt->option->id = talloc_asprintf(opt, "%s@%p",
43 ctx->dc->device->device->id, opt);
47 /* all other parameters need an option */
51 if (streq(name, "KERNEL")) {
52 url = pb_url_join(ctx->dc, ctx->dc->conf_url, value);
53 opt->boot_image = create_url_resource(opt, url);
55 } else if (streq(name, "INITRD")) {
56 url = pb_url_join(ctx->dc, ctx->dc->conf_url, value);
57 opt->initrd = create_url_resource(opt, url);
59 } else if (streq(name, "APPEND")) {
62 opt->option->boot_args = talloc_strdup(opt->option, value);
64 str = strcasestr(value, "INITRD=");
66 str += strlen("INITRD=");
67 end = strchrnul(str, ' ');
70 url = pb_url_join(ctx->dc, ctx->dc->conf_url, str);
71 opt->initrd = create_url_resource(opt, url);
77 static int pxe_parse(struct discover_context *dc, char *buf, int len)
79 struct conf_context *conf;
81 conf = talloc_zero(dc, struct conf_context);
87 conf->get_pair = conf_get_pair_space;
88 conf->process_pair = pxe_process_pair;
89 conf->finish = pxe_finish;
91 conf_parse_buf(conf, buf, len);
97 static struct parser pxe_parser = {
100 .method = CONF_METHOD_DHCP,
103 register_parser(pxe_parser);