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

Variables

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

Detailed Description

NTP commands.

Definition in file ntp_cmd.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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.

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

                                              {
        struct ntp_options opts;
        const char *hostname;
        int rc;

        /* Parse options */
        if ( ( rc = parse_options ( argc, argv, &ntp_cmd, &opts ) ) != 0 )
                return rc;

        /* Parse hostname */
        hostname = argv[optind];

        /* Get time and date via NTP */
        if ( ( rc = ntp ( hostname ) ) != 0 ) {
                printf ( "Could not get time and date: %s\n", strerror ( rc ) );
                return rc;
        }

        return 0;
}

Variable Documentation

struct option_descriptor ntp_opts[] = {} [static]

"ntp" option list

Definition at line 43 of file ntp_cmd.c.

struct command_descriptor ntp_cmd [static]
Initial value:
        COMMAND_DESC ( struct ntp_options, ntp_opts, 1, 1, "<server>" )

"ntp" command descriptor

Definition at line 46 of file ntp_cmd.c.

struct command ntp_command __command
Initial value:
 {
        .name = "ntp",
        .exec = ntp_exec,
}

NTP command.

Definition at line 78 of file ntp_cmd.c.