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

Method CommandPopulate

core/modules/l2_forward.cc:707–739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

705}
706
707CommandResponse L2Forward::CommandPopulate(
708 const bess::pb::L2ForwardCommandPopulateArg &arg) {
709 const char *base;
710 char base_str[6] = {0};
711 uint64_t base_u64;
712
713 if (!arg.base().length()) {
714 return CommandFailure(EINVAL, "base must exist in gen, and must be string");
715 }
716
717 // parse base addr
718 base = arg.base().c_str();
719 if (parse_mac_addr(base, base_str) != 0) {
720 return CommandFailure(EINVAL, "%s is not a proper mac address", base_str);
721 }
722
723 base_u64 = l2_addr_to_u64(base_str);
724
725 int cnt = arg.count();
726 int gate_cnt = arg.gate_count();
727
728 base_u64 = bess::utils::be64_t::swap(base_u64) >> 16;
729 base_u64 = base_u64 >> 16;
730
731 for (int i = 0; i < cnt; i++) {
732 l2_add_entry(&l2_table_, bess::utils::be64_t::swap(base_u64 << 16),
733 i % gate_cnt);
734
735 base_u64++;
736 }
737
738 return CommandSuccess();
739}
740
741ADD_MODULE(L2Forward, "l2_forward",
742 "classifies packets with destination MAC address")

Callers

nothing calls this directly

Calls 5

CommandFailureFunction · 0.85
parse_mac_addrFunction · 0.85
l2_addr_to_u64Function · 0.85
l2_add_entryFunction · 0.85
CommandSuccessFunction · 0.85

Tested by

no test coverage detected