| 41 | |
| 42 | template <bool do_shift = false, bool do_mask = false> |
| 43 | static 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 | |
| 68 | static void CopyFromValue(bess::PacketBatch *batch, const struct Attr *attr, |
| 69 | mt_offset_t mt_off) { |
nothing calls this directly
no test coverage detected