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)
 
 FILE_SECBOOT (PERMITTED)
 
static int ntp_exec (int argc, char **argv)
 "ntp" command More...
 
 COMMAND (ntp, ntp_exec)
 NTP command. More...
 

Variables

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

Detailed Description

NTP commands.

Definition in file ntp_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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 57 of file ntp_cmd.c.

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

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

◆ COMMAND()

COMMAND ( ntp  ,
ntp_exec   
)

NTP command.

Variable Documentation

◆ ntp_opts

struct option_descriptor ntp_opts[] = {}
static

"ntp" option list

Definition at line 44 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:44
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:109
"ntp" options
Definition: ntp_cmd.c:41

"ntp" command descriptor

Definition at line 47 of file ntp_cmd.c.

Referenced by ntp_exec().