1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
|
/******************************************************************************
Implementation of EVB TLVs for LLDP
(c) Copyright IBM Corp. 2012
Author(s): Thomas Richter <tmricht at linux.vnet.ibm.com>
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".
******************************************************************************/
#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "lldp.h"
#include "lldp_evb22.h"
#include "lldp_tlv.h"
#include "lldp_mand_clif.h"
#include "config.h"
#include "clif_msgs.h"
#include "messages.h"
/*
* Defines for configuration file name tags.
*/
#define EVB_BUF_SIZE 256
#define EVB_CONF_MODE "evbmode"
#define EVB_CONF_RRREQ "evbrrreq"
#define EVB_CONF_RRCAP "evbrrcap"
#define EVB_CONF_GPID "evbgpid"
#define EVB_CONF_RETRIES "ecpretries"
#define EVB_CONF_RTE "ecprte"
#define EVB_CONF_RWD "vdprwd"
#define EVB_CONF_RKA "vdprka"
#define EVB_CONF_BRIDGE "bridge"
#define EVB_CONF_STATION "station"
/*
* Read EVB specific data from the configuration file.
*/
static const char *evb22_conf_string(char *ifname, enum agent_type type,
char *ext, int def)
{
char arg_path[EVB_BUF_SIZE];
const char *param = NULL;
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
TLVID_PREFIX, TLVID(OUI_IEEE_8021Qbg22, LLDP_EVB22_SUBTYPE),
ext);
if (get_cfg(ifname, type, arg_path, ¶m, CONFIG_TYPE_STRING))
LLDPAD_INFO("%s:%s agent %d loading EVB policy for %s"
" failed, using default (%d)\n", __func__,
ifname, type, ext, def);
return param;
}
static int evb22_conf_int(char *ifname, enum agent_type type,
char *ext, int def, int cfgtype)
{
char arg_path[EVB_BUF_SIZE];
int param;
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
TLVID_PREFIX, TLVID(OUI_IEEE_8021Qbg22, LLDP_EVB22_SUBTYPE),
ext);
if (get_cfg(ifname, type, arg_path, ¶m, cfgtype)) {
LLDPAD_INFO("%s:%s agent %d loading EVB policy for %s"
" failed, using default (%d)\n", __func__,
ifname, type, ext, def);
return def;
}
return param;
}
/*
* Read EXP parameter. Defaults to 8 --> 10 * 2 ^ 8 = 2560us > 2ms.
*/
static int exponent(char *ifname, enum agent_type type, char *txt, int def)
{
int value;
value = evb22_conf_int(ifname, type, txt, def, CONFIG_TYPE_INT);
if (value > 31) {
LLDPAD_DBG("%s:%s agent %d invalid %s %d\n", __func__,
ifname, type, txt, value);
value = def;
}
LLDPAD_DBG("%s:%s agent %d policy %s %d\n", __func__,
ifname, type, txt, value);
return value;
}
/*
* Read retransmission exponent parameter.
*/
int evb22_conf_rte(char *ifname, enum agent_type type)
{
return exponent(ifname, type, EVB_CONF_RTE, 8);
}
/*
* Read reinit keep alive parameter. Same as RTE.
*/
int evb22_conf_rka(char *ifname, enum agent_type type)
{
return exponent(ifname, type, EVB_CONF_RKA, 20);
}
/*
* Read resource wait delay parameter. Same as RTE.
*/
int evb22_conf_rwd(char *ifname, enum agent_type type)
{
return exponent(ifname, type, EVB_CONF_RWD, 20);
}
/*
* Read max retries parameter. Defaults to 3.
*/
int evb22_conf_retries(char *ifname, enum agent_type type)
{
int value;
value = evb22_conf_int(ifname, type, EVB_CONF_RETRIES, 3,
CONFIG_TYPE_INT);
if (value > 7) {
LLDPAD_DBG("%s:%s agent %d invalid %s %d\n", __func__,
ifname, type, EVB_CONF_RETRIES, value);
value = 3;
}
LLDPAD_DBG("%s:%s agent %d policy %s %d\n", __func__,
ifname, type, EVB_CONF_RETRIES, value);
return value;
}
/*
* Read station group id parameter. Defaults to false.
*/
int evb22_conf_gid(char *ifname, enum agent_type type)
{
int value;
value = evb22_conf_int(ifname, type, EVB_CONF_GPID, false,
CONFIG_TYPE_BOOL);
LLDPAD_DBG("%s:%s agent %d policy %s %s\n", __func__,
ifname, type, EVB_CONF_GPID, value ? "true" : "false");
return value;
}
/*
* Read reflective-relay bridge capability parameter. Defaults to false.
*/
int evb22_conf_rrcap(char *ifname, enum agent_type type)
{
int value;
value = evb22_conf_int(ifname, type, EVB_CONF_RRCAP, false,
CONFIG_TYPE_BOOL);
LLDPAD_DBG("%s:%s agent %d policy %s %s\n", __func__,
ifname, type, EVB_CONF_RRCAP, value ? "true" : "false");
return value;
}
/*
* Read reflective-relay station request parameter. Defaults to false.
*/
int evb22_conf_rrreq(char *ifname, enum agent_type type)
{
int value;
value = evb22_conf_int(ifname, type, EVB_CONF_RRREQ, false,
CONFIG_TYPE_BOOL);
LLDPAD_DBG("%s:%s agent %d policy %s %s\n", __func__,
ifname, type, EVB_CONF_RRREQ, value ? "true" : "false");
return value;
}
/*
* Read station/bridge role from configuration file. Defaults to station
*/
int evb22_conf_evbmode(char *ifname, enum agent_type type)
{
int mode = EVB_STATION;
const char *value;
value = evb22_conf_string(ifname, type, EVB_CONF_MODE, mode);
if (value) {
if (!strcasecmp(value, EVB_CONF_BRIDGE))
mode = EVB_BRIDGE;
else if (strcasecmp(value, EVB_CONF_STATION)) {
LLDPAD_ERR("%s:%s agent %d invalid evbmode %s\n",
__func__, ifname, type, value);
value = EVB_CONF_STATION;
}
} else
value = EVB_CONF_STATION;
LLDPAD_DBG("%s:%s agent %d policy %s %s(%#x)\n", __func__,
ifname, type, EVB_CONF_MODE, value, mode);
return mode;
}
/*
* Read transmit status from configuration file.
*/
int evb22_conf_enabletx(char *ifname, enum agent_type type)
{
return is_tlv_txenabled(ifname, type,
TLVID(OUI_IEEE_8021Qbg22, LLDP_EVB22_SUBTYPE));
}
static int evb22_cmdok(struct cmd *cmd, int expected)
{
if (cmd->cmd != expected)
return cmd_invalid;
switch (cmd->tlvid) {
case TLVID(OUI_IEEE_8021Qbg22, LLDP_EVB22_SUBTYPE):
return cmd_success;
case INVALID_TLVID:
return cmd_invalid;
default:
return cmd_not_applicable;
}
}
static int get_arg_evbmode(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
struct evb22_data *ed;
char *s;
cmd_status good_cmd = evb22_cmdok(cmd, cmd_gettlv);
if (good_cmd != cmd_success)
return good_cmd;
ed = evb22_data((char *) &cmd->ifname, cmd->type);
if (!ed)
return cmd_invalid;
if (evb_ex_evbmode(ed->policy.evb_mode) == EVB_STATION)
s = EVB_CONF_STATION;
else
s = EVB_CONF_BRIDGE;
snprintf(obuf, obuf_len, "%02x%s%04x%s",
(unsigned int)strlen(arg), arg, (unsigned int)strlen(s), s);
return cmd_success;
}
static int set2_arg_evbmode(struct cmd *cmd, char *arg, const char *argvalue,
bool test)
{
char arg_path[EVB_BUF_SIZE];
struct evb22_data *ed;
cmd_status good_cmd = evb22_cmdok(cmd, cmd_settlv);
u8 mode;
if (good_cmd != cmd_success)
return good_cmd;
if (strcasecmp(argvalue, EVB_CONF_BRIDGE)
&& strcasecmp(argvalue, EVB_CONF_STATION))
return cmd_bad_params;
ed = evb22_data((char *) &cmd->ifname, cmd->type);
if (!ed)
return cmd_invalid;
if (test)
return cmd_success;
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
TLVID_PREFIX, cmd->tlvid, arg);
if (set_cfg(cmd->ifname, cmd->type, arg_path, &argvalue,
CONFIG_TYPE_STRING)) {
LLDPAD_ERR("%s: error saving EVB mode (%s)\n", ed->ifname,
argvalue);
return cmd_failed;
}
mode = strcasecmp(argvalue, EVB_CONF_BRIDGE) ? EVB_STATION : EVB_BRIDGE;
ed->policy.evb_mode = evb_maskoff_evbmode(ed->policy.evb_mode) |
evb_set_evbmode(mode);
LLDPAD_INFO("%s: changed EVB mode (%s)\n", ed->ifname, argvalue);
return cmd_success;
}
static int set_arg_evbmode(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return set2_arg_evbmode(cmd, arg, argvalue, false);
}
static int test_arg_evbmode(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return set2_arg_evbmode(cmd, arg, argvalue, true);
}
static int get_txmit(struct evb22_data *ed)
{
return ed->txmit;
}
static void set_txmit(struct evb22_data *ed, int value)
{
ed->txmit = value;
}
static int get_gpid(struct evb22_data *ed)
{
int mode = evb_ex_evbmode(ed->policy.evb_mode);
if (mode == EVB_STATION && evb_ex_sgid(ed->policy.station_s))
return 1;
if (mode == EVB_BRIDGE && evb_ex_bgid(ed->policy.bridge_s))
return 1;
return 0;
}
static void set_gpid(struct evb22_data *ed, int value)
{
if (evb_ex_evbmode(ed->policy.evb_mode) == EVB_STATION)
ed->policy.station_s = evb_maskoff_sgid(ed->policy.station_s)
| evb_set_sgid(value);
else
ed->policy.bridge_s = evb_maskoff_bgid(ed->policy.bridge_s)
| evb_set_bgid(value);
}
static void set_rrcap(struct evb22_data *ed, int value)
{
ed->policy.bridge_s = evb_maskoff_rrcap(ed->policy.bridge_s)
| evb_set_rrcap(value);
}
static int get_rrcap(struct evb22_data *ed)
{
return evb_ex_rrcap(ed->policy.bridge_s);
}
static void set_rrreq(struct evb22_data *ed, int value)
{
ed->policy.station_s = evb_maskoff_rrreq(ed->policy.station_s)
| evb_set_rrreq(value);
}
static int get_rrreq(struct evb22_data *ed)
{
return evb_ex_rrreq(ed->policy.station_s);
}
/*
* Read a boolean value from the command line argument and apply the new
* value to parameter.
*/
static int scan_bool(struct cmd *cmd, char *arg, char *argvalue, bool test,
void (*fct)(struct evb22_data *, int))
{
int value;
char arg_path[EVB_BUF_SIZE];
struct evb22_data *ed;
cmd_status good_cmd = evb22_cmdok(cmd, cmd_settlv);
if (good_cmd != cmd_success)
return good_cmd;
if (!strcasecmp(argvalue, VAL_YES))
value = 1;
else if (!strcasecmp(argvalue, VAL_NO))
value = 0;
else
return cmd_bad_params;
ed = evb22_data((char *) &cmd->ifname, cmd->type);
if (!ed)
return cmd_invalid;
if (test)
return cmd_success;
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
TLVID_PREFIX, cmd->tlvid, arg);
if (set_cfg(cmd->ifname, cmd->type, arg_path, &value,
CONFIG_TYPE_BOOL)){
LLDPAD_ERR("%s: error saving EVB enabletx (%s)\n", ed->ifname,
argvalue);
return cmd_failed;
}
LLDPAD_INFO("%s: changed EVB %s (%s)\n", ed->ifname, arg, argvalue);
(*fct)(ed, value);
somethingChangedLocal(cmd->ifname, cmd->type);
return cmd_success;
}
static int show_bool(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len,
int (*fct)(struct evb22_data *))
{
struct evb22_data *ed;
char *s;
cmd_status good_cmd = evb22_cmdok(cmd, cmd_gettlv);
if (good_cmd != cmd_success)
return good_cmd;
ed = evb22_data((char *) &cmd->ifname, cmd->type);
if (!ed)
return cmd_invalid;
if ((*fct)(ed))
s = VAL_YES;
else
s = VAL_NO;
snprintf(obuf, obuf_len, "%02x%s%04x%s",
(unsigned int)strlen(arg), arg, (unsigned int)strlen(s), s);
return cmd_success;
}
static int get_arg_tlvtxenable(struct cmd *cmd, char *arg,
UNUSED char *argvalue, char *obuf, int obuf_len)
{
return show_bool(cmd, arg, argvalue, obuf, obuf_len, get_txmit);
}
static int set_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_bool(cmd, arg, argvalue, false, set_txmit);
}
static int test_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
/*
* Make sure either evb draft 0.2 or evb ratified standard is
* running at the same time but not both.
*/
if (!strcasecmp(argvalue, VAL_YES)
&& is_tlv_txenabled(cmd->ifname, cmd->type,
TLVID(OUI_IEEE_8021Qbg,
LLDP_EVB_SUBTYPE))) {
LLDPAD_ERR("%s:%s evb draft 0.2 protocol already enabled\n",
__func__, cmd->ifname);
return cmd_failed;
}
return scan_bool(cmd, arg, argvalue, true, 0);
}
static int get_arg_gpid(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
return show_bool(cmd, arg, argvalue, obuf, obuf_len, get_gpid);
}
static int set_arg_gpid(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_bool(cmd, arg, argvalue, false, set_gpid);
}
static int test_arg_gpid(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_bool(cmd, arg, argvalue, true, 0);
}
static int get_arg_rrcap(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
return show_bool(cmd, arg, argvalue, obuf, obuf_len, get_rrcap);
}
static int set_arg_rrcap(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_bool(cmd, arg, argvalue, false, set_rrcap);
}
static int test_arg_rrcap(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_bool(cmd, arg, argvalue, true, 0);
}
static int get_arg_rrreq(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
return show_bool(cmd, arg, argvalue, obuf, obuf_len, get_rrreq);
}
static int set_arg_rrreq(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_bool(cmd, arg, argvalue, false, set_rrreq);
}
static int test_arg_rrreq(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_bool(cmd, arg, argvalue, true, 0);
}
static void set_retries(struct evb22_data *ed, int value)
{
ed->policy.r_rte = evb_maskoff_retries(ed->policy.r_rte)
| evb_set_retries(value);
}
static int get_retries(struct evb22_data *ed)
{
return evb_ex_retries(ed->policy.r_rte);
}
static void set_rte(struct evb22_data *ed, int value)
{
ed->policy.r_rte = evb_maskoff_rte(ed->policy.r_rte)
| evb_set_rte(value);
}
static int get_rte(struct evb22_data *ed)
{
return evb_ex_rte(ed->policy.r_rte);
}
static void set_rwd(struct evb22_data *ed, int value)
{
ed->policy.evb_mode = evb_maskoff_rwd(ed->policy.evb_mode)
| evb_set_rwd(value);
}
static int get_rwd(struct evb22_data *ed)
{
return evb_ex_rwd(ed->policy.evb_mode);
}
static void set_rka(struct evb22_data *ed, int value)
{
ed->policy.rl_rka = evb_maskoff_rka(ed->policy.rl_rka)
| evb_set_rka(value);
}
static int get_rka(struct evb22_data *ed)
{
return evb_ex_rka(ed->policy.rl_rka);
}
static int scan_31bit(struct cmd *cmd, char *arg, const char *argvalue,
bool test, void (*fct)(struct evb22_data *, int),
int limit)
{
char arg_path[EVB_BUF_SIZE];
struct evb22_data *ed;
int value;
char *endp;
cmd_status good_cmd = evb22_cmdok(cmd, cmd_settlv);
if (good_cmd != cmd_success)
return good_cmd;
value = strtoul(argvalue, &endp, 0);
if (*endp != '\0' || value > limit)
return cmd_bad_params;
ed = evb22_data((char *) &cmd->ifname, cmd->type);
if (!ed)
return cmd_invalid;
if (test)
return cmd_success;
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
TLVID_PREFIX, cmd->tlvid, arg);
if (set_cfg(ed->ifname, cmd->type, arg_path, &value,
CONFIG_TYPE_INT)){
LLDPAD_ERR("%s: error saving EVB %s (%d)\n", ed->ifname, arg,
value);
return cmd_failed;
}
LLDPAD_INFO("%s: changed EVB %s (%s)\n", ed->ifname, arg, argvalue);
(*fct)(ed, value);
somethingChangedLocal(cmd->ifname, cmd->type);
return cmd_success;
}
static int show_31bit(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len,
int (*fct)(struct evb22_data *))
{
struct evb22_data *ed;
char s[EVB_BUF_SIZE];
cmd_status good_cmd = evb22_cmdok(cmd, cmd_gettlv);
if (good_cmd != cmd_success)
return good_cmd;
ed = evb22_data((char *) &cmd->ifname, cmd->type);
if (!ed)
return cmd_invalid;
if (sprintf(s, "%i", (*fct)(ed)) <= 0)
return cmd_invalid;
snprintf(obuf, obuf_len, "%02x%s%04x%s",
(unsigned int)strlen(arg), arg, (unsigned int)strlen(s), s);
return cmd_success;
}
static int get_arg_retries(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
return show_31bit(cmd, arg, argvalue, obuf, obuf_len, get_retries);
}
static int set_arg_retries(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, false, set_retries, 7);
}
static int test_arg_retries(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, true, 0, 7);
}
static int get_arg_rte(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
return show_31bit(cmd, arg, argvalue, obuf, obuf_len, get_rte);
}
static int set_arg_rte(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, false, set_rte, 31);
}
static int test_arg_rte(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, true, 0, 31);
}
static int get_arg_rwd(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
return show_31bit(cmd, arg, argvalue, obuf, obuf_len, get_rwd);
}
static int set_arg_rwd(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, false, set_rwd, 31);
}
static int test_arg_rwd(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, true, 0, 31);
}
static int get_arg_rka(struct cmd *cmd, char *arg, UNUSED char *argvalue,
char *obuf, int obuf_len)
{
return show_31bit(cmd, arg, argvalue, obuf, obuf_len, get_rka);
}
static int set_arg_rka(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, false, set_rka, 31);
}
static int test_arg_rka(struct cmd *cmd, char *arg, char *argvalue,
UNUSED char *obuf, UNUSED int obuf_len)
{
return scan_31bit(cmd, arg, argvalue, true, 0, 31);
}
static struct arg_handlers arg_handlers[] = {
{
.arg = EVB_CONF_RKA,
.arg_class = TLV_ARG,
.handle_get = get_arg_rka,
.handle_set = set_arg_rka,
.handle_test = test_arg_rka
},
{
.arg = EVB_CONF_RWD,
.arg_class = TLV_ARG,
.handle_get = get_arg_rwd,
.handle_set = set_arg_rwd,
.handle_test = test_arg_rwd
},
{
.arg = EVB_CONF_RTE,
.arg_class = TLV_ARG,
.handle_get = get_arg_rte,
.handle_set = set_arg_rte,
.handle_test = test_arg_rte
},
{
.arg = EVB_CONF_RETRIES,
.arg_class = TLV_ARG,
.handle_get = get_arg_retries,
.handle_set = set_arg_retries,
.handle_test = test_arg_retries
},
{
.arg = EVB_CONF_RRREQ,
.arg_class = TLV_ARG,
.handle_get = get_arg_rrreq,
.handle_set = set_arg_rrreq,
.handle_test = test_arg_rrreq
},
{
.arg = EVB_CONF_RRCAP,
.arg_class = TLV_ARG,
.handle_get = get_arg_rrcap,
.handle_set = set_arg_rrcap,
.handle_test = test_arg_rrcap
},
{
.arg = EVB_CONF_GPID,
.arg_class = TLV_ARG,
.handle_get = get_arg_gpid,
.handle_set = set_arg_gpid,
.handle_test = test_arg_gpid
},
{
.arg = EVB_CONF_MODE,
.arg_class = TLV_ARG,
.handle_get = get_arg_evbmode,
.handle_set = set_arg_evbmode,
.handle_test = test_arg_evbmode
},
{
.arg = ARG_TLVTXENABLE,
.arg_class = TLV_ARG,
.handle_get = get_arg_tlvtxenable,
.handle_set = set_arg_tlvtxenable,
.handle_test = test_arg_tlvtxenable
},
{
.arg = 0
}
};
struct arg_handlers *evb22_get_arg_handlers()
{
return &arg_handlers[0];
}
|