1 Star 0 Fork 0

sdlhk/lldpad

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
parse_cli.l 19.20 KB
一键复制 编辑 原始数据 按行查看 历史
Dan Williams 提交于 2014-02-20 00:08 . trivial: upper-case some enum values
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
/*******************************************************************************
LLDP Agent Daemon (LLDPAD) Software
Copyright(c) 2007-2010 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
open-lldp Mailing List <lldp-devel@open-lldp.org>
*******************************************************************************/
%option nounput
%option noinput
%{
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include "lldp_dcbx_cmds.h"
#include "dcb_types.h"
#include "parse_cli.h"
#define BADARG "bad argument: "
static int cmd=0;
static int feature=0;
static int subtype=0;
static int error=0;
static char *port_id = NULL;
static char *badarg = NULL;
static int got_args = 0;
static int dcb_state = -1;
static int dcbx_version = -1;
static int advertise = 0x0f;
static int enable = 0x0f;
static int willing = 0x0f;
static int up2tc_a[MAX_USER_PRIORITIES];
static int up2tc_idx = 0;
static int pgpct_a[MAX_BANDWIDTH_GROUPS];
static int pgpct_idx = 0;
static int pgid_a[MAX_USER_PRIORITIES];
static int pgid_idx = 0;
static int uppct_a[MAX_USER_PRIORITIES];
static int uppct_idx = 0;
static int strict_a[MAX_USER_PRIORITIES];
static int strict_idx = 0;
static int pfcup_a[MAX_USER_PRIORITIES];
static int pfcup_idx = 0;
static int appsubtype = -1;
static char *appcfg_p = NULL;
static int llsubtype = -1;
static int llstatus = -1;
static int desc_id = 0;
static char *desc_str = NULL;
static int fargs = 0;
%}
%option noyywrap
%x dcb
%x dcbx
%x pg
%x pfc
%x app
%x ll
%x up2tc
%x pgpct
%x pgid
%x uppct
%x strict
%x getport
%x getfeature
%x getdcbargs
%x getdcbxargs
%x getdcbxver
%x getpfcargs
%x getpgargs
%x getpgdescargs
%x getpgdesc
%x getappargs
%x getllargs
%x getadvertise
%x getenable
%x getwilling
%x getup2tc
%x getpgpct
%x getpgid
%x getuppct
%x getstrict
%x getpfcup
%x getappsubtype
%x getappcfg
%x getllsubtype
%x getllstatus
%x cmddone
%%
[ \\t]+
gc { if (!cmd) {
cmd = CMD_GET_CONFIG;
} else {
if (!badarg) badarg = strdup(yytext);
error = 1;
}
BEGIN(getport);
}
sc { if (!cmd) {
cmd = CMD_SET_CONFIG;
} else {
if (!badarg) badarg = strdup(yytext);
error = 1;
}
BEGIN(getport);
}
go { if (!cmd) {
cmd = CMD_GET_OPER;
} else {
if (!badarg) badarg = strdup(yytext);
error = 1;
}
BEGIN(getport);
}
gp { if (!cmd) {
cmd = CMD_GET_PEER;
} else {
if (!badarg) badarg = strdup(yytext);
error = 1;
}
BEGIN(getport);
}
[[:alnum:][:punct:][:cntrl:]]+ { if (!badarg) badarg = strdup(yytext);
error = 1;
}
<getport>[ \\t]
<getport>dcbx { feature = FEATURE_DCBX;
/* 'dcbx' is a global feature which does not
* require a port name.
*/
if (cmd == CMD_SET_CONFIG) {
BEGIN(getdcbxargs);
} else if (cmd != CMD_GET_PEER) {
BEGIN(cmddone);
} else {
error = 1;
if (!badarg) badarg =
strdup("invalid command");
}
}
<getport>[a-zA-Z0-9_.:-]+ { port_id = strdup(yytext);
BEGIN(getfeature);
}
<getfeature>[ \\t]
<getfeature>dcb { feature = FEATURE_DCB;
if (cmd == CMD_SET_CONFIG)
BEGIN(getdcbargs);
else
BEGIN(cmddone);
}
<getfeature>pfc { feature = FEATURE_PFC;
if (cmd == CMD_SET_CONFIG)
BEGIN(getpfcargs);
else
BEGIN(cmddone);
}
<getfeature>pg { feature = FEATURE_PG;
if (cmd == CMD_SET_CONFIG)
BEGIN(getpgargs);
else
BEGIN(cmddone);
}
<getfeature>pgdesc { feature = FEATURE_PG_DESC;
BEGIN(getpgdescargs);
}
<getfeature>app { feature = FEATURE_APP;
BEGIN(getappsubtype);
}
<getfeature>ll { feature = FEATURE_LLINK;
BEGIN(getllsubtype);
}
<getfeature>[a-zA-Z0-9]+ {
if (!badarg) badarg = strdup(yytext);
error = 1;
}
<getdcbxargs>[ \\t]
<getdcbxargs>v: {
BEGIN(getdcbxver);
}
<getdcbxver>[1256] { dcbx_version = atoi(yytext);
BEGIN(cmddone);
}
<getdcbxver>cee { dcbx_version = DCBX_SUBTYPE2;
BEGIN(cmddone);
}
<getdcbxver>cin { dcbx_version = DCBX_SUBTYPE1;
BEGIN(cmddone);
}
<getdcbxver>force-cee { dcbx_version = DCBX_FORCE_SUBTYPE2;
BEGIN(cmddone);
}
<getdcbxver>force-cin { dcbx_version = DCBX_FORCE_SUBTYPE1;
BEGIN(cmddone);
}
<getdcbargs,getpgargs,getpfcargs,getappargs,getpgdescargs>[ \\t]
<getdcbargs>on { dcb_state = 1;
BEGIN(cmddone);
}
<getdcbargs>off { dcb_state = 0;
BEGIN(cmddone);
}
<getpgdescargs>[1-8] {
desc_id = *yytext & 0x0f;
if (cmd == CMD_SET_CONFIG)
BEGIN(getpgdesc);
else
BEGIN(cmddone);
}
<getpgdesc>[ \\t]+
<getpgdesc>[[:alnum:][:punct:]]+[[:alnum:][:punct:] \\t]+[[:alnum:][:punct:]]+ {
desc_str = strdup(yytext);
BEGIN(cmddone);
}
<getpgdesc>[[:cntrl:]] {
error = 1;
if (!badarg) badarg = strdup(yytext);
}
<getpgargs,getpfcargs,getappargs,getllargs>a: {
if (got_args & GOT_ADVERTISE) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_ADVERTISE;
BEGIN(getadvertise);
}
}
<getpgargs,getpfcargs,getappargs,getllargs>e: {
if (got_args & GOT_ENABLE) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_ENABLE;
BEGIN(getenable);
}
}
<getpgargs,getpfcargs,getappargs,getllargs>w: {
if (got_args & GOT_WILLING) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_WILLING;
BEGIN(getwilling);
}
}
<getadvertise>[01] { advertise = atoi(yytext);
switch (feature) {
case FEATURE_PG: BEGIN(getpgargs); break;
case FEATURE_PFC: BEGIN(getpfcargs); break;
case FEATURE_APP: BEGIN(getappargs); break;
case FEATURE_LLINK: BEGIN(getllargs); break;
default:
if (!badarg) badarg =
strdup("invalid feature");
error = 1;
}
}
<getenable>[01] { enable = atoi(yytext);
switch (feature) {
case FEATURE_PG: BEGIN(getpgargs); break;
case FEATURE_PFC: BEGIN(getpfcargs); break;
case FEATURE_APP: BEGIN(getappargs); break;
case FEATURE_LLINK: BEGIN(getllargs); break;
default:
if (!badarg) badarg =
strdup("invalid feature");
error = 1;
}
}
<getwilling>[01] { willing = atoi(yytext);
switch (feature) {
case FEATURE_PG: BEGIN(getpgargs); break;
case FEATURE_PFC: BEGIN(getpfcargs); break;
case FEATURE_APP: BEGIN(getappargs); break;
case FEATURE_LLINK: BEGIN(getllargs); break;
default:
if (!badarg) badarg =
strdup("invalid feature");
error = 1;
}
}
<getwilling,getenable,getadvertise>[2-9[:alpha:][:punct:][:cntrl:] \\t] {
error = 1;
if (!badarg) badarg = strdup(yytext);
}
<getpgargs>up2tc: {
if (got_args & GOT_UP2TC) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_UP2TC;
BEGIN(getup2tc);
}
}
<getpgargs>pgpct: {
if (got_args & GOT_PGPCT) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_PGPCT;
BEGIN(getpgpct);
}
}
<getpgargs>pgid: {
if (got_args & GOT_PGID) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_PGID;
BEGIN(getpgid);
}
}
<getpgargs>uppct: {
if (got_args & GOT_UPPCT) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_UPPCT;
BEGIN(getuppct);
}
}
<getpgargs>strict: {
if (got_args & GOT_STRICT) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_STRICT;
BEGIN(getstrict);
}
}
<getpfcargs>pfcup: {
if (got_args & GOT_PFCUP) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_PFCUP;
BEGIN(getpfcup);
}
}
<getappsubtype>:[0-9]+ { appsubtype = atoi(yytext+1);
if (appsubtype >= DCB_MAX_APPTLV) {
appsubtype = -1;
if (!badarg) badarg =
strdup("invalid subtype");
error = 1;
}
else if (cmd == CMD_SET_CONFIG) {
BEGIN(getappargs);
}
else
BEGIN(cmddone);
}
<getappsubtype>:[fF][cC][oO][eE][ \\t] { appsubtype = 0;
if (cmd == CMD_SET_CONFIG)
BEGIN(getappargs);
else
BEGIN(cmddone);
}
<getappsubtype>:[iI][sS][cC][sC][iI][ \\t] { appsubtype = 1;
if (cmd == CMD_SET_CONFIG)
BEGIN(getappargs);
else
BEGIN(cmddone);
}
<getappsubtype>:[fF][iI][pP][ \\t] { appsubtype = 2;
if (cmd == CMD_SET_CONFIG)
BEGIN(getappargs);
else
BEGIN(cmddone);
}
<getappargs>appcfg: {
if (got_args & GOT_APPCFG) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_APPCFG;
BEGIN(getappcfg);
}
}
<getllsubtype>:0 { llsubtype = atoi(yytext+1);
if (cmd == CMD_SET_CONFIG)
BEGIN(getllargs);
else
BEGIN(cmddone);
}
<getllsubtype>:[fF][cC][oO][eE][ \\t] { llsubtype = 0;
if (cmd == CMD_SET_CONFIG)
BEGIN(getllargs);
else
BEGIN(cmddone);
}
<getllargs>status: {
if (got_args & GOT_LLSTATUS) {
if (!badarg) badarg =
strdup("duplicate argument");
error = 1;
} else {
got_args |= GOT_LLSTATUS;
BEGIN(getllstatus);
}
}
<getllstatus>[01] { llstatus = atoi(yytext);
BEGIN(getllargs);
}
<getdcbargs,getpfcargs,getpgargs,getappargs,getpgdescargs>[[:alnum:][:punct:][:cntrl:]] {
BEGIN(cmddone);
yyless(0);
}
<getup2tc>[0-7] { up2tc_a[up2tc_idx++] = atoi(yytext);
if (up2tc_idx == 8) {
BEGIN(getpgargs);
}
}
<getpgpct,getuppct>[, \\t]+
<getpgpct>[0-9]+ { pgpct_a[pgpct_idx] = atoi(yytext);
if (pgpct_a[pgpct_idx] > 100) {
if (!badarg) badarg =
strdup("invalid percent value");
error = 1;
} else {
pgpct_idx++;
if (pgpct_idx == 8) {
BEGIN(getpgargs);
}
}
}
<getuppct>[0-9]+ { uppct_a[uppct_idx] = atoi(yytext);
if (uppct_a[uppct_idx] > 100) {
if (!badarg) badarg =
strdup("invalid percent value");
error = 1;
} else {
uppct_idx++;
if (uppct_idx == 8) {
BEGIN(getpgargs);
}
}
}
<getpgpct,getuppct>[a-zA-Z0-9]+ { BEGIN(getpgargs);
}
<getpgid>[0-7fF] { pgid_a[pgid_idx++] = strtol(yytext, NULL, 16);
if (pgid_idx == 8) {
BEGIN(getpgargs);
}
}
<getstrict>[01] { strict_a[strict_idx++] = atoi(yytext);
if (strict_idx == 8) {
BEGIN(getpgargs);
}
}
<getpfcup>[01] { pfcup_a[pfcup_idx++] = atoi(yytext);
if (pfcup_idx == 8) {
BEGIN(getpfcargs);
}
}
<getappcfg>[0-9a-fA-F]{2} { appcfg_p = strdup(yytext);
BEGIN(getappargs);
}
<getappcfg,getup2tc,getpgpct,getpgid,getuppct,getstrict,getpfcup,getdcbxargs,getdcbxver,getappsubtype,getllsubtype>. {
error = 1;
if (!badarg) badarg = strdup(yytext);
}
<cmddone>[^[:blank:]]+ { if (!badarg) badarg = strdup(yytext);
error = 1;
}
<<EOF>> {
BEGIN(INITIAL);
yyterminate();
}
%%
int get_port_len()
{
if (port_id)
return strlen(port_id);
else
return 0;
}
int *get_up2tc()
{
return &up2tc_a[0];
}
int *get_pgpct()
{
return &pgpct_a[0];
}
int *get_pgid()
{
return &pgid_a[0];
}
int *get_uppct()
{
return &uppct_a[0];
}
int *get_strict()
{
return &strict_a[0];
}
int *get_pfcup()
{
return &pfcup_a[0];
}
char *get_appcfg()
{
return appcfg_p;
}
int get_enable()
{
return enable;
}
int get_dcb_param()
{
return dcb_state;
}
int get_dcbx_param()
{
return dcbx_version;
}
int get_advertise()
{
return advertise;
}
int get_willing()
{
return willing;
}
int get_cmd()
{
return cmd;
}
int get_fargs()
{
return fargs;
}
int get_feature()
{
return feature;
}
int get_subtype()
{
return subtype;
}
int get_desc_id()
{
return desc_id;
}
char *get_desc_str()
{
return desc_str;
}
void free_desc_str()
{
if (desc_str) {
free(desc_str);
desc_str = NULL;
}
}
char *get_port()
{
return port_id;
}
int get_llstatus()
{
return llstatus;
}
void free_port()
{
if (port_id) {
free(port_id);
port_id = NULL;
}
}
void free_appcfg()
{
if (appcfg_p) {
free(appcfg_p);
appcfg_p = NULL;
}
}
char *get_parse_error()
{
return badarg;
}
void free_parse_error()
{
if (badarg) {
free(badarg);
badarg = NULL;
}
}
void init_parse_state()
{
cmd=0;
feature=0;
error=0;
free_parse_error();
free_port();
free_appcfg();
free_desc_str();
dcb_state = -1;
dcbx_version = -1;
advertise = 0xf;
enable = 0xf;
willing = 0xf;
up2tc_idx = 0;
pgpct_idx = 0;
pgid_idx = 0;
uppct_idx = 0;
strict_idx = 0;
pfcup_idx = 0;
appsubtype = -1;
llsubtype = -1;
llstatus = -1;
desc_id = 0;
got_args = 0;
fargs = 0;
}
int parse_dcb_cmd(char *buf)
{
int i;
int pargs = 1;
YY_BUFFER_STATE yyhnd;
yyout = fopen("/dev/null", "a+");
yyhnd = yy_scan_string(buf);
yylex();
yy_delete_buffer(yyhnd);
if (error) {
return error;
}
switch (cmd) {
case CMD_GET_CONFIG:
case CMD_GET_OPER:
case CMD_GET_PEER:
if (!feature) {
if (!badarg)
badarg = strdup("feature was not specified");
error = 1;
}
if (!port_id && feature != FEATURE_DCBX) {
if (!badarg)
badarg = strdup("port was not specified");
error = 1;
}
switch (feature) {
case FEATURE_DCB:
case FEATURE_DCBX:
if (cmd == CMD_GET_PEER) {
if (!badarg)
badarg = strdup("invalid command");
error = 1;
break;
}
/* else fall thru */
case FEATURE_PG:
case FEATURE_PFC:
subtype = 0;
break;
case FEATURE_APP:
if (appsubtype >= 0) {
subtype = appsubtype;
} else {
subtype = 0;
if (!badarg)
badarg = strdup("subtype was not "
"specified");
error = 1;
}
break;
case FEATURE_LLINK:
if (llsubtype >= 0) {
subtype = llsubtype;
} else {
subtype = 0;
if (!badarg)
badarg = strdup("subtype was not "
"specified");
error = 1;
}
break;
case FEATURE_PG_DESC:
if (!desc_id) {
desc_id = 0;
if (!badarg)
badarg = strdup("pgid was not "
"specified");
error = 1;
}
if (cmd != CMD_GET_CONFIG) {
if (!badarg)
badarg = strdup("invalid command");
error = 1;
}
subtype = 0;
break;
default:
if (!badarg)
badarg = strdup("invalid feature");
error = 1;
break;
}
break;
case CMD_SET_CONFIG:
if (!port_id && feature != FEATURE_DCBX) {
if (!badarg)
badarg = strdup("port was not specified");
error = 1;
break;
}
/* make sure all command components were provided */
if (advertise == 0x0f && willing == 0x0f && enable == 0x0f) {
pargs = 0;
}
switch (feature) {
case FEATURE_DCB:
fargs = (dcb_state > -1);
if (fargs == 0) {
if (!badarg)
badarg = strdup("no dcb arg supplied");
error = 1;
}
break;
case FEATURE_DCBX:
fargs = (dcbx_version > -1);
if (fargs == 0) {
if (!badarg)
badarg = strdup("no dcbx arg supplied");
error = 1;
}
break;
case FEATURE_PG:
/* check if pg attributes were included and flag error
* if an incomplete set was entered.
*/
fargs = up2tc_idx + strict_idx + pgpct_idx +
uppct_idx + pgid_idx;
if (fargs == 0 && pargs == 0) {
if (!badarg)
badarg = strdup("no pg args supplied");
error = 1;
break;
}
if (up2tc_idx == 0) {
for (i = 0; i < MAX_USER_PRIORITIES; i++)
if (fargs)
up2tc_a[i] = -1;
}
else if (up2tc_idx < MAX_USER_PRIORITIES) {
if (!badarg)
badarg = strdup("incomplete up2tc "
"argument");
error = 1;
break;
}
if (pgid_idx == 0) {
for (i = 0; i < MAX_USER_PRIORITIES; i++)
if (fargs)
pgid_a[i] = -1;
}
else if (pgid_idx < MAX_USER_PRIORITIES) {
if (!badarg)
badarg = strdup("incomplete pgid "
"argument");
error = 1;
break;
}
if (pgpct_idx == 0) {
for (i = 0; i < MAX_BANDWIDTH_GROUPS; i++)
if (fargs)
pgpct_a[i] = -1;
}
else if (pgpct_idx < MAX_BANDWIDTH_GROUPS) {
if (!badarg)
badarg = strdup("incomplete pgpct "
"argument");
error = 1;
break;
}
if (uppct_idx == 0) {
for (i = 0; i < MAX_USER_PRIORITIES; i++)
if (fargs)
uppct_a[i] = -1;
}
else if (uppct_idx < MAX_USER_PRIORITIES) {
if (!badarg)
badarg = strdup("incomplete uppct "
"argument");
error = 1;
break;
}
if (strict_idx == 0) {
for (i=0; i<MAX_USER_PRIORITIES; i++) {
if (fargs)
strict_a[i] = -1;
}
}
else if (strict_idx < MAX_USER_PRIORITIES) {
if (!badarg)
badarg = strdup("incomplete strict "
"argument");
error = 1;
break;
}
break;
case FEATURE_PFC: /* pfc */
fargs = pfcup_idx;
if (fargs == 0 && pargs == 0) {
if (!badarg)
badarg = strdup("no pfc args supplied");
error = 1;
break;
}
if (pfcup_idx && pfcup_idx < MAX_USER_PRIORITIES) {
if (!badarg)
badarg = strdup("incomplete pfcup "
"argument");
error = 1;
}
break;
case FEATURE_APP:
fargs = (appcfg_p != NULL);
if (fargs == 0 && pargs == 0) {
if (!badarg)
badarg = strdup("no app args supplied");
error = 1;
break;
}
if (appcfg_p && strlen(appcfg_p) % 2) {
if (!badarg)
badarg = strdup("invalid appcfg "
"length");
error = 1;
break;
}
subtype = appsubtype;
if (!appcfg_p)
break;
switch (appsubtype) {
case APP_FCOE_STYPE:
if (strlen(appcfg_p) != 2) {
if (!badarg)
badarg = strdup("invalid appcfg"
" length for FCoE");
error = 1;
}
break;
case APP_ISCSI_STYPE:
if (strlen(appcfg_p) != 2) {
if (!badarg)
badarg = strdup("invalid appcfg"
" length for iSCSI");
error = 1;
}
break;
case APP_FIP_STYPE:
if (strlen(appcfg_p) != 2) {
if (!badarg)
badarg = strdup("invalid appcfg"
" length for FIP");
error = 1;
}
break;
default:
break;
}
break;
case FEATURE_LLINK:
if (pargs == 0 && llstatus < 0) {
if (!badarg)
badarg = strdup("no args supplied");
error = 1;
break;
}
break;
case FEATURE_PG_DESC:
fargs = (desc_str != NULL);
if (fargs == 0) {
if (!badarg)
badarg = strdup("bwg description was "
"not supplied");
error = 1;
break;
}
if (desc_str && strlen(desc_str) >=
MAX_DESCRIPTION_LEN) {
if (!badarg)
badarg = strdup("bwg description "
"length too long (max 99)");
error = 1;
}
break;
default:
if (!badarg)
badarg = strdup("invalid feature");
error = 1;
break;
}
break;
default:
badarg = strdup("invalid DCB command");
error = 1;
}
return error;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/sdlhk/lldpad.git
git@gitee.com:sdlhk/lldpad.git
sdlhk
lldpad
lldpad
master

搜索帮助