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 if (conf->parser_info)
16 discover_context_add_boot_option(conf->dc, conf->parser_info);
19 static void pxe_process_pair(struct conf_context *ctx,
20 const char *name, char *value)
22 struct discover_boot_option *opt = ctx->parser_info;
25 /* quirk in the syslinux config format: initrd can be separated
27 if (!name && !strncasecmp(value, "initrd=", strlen("initrd="))) {
29 value += strlen("initrd=");
35 if (streq(name, "LABEL")) {
39 opt = discover_boot_option_create(ctx->dc, ctx->dc->device);
40 ctx->parser_info = opt;
42 opt->option->name = talloc_strdup(opt, value);
43 opt->option->id = talloc_asprintf(opt, "%s@%p",
44 ctx->dc->device->device->id, opt);
48 /* all other parameters need an option */
52 if (streq(name, "KERNEL")) {
53 url = pb_url_join(ctx->dc, ctx->dc->conf_url, value);
54 opt->boot_image = create_url_resource(opt, url);
56 } else if (streq(name, "INITRD")) {
57 url = pb_url_join(ctx->dc, ctx->dc->conf_url, value);
58 opt->initrd = create_url_resource(opt, url);
60 } else if (streq(name, "APPEND")) {
63 opt->option->boot_args = talloc_strdup(opt->option, value);
65 str = strcasestr(value, "INITRD=");
67 str += strlen("INITRD=");
68 end = strchrnul(str, ' ');
71 url = pb_url_join(ctx->dc, ctx->dc->conf_url, str);
72 opt->initrd = create_url_resource(opt, url);
78 static int pxe_parse(struct discover_context *dc, char *buf, int len)
80 struct conf_context *conf;
82 conf = talloc_zero(dc, struct conf_context);
88 conf->get_pair = conf_get_pair_space;
89 conf->process_pair = pxe_process_pair;
90 conf->finish = pxe_finish;
92 conf_parse_buf(conf, buf, len);
98 static struct parser pxe_parser = {
101 .method = CONF_METHOD_DHCP,
104 register_parser(pxe_parser);