コード例 #1
0
static struct mbuf *
fill_packet(int proto)
{
	struct mbuf *m;
	struct ip *ip;
	struct tcphdr *th;

	m = mbuf_construct(IPPROTO_TCP);
	th = mbuf_return_hdrs(m, false, &ip);
	ip->ip_src.s_addr = inet_addr("192.168.2.100");
	ip->ip_dst.s_addr = inet_addr("10.0.0.1");
	th->th_sport = htons(15000);
	th->th_dport = htons(80);
	return m;
}
コード例 #2
0
ファイル: npf_perf_test.c プロジェクト: ryo/netbsd-src
static struct mbuf *
fill_packet(unsigned i)
{
	struct mbuf *m;
	struct ip *ip;
	struct udphdr *uh;
	char buf[32];

	m = mbuf_construct(IPPROTO_UDP);
	uh = mbuf_return_hdrs(m, false, &ip);

	snprintf(buf, sizeof(buf), "192.0.2.%u", i + i);
	ip->ip_src.s_addr = inet_addr(PUB_IP1);
	ip->ip_dst.s_addr = inet_addr(stateful ? LOCAL_IP2 : LOCAL_IP3);
	uh->uh_sport = htons(80);
	uh->uh_dport = htons(15000 + i);
	return m;
}