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 More...
 
static int vdestroy_exec (int argc, char **argv)
 "vdestroy" command More...
 

Variables

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

Detailed Description

VLAN commands.

Definition in file vlan_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ vcreate_exec()

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.

69  {
70  struct vcreate_options opts;
71  struct net_device *trunk;
72  int rc;
73 
74  /* Parse options */
75  if ( ( rc = parse_options ( argc, argv, &vcreate_cmd, &opts ) ) != 0 )
76  return rc;
77 
78  /* Parse trunk interface */
79  if ( ( rc = parse_netdev ( argv[optind], &trunk ) ) != 0 )
80  return rc;
81 
82  /* Create VLAN device */
83  if ( ( rc = vlan_create ( trunk, opts.tag, opts.priority ) ) != 0 ) {
84  printf ( "Could not create VLAN device: %s\n",
85  strerror ( rc ) );
86  return rc;
87  }
88 
89  return 0;
90 }
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:464
int optind
Current option index.
Definition: getopt.c:51
static struct command_descriptor vcreate_cmd
"vcreate" command descriptor
Definition: vlan_cmd.c:58
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
"vcreate" options
Definition: vlan_cmd.c:42
int vlan_create(struct net_device *trunk, unsigned int tag, unsigned int priority)
Create VLAN device.
Definition: vlan.c:338
static union @423 opts
"cert<xxx>" option list
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A network device.
Definition: netdevice.h:348
int parse_netdev(char *text, struct net_device **netdev)
Parse network device name.
Definition: parseopt.c:132

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

◆ vdestroy_exec()

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.

110  {
111  struct vdestroy_options opts;
112  struct net_device *netdev;
113  int rc;
114 
115  /* Parse options */
116  if ( ( rc = parse_options ( argc, argv, &vdestroy_cmd, &opts ) ) != 0 )
117  return rc;
118 
119  /* Parse trunk interface */
120  if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
121  return rc;
122 
123  /* Destroy VLAN device */
124  if ( ( rc = vlan_destroy ( netdev ) ) != 0 ) {
125  printf ( "Could not destroy VLAN device: %s\n",
126  strerror ( rc ) );
127  return rc;
128  }
129 
130  return 0;
131 }
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:464
int optind
Current option index.
Definition: getopt.c:51
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
static struct net_device * netdev
Definition: gdbudp.c:52
static union @423 opts
"cert<xxx>" option list
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A network device.
Definition: netdevice.h:348
int vlan_destroy(struct net_device *netdev)
Destroy VLAN device.
Definition: vlan.c:428
static struct command_descriptor vdestroy_cmd
"vdestroy" command descriptor
Definition: vlan_cmd.c:99
"vdestroy" options
Definition: vlan_cmd.c:93
int parse_netdev(char *text, struct net_device **netdev)
Parse network device name.
Definition: parseopt.c:132

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

Variable Documentation

◆ vcreate_opts

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

"vcreate" option list

Definition at line 50 of file vlan_cmd.c.

◆ vcreate_cmd

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

"vcreate" command descriptor

Definition at line 58 of file vlan_cmd.c.

Referenced by vcreate_exec().

◆ vdestroy_opts

struct option_descriptor vdestroy_opts[] = {}
static

"vdestroy" option list

Definition at line 96 of file vlan_cmd.c.

◆ 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:96
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107
"vdestroy" options
Definition: vlan_cmd.c:93

"vdestroy" command descriptor

Definition at line 99 of file vlan_cmd.c.

Referenced by vdestroy_exec().

◆ __command

struct command vlan_commands [] __command
Initial value:
= {
{
.name = "vcreate",
.exec = vcreate_exec,
},
{
.name = "vdestroy",
.exec = vdestroy_exec,
},
}
static int vdestroy_exec(int argc, char **argv)
"vdestroy" command
Definition: vlan_cmd.c:110
static int vcreate_exec(int argc, char **argv)
"vcreate" command
Definition: vlan_cmd.c:69

VLAN commands.

Definition at line 134 of file vlan_cmd.c.