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

VLAN commands. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <ipxe/netdevice.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/vlan.h>

Go to the source code of this file.

Data Structures

struct  vcreate_options
 "vcreate" options More...
struct  vdestroy_options
 "vdestroy" options More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int vcreate_exec (int argc, char **argv)
 "vcreate" command
static int vdestroy_exec (int argc, char **argv)
 "vdestroy" command

Variables

static struct option_descriptor vcreate_opts []
 "vcreate" option list
static struct command_descriptor vcreate_cmd
 "vcreate" command descriptor
static struct option_descriptor vdestroy_opts [] = {}
 "vdestroy" option list
static struct command_descriptor vdestroy_cmd
 "vdestroy" command descriptor
struct command vlan_commands[] __command
 VLAN commands.

Detailed Description

VLAN commands.

Definition in file vlan_cmd.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int vcreate_exec ( int  argc,
char **  argv 
) [static]

"vcreate" command

Parameters:
argcArgument count
argvArgument list
Return values:
rcReturn status code

Definition at line 69 of file vlan_cmd.c.

References optind, parse_netdev(), parse_options(), printf(), vcreate_options::priority, rc, strerror(), vcreate_options::tag, and vlan_create().

                                                  {
        struct vcreate_options opts;
        struct net_device *trunk;
        int rc;

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

        /* Parse trunk interface */
        if ( ( rc = parse_netdev ( argv[optind], &trunk ) ) != 0 )
                return rc;

        /* Create VLAN device */
        if ( ( rc = vlan_create ( trunk, opts.tag, opts.priority ) ) != 0 ) {
                printf ( "Could not create VLAN device: %s\n",
                         strerror ( rc ) );
                return rc;
        }

        return 0;
}
static int vdestroy_exec ( int  argc,
char **  argv 
) [static]

"vdestroy" command

Parameters:
argcArgument count
argvArgument list
Return values:
rcReturn status code

Definition at line 110 of file vlan_cmd.c.

References netdev, optind, parse_netdev(), parse_options(), printf(), rc, strerror(), and vlan_destroy().

                                                   {
        struct vdestroy_options opts;
        struct net_device *netdev;
        int rc;

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

        /* Parse trunk interface */
        if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
                return rc;

        /* Destroy VLAN device */
        if ( ( rc = vlan_destroy ( netdev ) ) != 0 ) {
                printf ( "Could not destroy VLAN device: %s\n",
                         strerror ( rc ) );
                return rc;
        }

        return 0;
}

Variable Documentation

struct option_descriptor vcreate_opts[] [static]
Initial value:

"vcreate" option list

Definition at line 50 of file vlan_cmd.c.

Initial value:
        COMMAND_DESC ( struct vcreate_options, vcreate_opts, 1, 1,
                       "<trunk interface>" )

"vcreate" command descriptor

Definition at line 58 of file vlan_cmd.c.

struct option_descriptor vdestroy_opts[] = {} [static]

"vdestroy" option list

Definition at line 96 of file vlan_cmd.c.

Initial value:
        COMMAND_DESC ( struct vdestroy_options, vdestroy_opts, 1, 1,
                       "<VLAN interface>" )

"vdestroy" command descriptor

Definition at line 99 of file vlan_cmd.c.

struct command vlan_commands [] __command
Initial value:
 {
        {
                .name = "vcreate",
                .exec = vcreate_exec,
        },
        {
                .name = "vdestroy",
                .exec = vdestroy_exec,
        },
}

VLAN commands.

Definition at line 134 of file vlan_cmd.c.