iPXE
Data Structures | Functions | Variables
dhcp_cmd.c File Reference

DHCP management commands. More...

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <assert.h>
#include <getopt.h>
#include <ipxe/netdevice.h>
#include <ipxe/in.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <usr/dhcpmgmt.h>
#include <hci/ifmgmt_cmd.h>

Go to the source code of this file.

Data Structures

struct  pxebs_options
 "pxebs" options More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int pxebs_exec (int argc, char **argv)
 The "pxebs" command. More...
 

Variables

static struct option_descriptor pxebs_opts [] = {}
 "pxebs" option list More...
 
static struct command_descriptor pxebs_cmd
 "pxebs" command descriptor More...
 
struct command dhcp_commands [] __command
 DHCP management commands. More...
 

Detailed Description

DHCP management commands.

Definition in file dhcp_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ pxebs_exec()

static int pxebs_exec ( int  argc,
char **  argv 
)
static

The "pxebs" command.

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 66 of file dhcp_cmd.c.

66  {
67  struct pxebs_options opts;
68  struct net_device *netdev;
69  unsigned int pxe_type;
70  int rc;
71 
72  /* Parse options */
73  if ( ( rc = parse_options ( argc, argv, &pxebs_cmd, &opts ) ) != 0 )
74  return rc;
75 
76  /* Parse net device name */
77  if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
78  return rc;
79 
80  /* Parse boot server type */
81  if ( ( rc = parse_integer ( argv[ optind + 1 ], &pxe_type ) ) != 0 )
82  return rc;
83 
84  /* Perform Boot Server Discovery */
85  if ( ( rc = pxebs ( netdev, pxe_type ) ) != 0 ) {
86  printf ( "Could not discover boot server on %s: %s\n",
87  netdev->name, strerror ( rc ) );
88  return rc;
89  }
90 
91  return 0;
92 }
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition: parseopt.c:88
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
"pxebs" options
Definition: dhcp_cmd.c:49
int optind
Current option index.
Definition: getopt.c:51
static union @424 opts
"cert<xxx>" option list
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A network device.
Definition: netdevice.h:348
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:358
static struct command_descriptor pxebs_cmd
"pxebs" command descriptor
Definition: dhcp_cmd.c:55
int pxebs(struct net_device *netdev, unsigned int pxe_type)
Definition: dhcpmgmt.c:41
int parse_netdev(char *text, struct net_device **netdev)
Parse network device name.
Definition: parseopt.c:132

References net_device::name, netdev, optind, opts, parse_integer(), parse_netdev(), parse_options(), printf(), pxebs(), pxebs_cmd, rc, and strerror().

Variable Documentation

◆ pxebs_opts

struct option_descriptor pxebs_opts[] = {}
static

"pxebs" option list

Definition at line 52 of file dhcp_cmd.c.

◆ pxebs_cmd

struct command_descriptor pxebs_cmd
static
Initial value:
=
"<interface> <server type>" )
"pxebs" options
Definition: dhcp_cmd.c:49
static struct option_descriptor pxebs_opts[]
"pxebs" option list
Definition: dhcp_cmd.c:52
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107

"pxebs" command descriptor

Definition at line 55 of file dhcp_cmd.c.

Referenced by pxebs_exec().

◆ __command

struct command dhcp_commands [] __command
Initial value:
= {
{
.name = "dhcp",
.exec = ifconf_exec,
},
{
.name = "pxebs",
.exec = pxebs_exec,
},
}
int ifconf_exec(int argc, char **argv)
The "ifconf" command.
Definition: ifmgmt_cmd.c:249
static int pxebs_exec(int argc, char **argv)
The "pxebs" command.
Definition: dhcp_cmd.c:66

DHCP management commands.

Definition at line 95 of file dhcp_cmd.c.