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

Function CopyFromPacket

core/modules/set_metadata.cc:43–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42template <bool do_shift = false, bool do_mask = false>
43static void CopyFromPacket(bess::PacketBatch *batch, const struct Attr *attr,
44 mt_offset_t mt_off) {
45 int cnt = batch->cnt();
46 int size = attr->size;
47 int shift = attr->shift;
48 int pkt_off = attr->offset;
49
50 for (int i = 0; i < cnt; i++) {
51 bess::Packet *pkt = batch->pkts()[i];
52 uint8_t *head = pkt->head_data<uint8_t *>(pkt_off);
53 uint8_t *mt_ptr = _ptr_attr_with_offset<uint8_t>(mt_off, pkt);
54 bess::utils::CopySmall(mt_ptr, head, size);
55 if (do_shift) {
56 if (shift > 0) {
57 bess::utils::ShiftBytesRight(mt_ptr, size, shift);
58 } else {
59 bess::utils::ShiftBytesLeft(mt_ptr, size, -shift);
60 }
61 }
62 if (do_mask) {
63 bess::utils::MaskBytes(mt_ptr, attr->mask.bytes, size);
64 }
65 }
66}
67
68static void CopyFromValue(bess::PacketBatch *batch, const struct Attr *attr,
69 mt_offset_t mt_off) {

Callers

nothing calls this directly

Calls 6

CopySmallFunction · 0.85
ShiftBytesRightFunction · 0.85
ShiftBytesLeftFunction · 0.85
MaskBytesFunction · 0.85
cntMethod · 0.45
pktsMethod · 0.45

Tested by

no test coverage detected