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

Method CommandLookup

core/modules/l2_forward.cc:675–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

673}
674
675CommandResponse L2Forward::CommandLookup(
676 const bess::pb::L2ForwardCommandLookupArg &arg) {
677 bess::pb::L2ForwardCommandLookupResponse ret;
678 for (int i = 0; i < arg.addrs_size(); i++) {
679 const auto &_addr = arg.addrs(i);
680
681 if (!_addr.length()) {
682 return CommandFailure(EINVAL, "lookup must be list of string");
683 }
684
685 const char *str_addr = _addr.c_str();
686 char addr[6];
687
688 if (parse_mac_addr(str_addr, addr) != 0) {
689 return CommandFailure(EINVAL, "%s is not a proper mac address", str_addr);
690 }
691
692 gate_idx_t gate;
693 int r = l2_find(&l2_table_, l2_addr_to_u64(addr), &gate);
694
695 if (r == -ENOENT) {
696 return CommandFailure(ENOENT, "MAC address '%s' does not exist",
697 str_addr);
698 } else if (r != 0) {
699 return CommandFailure(EINVAL, "Unknown Error: %d\n", r);
700 }
701 ret.add_gates(gate);
702 }
703
704 return CommandSuccess(ret);
705}
706
707CommandResponse L2Forward::CommandPopulate(
708 const bess::pb::L2ForwardCommandPopulateArg &arg) {

Callers

nothing calls this directly

Calls 5

CommandFailureFunction · 0.85
parse_mac_addrFunction · 0.85
l2_findFunction · 0.85
l2_addr_to_u64Function · 0.85
CommandSuccessFunction · 0.85

Tested by

no test coverage detected