| 638 | } |
| 639 | |
| 640 | CommandResponse L2Forward::CommandDelete( |
| 641 | const bess::pb::L2ForwardCommandDeleteArg &arg) { |
| 642 | for (int i = 0; i < arg.addrs_size(); i++) { |
| 643 | const auto &_addr = arg.addrs(i); |
| 644 | |
| 645 | if (!_addr.length()) { |
| 646 | return CommandFailure(EINVAL, "lookup must be list of string"); |
| 647 | } |
| 648 | |
| 649 | const char *str_addr = _addr.c_str(); |
| 650 | char addr[6]; |
| 651 | |
| 652 | if (parse_mac_addr(str_addr, addr) != 0) { |
| 653 | return CommandFailure(EINVAL, "%s is not a proper mac address", str_addr); |
| 654 | } |
| 655 | |
| 656 | int r = l2_del_entry(&l2_table_, l2_addr_to_u64(addr)); |
| 657 | |
| 658 | if (r == -ENOENT) { |
| 659 | return CommandFailure(ENOENT, "MAC address '%s' does not exist", |
| 660 | str_addr); |
| 661 | } else if (r != 0) { |
| 662 | return CommandFailure(EINVAL, "Unknown Error: %d\n", r); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | return CommandSuccess(); |
| 667 | } |
| 668 | |
| 669 | CommandResponse L2Forward::CommandSetDefaultGate( |
| 670 | const bess::pb::L2ForwardCommandSetDefaultGateArg &arg) { |
nothing calls this directly
no test coverage detected