Revision 18995b98
b/savevm.c | ||
---|---|---|
96 | 96 |
static BlockDriverState *bs_snapshots; |
97 | 97 |
|
98 | 98 |
#define SELF_ANNOUNCE_ROUNDS 5 |
99 |
#define ETH_P_EXPERIMENTAL 0x01F1 /* just a number */ |
|
100 |
//#define ETH_P_EXPERIMENTAL 0x0012 /* make it the size of the packet */ |
|
101 |
#define EXPERIMENTAL_MAGIC 0xf1f23f4f |
|
102 | 99 |
|
103 |
static int announce_self_create(uint8_t *buf, |
|
100 |
#ifndef ETH_P_RARP |
|
101 |
#define ETH_P_RARP 0x0835 |
|
102 |
#endif |
|
103 |
#define ARP_HTYPE_ETH 0x0001 |
|
104 |
#define ARP_PTYPE_IP 0x0800 |
|
105 |
#define ARP_OP_REQUEST_REV 0x3 |
|
106 |
|
|
107 |
static int announce_self_create(uint8_t *buf, |
|
104 | 108 |
uint8_t *mac_addr) |
105 | 109 |
{ |
106 |
uint32_t magic = EXPERIMENTAL_MAGIC; |
|
107 |
uint16_t proto = htons(ETH_P_EXPERIMENTAL); |
|
110 |
/* Ethernet header. */ |
|
111 |
memset(buf, 0xff, 6); /* destination MAC addr */ |
|
112 |
memcpy(buf + 6, mac_addr, 6); /* source MAC addr */ |
|
113 |
*(uint16_t *)(buf + 12) = htons(ETH_P_RARP); /* ethertype */ |
|
108 | 114 |
|
109 |
/* FIXME: should we send a different packet (arp/rarp/ping)? */ |
|
115 |
/* RARP header. */ |
|
116 |
*(uint16_t *)(buf + 14) = htons(ARP_HTYPE_ETH); /* hardware addr space */ |
|
117 |
*(uint16_t *)(buf + 16) = htons(ARP_PTYPE_IP); /* protocol addr space */ |
|
118 |
*(buf + 18) = 6; /* hardware addr length (ethernet) */ |
|
119 |
*(buf + 19) = 4; /* protocol addr length (IPv4) */ |
|
120 |
*(uint16_t *)(buf + 20) = htons(ARP_OP_REQUEST_REV); /* opcode */ |
|
121 |
memcpy(buf + 22, mac_addr, 6); /* source hw addr */ |
|
122 |
memset(buf + 28, 0x00, 4); /* source protocol addr */ |
|
123 |
memcpy(buf + 32, mac_addr, 6); /* target hw addr */ |
|
124 |
memset(buf + 38, 0x00, 4); /* target protocol addr */ |
|
110 | 125 |
|
111 |
memset(buf, 0, 64); |
|
112 |
memset(buf, 0xff, 6); /* h_dst */ |
|
113 |
memcpy(buf + 6, mac_addr, 6); /* h_src */ |
|
114 |
memcpy(buf + 12, &proto, 2); /* h_proto */ |
|
115 |
memcpy(buf + 14, &magic, 4); /* magic */ |
|
126 |
/* Padding to get up to 60 bytes (ethernet min packet size, minus FCS). */ |
|
127 |
memset(buf + 42, 0x00, 18); |
|
116 | 128 |
|
117 |
return 64; /* len */
|
|
129 |
return 60; /* len (FCS will be added by hardware) */
|
|
118 | 130 |
} |
119 | 131 |
|
120 | 132 |
static void qemu_announce_self_once(void *opaque) |
... | ... | |
122 | 134 |
int i, len; |
123 | 135 |
VLANState *vlan; |
124 | 136 |
VLANClientState *vc; |
125 |
uint8_t buf[256];
|
|
137 |
uint8_t buf[60];
|
|
126 | 138 |
static int count = SELF_ANNOUNCE_ROUNDS; |
127 | 139 |
QEMUTimer *timer = *(QEMUTimer **)opaque; |
128 | 140 |
|
... | ... | |
135 | 147 |
vc->receive(vc, buf, len); |
136 | 148 |
} |
137 | 149 |
} |
138 |
if (count--) { |
|
139 |
qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100); |
|
150 |
if (--count) { |
|
151 |
/* delay 50ms, 150ms, 250ms, ... */ |
|
152 |
qemu_mod_timer(timer, qemu_get_clock(rt_clock) + |
|
153 |
50 + (SELF_ANNOUNCE_ROUNDS - count - 1) * 100); |
|
140 | 154 |
} else { |
141 | 155 |
qemu_del_timer(timer); |
142 | 156 |
qemu_free_timer(timer); |
Also available in: Unified diff