| 291 | } |
| 292 | |
| 293 | DRR::FlowId DRR::GetId(bess::Packet *pkt) { |
| 294 | using bess::utils::Ethernet; |
| 295 | using bess::utils::Ipv4; |
| 296 | using bess::utils::Udp; |
| 297 | |
| 298 | Ethernet *eth = pkt->head_data<Ethernet *>(); |
| 299 | Ipv4 *ip = reinterpret_cast<Ipv4 *>(eth + 1); |
| 300 | size_t ip_bytes = ip->header_length << 2; |
| 301 | Udp *udp = reinterpret_cast<Udp *>(reinterpret_cast<uint8_t *>(ip) + |
| 302 | ip_bytes); // Assumes a l-4 header |
| 303 | // TODO(joshua): handle packet fragmentation |
| 304 | FlowId id = {ip->src.value(), ip->dst.value(), udp->src_port.value(), |
| 305 | udp->dst_port.value(), ip->protocol}; |
| 306 | return id; |
| 307 | } |
| 308 | |
| 309 | void DRR::AddNewFlow(bess::Packet *pkt, FlowId id, int *err) { |
| 310 | // creates flow |