MCPcopy Create free account
hub / github.com/NetSys/bess / CommandAdd

Method CommandAdd

core/modules/l2_forward.cc:608–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608CommandResponse L2Forward::CommandAdd(
609 const bess::pb::L2ForwardCommandAddArg &arg) {
610 for (int i = 0; i < arg.entries_size(); i++) {
611 const auto &entry = arg.entries(i);
612
613 if (!entry.addr().length()) {
614 return CommandFailure(EINVAL,
615 "add list item map must contain addr as a string");
616 }
617
618 const char *str_addr = entry.addr().c_str();
619 int gate = entry.gate();
620 char addr[6];
621
622 if (parse_mac_addr(str_addr, addr) != 0) {
623 return CommandFailure(EINVAL, "%s is not a proper mac address", str_addr);
624 }
625
626 int r = l2_add_entry(&l2_table_, l2_addr_to_u64(addr), gate);
627
628 if (r == -EEXIST) {
629 return CommandFailure(EEXIST, "MAC address '%s' already exist", str_addr);
630 } else if (r == -ENOMEM) {
631 return CommandFailure(ENOMEM, "Not enough space");
632 } else if (r != 0) {
633 return CommandFailure(-r);
634 }
635 }
636
637 return CommandSuccess();
638}
639
640CommandResponse L2Forward::CommandDelete(
641 const bess::pb::L2ForwardCommandDeleteArg &arg) {

Callers

nothing calls this directly

Calls 6

CommandFailureFunction · 0.85
parse_mac_addrFunction · 0.85
l2_add_entryFunction · 0.85
l2_addr_to_u64Function · 0.85
CommandSuccessFunction · 0.85
gateMethod · 0.80

Tested by

no test coverage detected