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

NTP commands. More...

#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <usr/ntpmgmt.h>

Go to the source code of this file.

Data Structures

struct  ntp_options
 "ntp" options More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int ntp_exec (int argc, char **argv)
 "ntp" command More...
 

Variables

static struct option_descriptor ntp_opts [] = {}
 "ntp" option list More...
 
static struct command_descriptor ntp_cmd
 "ntp" command descriptor More...
 
struct command ntp_command __command
 NTP command. More...
 

Detailed Description

NTP commands.

Definition in file ntp_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ntp_exec()

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

"ntp" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 56 of file ntp_cmd.c.

56  {
57  struct ntp_options opts;
58  const char *hostname;
59  int rc;
60 
61  /* Parse options */
62  if ( ( rc = parse_options ( argc, argv, &ntp_cmd, &opts ) ) != 0 )
63  return rc;
64 
65  /* Parse hostname */
66  hostname = argv[optind];
67 
68  /* Get time and date via NTP */
69  if ( ( rc = ntp ( hostname ) ) != 0 ) {
70  printf ( "Could not get time and date: %s\n", strerror ( rc ) );
71  return rc;
72  }
73 
74  return 0;
75 }
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
int optind
Current option index.
Definition: getopt.c:51
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
static struct command_descriptor ntp_cmd
"ntp" command descriptor
Definition: ntp_cmd.c:46
int ntp(const char *hostname)
Get time and date via NTP.
Definition: ntpmgmt.c:45
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static union @437 opts
"cert<xxx>" option list
"ntp" options
Definition: ntp_cmd.c:40

References ntp(), ntp_cmd, optind, opts, parse_options(), printf(), rc, and strerror().

Variable Documentation

◆ ntp_opts

struct option_descriptor ntp_opts[] = {}
static

"ntp" option list

Definition at line 43 of file ntp_cmd.c.

◆ ntp_cmd

struct command_descriptor ntp_cmd
static
Initial value:
=
COMMAND_DESC ( struct ntp_options, ntp_opts, 1, 1, "<server>" )
static struct option_descriptor ntp_opts[]
"ntp" option list
Definition: ntp_cmd.c:43
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108
"ntp" options
Definition: ntp_cmd.c:40

"ntp" command descriptor

Definition at line 46 of file ntp_cmd.c.

Referenced by ntp_exec().

◆ __command

struct command ntp_command __command
Initial value:
= {
.name = "ntp",
.exec = ntp_exec,
}
static int ntp_exec(int argc, char **argv)
"ntp" command
Definition: ntp_cmd.c:56

NTP command.

Definition at line 78 of file ntp_cmd.c.