123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
-
-
- FILE_LICENCE ( GPL2_OR_LATER );
-
- #include <stdio.h>
- #include <stdint.h>
- #include <stdlib.h>
- #include <stdio.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>
-
-
-
-
- static struct command_descriptor dhcp_cmd =
- COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
- "[<interface>] [<interface>...]",
- "Configure network interface(s) using DHCP" );
-
-
- static int dhcp_payload ( struct net_device *netdev ) {
- int rc;
-
- if ( ( rc = dhcp ( netdev ) ) != 0 ) {
- printf ( "Could not configure %s: %s\n",
- netdev->name, strerror ( rc ) );
-
-
- netdev_close ( netdev );
-
- return rc;
- }
-
- return 0;
- }
-
-
- static int dhcp_exec ( int argc, char **argv ) {
- return ifcommon_exec ( argc, argv, &dhcp_cmd, dhcp_payload, 1 );
- }
-
-
- struct pxebs_options {};
-
-
- static struct option_descriptor pxebs_opts[] = {};
-
-
- static struct command_descriptor pxebs_cmd =
- COMMAND_DESC ( struct pxebs_options, pxebs_opts, 2, 2,
- "<interface> <server_type>",
- "Perform PXE Boot Server discovery" );
-
-
- static int pxebs_exec ( int argc, char **argv ) {
- struct pxebs_options opts;
- struct net_device *netdev;
- unsigned int pxe_type;
- int rc;
-
-
- if ( ( rc = parse_options ( argc, argv, &pxebs_cmd, &opts ) ) != 0 )
- return rc;
-
-
- if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
- return rc;
-
-
- if ( ( rc = parse_integer ( argv[ optind + 1 ], &pxe_type ) ) != 0 )
- return rc;
-
-
- if ( ( rc = pxebs ( netdev, pxe_type ) ) != 0 ) {
- printf ( "Could not discover boot server on %s: %s\n",
- netdev->name, strerror ( rc ) );
- return rc;
- }
-
- return 0;
- }
-
-
- struct command dhcp_commands[] __command = {
- {
- .name = "dhcp",
- .exec = dhcp_exec,
- },
- {
- .name = "pxebs",
- .exec = pxebs_exec,
- },
- };
|