| 107 | } |
| 108 | |
| 109 | int PCAPPort::SendPackets(queue_t, bess::Packet** pkts, int cnt) { |
| 110 | if (!pcap_handle_.is_initialized()) { |
| 111 | CHECK(0); // raise an error |
| 112 | } |
| 113 | |
| 114 | int sent = 0; |
| 115 | |
| 116 | while (sent < cnt) { |
| 117 | bess::Packet* sbuf = pkts[sent]; |
| 118 | |
| 119 | if (likely(sbuf->nb_segs() == 1)) { |
| 120 | pcap_handle_.SendPacket(sbuf->head_data<const u_char*>(), |
| 121 | sbuf->total_len()); |
| 122 | } else if (sbuf->total_len() <= PCAP_SNAPLEN) { |
| 123 | unsigned char tx_pcap_data[PCAP_SNAPLEN]; |
| 124 | GatherData(tx_pcap_data, sbuf); |
| 125 | pcap_handle_.SendPacket(tx_pcap_data, sbuf->total_len()); |
| 126 | } |
| 127 | |
| 128 | sent++; |
| 129 | } |
| 130 | |
| 131 | bess::Packet::Free(pkts, sent); |
| 132 | return sent; |
| 133 | } |
| 134 | |
| 135 | void PCAPPort::GatherData(unsigned char* data, bess::Packet* pkt) { |
| 136 | while (pkt) { |
nothing calls this directly
no test coverage detected