iPXE
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)
 FILE_SECBOOT (PERMITTED)
static int vcreate_exec (int argc, char **argv)
 "vcreate" command
static int vdestroy_exec (int argc, char **argv)
 "vdestroy" command
 COMMAND (vcreate, vcreate_exec)
 VLAN commands.
 COMMAND (vdestroy, vdestroy_exec)

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

Detailed Description

VLAN commands.

Definition in file vlan_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ vcreate_exec()

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

"vcreate" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 70 of file vlan_cmd.c.

70 {
71 struct vcreate_options opts;
72 struct net_device *trunk;
73 int rc;
74
75 /* Parse options */
76 if ( ( rc = parse_options ( argc, argv, &vcreate_cmd, &opts ) ) != 0 )
77 return rc;
78
79 /* Parse trunk interface */
80 if ( ( rc = parse_netdev ( argv[optind], &trunk ) ) != 0 )
81 return rc;
82
83 /* Create VLAN device */
84 if ( ( rc = vlan_create ( trunk, opts.tag, opts.priority ) ) != 0 ) {
85 printf ( "Could not create VLAN device: %s\n",
86 strerror ( rc ) );
87 return rc;
88 }
89
90 return 0;
91}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
int optind
Current option index.
Definition getopt.c:52
int parse_netdev(char *text, struct net_device **netdev)
Parse network device name.
Definition parseopt.c:159
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition parseopt.c:485
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
A network device.
Definition netdevice.h:353
"vcreate" options
Definition vlan_cmd.c:43
int vlan_create(struct net_device *trunk, unsigned int tag, unsigned int priority)
Create VLAN device.
Definition vlan.c:344
static struct command_descriptor vcreate_cmd
"vcreate" command descriptor
Definition vlan_cmd.c:59
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References optind, opts, parse_netdev(), parse_options(), printf(), rc, strerror(), vcreate_cmd, and vlan_create().

Referenced by COMMAND().

◆ vdestroy_exec()

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

"vdestroy" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 111 of file vlan_cmd.c.

111 {
112 struct vdestroy_options opts;
113 struct net_device *netdev;
114 int rc;
115
116 /* Parse options */
117 if ( ( rc = parse_options ( argc, argv, &vdestroy_cmd, &opts ) ) != 0 )
118 return rc;
119
120 /* Parse trunk interface */
121 if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
122 return rc;
123
124 /* Destroy VLAN device */
125 if ( ( rc = vlan_destroy ( netdev ) ) != 0 ) {
126 printf ( "Could not destroy VLAN device: %s\n",
127 strerror ( rc ) );
128 return rc;
129 }
130
131 return 0;
132}
static struct net_device * netdev
Definition gdbudp.c:53
"vdestroy" options
Definition vlan_cmd.c:94
int vlan_destroy(struct net_device *netdev)
Destroy VLAN device.
Definition vlan.c:434
static struct command_descriptor vdestroy_cmd
"vdestroy" command descriptor
Definition vlan_cmd.c:100

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

Referenced by COMMAND().

◆ COMMAND() [1/2]

COMMAND ( vcreate ,
vcreate_exec  )

VLAN commands.

References vcreate_exec().

◆ COMMAND() [2/2]

COMMAND ( vdestroy ,
vdestroy_exec  )

References vdestroy_exec().

Variable Documentation

◆ vcreate_opts

struct option_descriptor vcreate_opts[]
static
Initial value:
= {
OPTION_DESC ( "priority", 'p', required_argument,
}
uint64_t tag
Identity tag.
Definition edd.h:1
@ required_argument
Option requires an argument.
Definition getopt.h:19
int parse_integer(char *text, unsigned int *value)
Parse integer value.
Definition parseopt.c:92
#define OPTION_DESC(_longopt, _shortopt, _has_arg, _struct, _field, _parse)
Construct option descriptor.
Definition parseopt.h:68
uint16_t priority
Priotity.
Definition stp.h:1

"vcreate" option list

Definition at line 51 of file vlan_cmd.c.

51 {
52 OPTION_DESC ( "tag", 't', required_argument,
54 OPTION_DESC ( "priority", 'p', required_argument,
56};

◆ vcreate_cmd

struct command_descriptor vcreate_cmd
static
Initial value:
=
"<trunk interface>" )
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition parseopt.h:109
static struct option_descriptor vcreate_opts[]
"vcreate" option list
Definition vlan_cmd.c:51

"vcreate" command descriptor

Definition at line 59 of file vlan_cmd.c.

Referenced by vcreate_exec().

◆ vdestroy_opts

struct option_descriptor vdestroy_opts[] = {}
static

"vdestroy" option list

Definition at line 97 of file vlan_cmd.c.

97{};

◆ vdestroy_cmd

struct command_descriptor vdestroy_cmd
static
Initial value:
=
"<VLAN interface>" )
static struct option_descriptor vdestroy_opts[]
"vdestroy" option list
Definition vlan_cmd.c:97

"vdestroy" command descriptor

Definition at line 100 of file vlan_cmd.c.

Referenced by vdestroy_exec().