iPXE
nslookup_cmd.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Patrick Plenefisch <phplenefisch@wpi.edu>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 */
19
20FILE_LICENCE ( GPL2_OR_LATER );
21FILE_SECBOOT ( PERMITTED );
22
23#include <stdio.h>
24#include <getopt.h>
25#include <ipxe/command.h>
26#include <ipxe/parseopt.h>
27#include <usr/nslookup.h>
28
29/** @file
30 *
31 * nslookup command
32 *
33 */
34
35/** "nslookup" options */
37
38/** "nslookup" option list */
39static struct option_descriptor nslookup_opts[] = {};
40
41/** "nslookup" command descriptor */
44 "<setting> <name>" );
45
46/**
47 * The "nslookup" command
48 *
49 * @v argc Argument count
50 * @v argv Argument list
51 * @ret rc Return status code
52 */
53static int nslookup_exec ( int argc, char **argv ) {
55 const char *name;
56 const char *setting_name;
57 int rc;
58
59 /* Parse options */
60 if ( ( rc = parse_options ( argc, argv, &nslookup_cmd, &opts ) ) != 0 )
61 return rc;
62
63 /* Parse setting name */
64 setting_name = argv[optind];
65
66 /* Parse name to be resolved */
67 name = argv[ optind + 1 ];
68
69 /* Look up name */
70 if ( ( rc = nslookup ( name, setting_name ) ) != 0 )
71 return rc;
72
73 return 0;
74}
75
76/** The "nslookup" command */
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
const char * name
Definition ath9k_hw.c:1986
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
#define COMMAND(name, exec)
Definition command.h:27
int optind
Current option index.
Definition getopt.c:52
Parse command-line options.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
Standalone name resolution.
static int nslookup_exec(int argc, char **argv)
The "nslookup" command.
static struct command_descriptor nslookup_cmd
"nslookup" command descriptor
static struct option_descriptor nslookup_opts[]
"nslookup" option list
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition parseopt.c:485
Command line option parsing.
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition parseopt.h:109
int setting_name(struct settings *settings, const struct setting *setting, char *buf, size_t len)
Return full setting name.
Definition settings.c:1607
A command descriptor.
Definition parseopt.h:78
"nslookup" options
A name resolution request.
Definition nslookup.c:40
A command-line option descriptor.
Definition parseopt.h:24