View | Details | Raw Unified | Return to bug 187149 | Differences between
and this patch

Collapse All | Expand All

(-)tools/tools/netmap/pkt-gen.c (+20 lines)
Lines 546-551 Link Here
546
{
546
{
547
	uint32_t a;
547
	uint32_t a;
548
	uint16_t p;
548
	uint16_t p;
549
	struct ether_header *eh = &pkt->eh;
549
	struct ip *ip = &pkt->ip;
550
	struct ip *ip = &pkt->ip;
550
	struct udphdr *udp = &pkt->udp;
551
	struct udphdr *udp = &pkt->udp;
551
552
Lines 580-585 Link Here
580
	ip->ip_dst.s_addr = htonl(g->dst_ip.start);
581
	ip->ip_dst.s_addr = htonl(g->dst_ip.start);
581
    } while (0);
582
    } while (0);
582
    // update checksum
583
    // update checksum
584
	/* Missing code here ? the comment "update checksum" should be followed
585
	 * by updating IP & UDP checksum. I will try to fix by simply copy/past
586
	 * checksum code from initialize_packet function */
587
588
	ip->ip_sum = 0;
589
	ip->ip_sum = wrapsum(checksum(ip, sizeof(*ip), 0));
590
591
	/* UDP checksum */
592
	uint16_t paylen = g->pkt_size - sizeof(*eh) - sizeof(struct ip);
593
	udp->uh_sum = 0;
594
	udp->uh_sum = wrapsum(checksum(udp, sizeof(*udp),
595
                    checksum(pkt->body,
596
                        paylen - sizeof(*udp),
597
                        checksum(&ip->ip_src, 2 * sizeof(ip->ip_src),
598
                            IPPROTO_UDP + (u_int32_t)ntohs(udp->uh_ulen)
599
                        )
600
                    )
601
                ));
602
583
}
603
}
584
604
585
/*
605
/*

Return to bug 187149