xref: /kvmtool/net/uip/arp.c (revision 42a6c572af1499be7a43780144e35432e6bdeb09)
1 #include "kvm/uip.h"
2 
uip_tx_do_arp(struct uip_tx_arg * arg)3 int uip_tx_do_arp(struct uip_tx_arg *arg)
4 {
5 	struct uip_arp *arp, *arp2;
6 	struct uip_info *info;
7 	struct uip_buf *buf;
8 
9 	info = arg->info;
10 	buf = uip_buf_clone(arg);
11 
12 	arp	 = (struct uip_arp *)(arg->eth);
13 	arp2	 = (struct uip_arp *)(buf->eth);
14 
15 	/*
16 	 * ARP replay code: 2
17 	 */
18 	arp2->op   = htons(0x2);
19 	arp2->dmac = arp->smac;
20 	arp2->dip  = arp->sip;
21 
22 	if (arp->dip == htonl(info->host_ip)) {
23 		arp2->smac = info->host_mac;
24 		arp2->sip = htonl(info->host_ip);
25 
26 		uip_buf_set_used(info, buf);
27 	}
28 
29 	return 0;
30 }
31