Revision e3f5ec2b net.c
b/net.c | ||
---|---|---|
402 | 402 |
} |
403 | 403 |
|
404 | 404 |
/* no can_receive() handler, they can always receive */ |
405 |
if (!vc->can_receive || vc->can_receive(vc->opaque)) {
|
|
405 |
if (!vc->can_receive || vc->can_receive(vc)) { |
|
406 | 406 |
return 1; |
407 | 407 |
} |
408 | 408 |
} |
... | ... | |
416 | 416 |
|
417 | 417 |
for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) { |
418 | 418 |
if (vc != sender && !vc->link_down) { |
419 |
vc->receive(vc->opaque, buf, size);
|
|
419 |
vc->receive(vc, buf, size); |
|
420 | 420 |
} |
421 | 421 |
} |
422 | 422 |
} |
... | ... | |
467 | 467 |
offset += len; |
468 | 468 |
} |
469 | 469 |
|
470 |
vc->receive(vc->opaque, buffer, offset);
|
|
470 |
vc->receive(vc, buffer, offset); |
|
471 | 471 |
|
472 | 472 |
return offset; |
473 | 473 |
} |
... | ... | |
520 | 520 |
if (vc->link_down) { |
521 | 521 |
len = calc_iov_length(iov, iovcnt); |
522 | 522 |
} else if (vc->receive_iov) { |
523 |
len = vc->receive_iov(vc->opaque, iov, iovcnt);
|
|
523 |
len = vc->receive_iov(vc, iov, iovcnt); |
|
524 | 524 |
} else if (vc->receive) { |
525 | 525 |
len = vc_sendv_compat(vc, iov, iovcnt); |
526 | 526 |
} |
... | ... | |
593 | 593 |
return slirp_inited; |
594 | 594 |
} |
595 | 595 |
|
596 |
static void slirp_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
596 |
static void slirp_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
|
597 | 597 |
{ |
598 | 598 |
#ifdef DEBUG_SLIRP |
599 | 599 |
printf("slirp input:\n"); |
... | ... | |
932 | 932 |
|
933 | 933 |
static int launch_script(const char *setup_script, const char *ifname, int fd); |
934 | 934 |
|
935 |
static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov,
|
|
935 |
static ssize_t tap_receive_iov(VLANClientState *vc, const struct iovec *iov,
|
|
936 | 936 |
int iovcnt) |
937 | 937 |
{ |
938 |
TAPState *s = opaque; |
|
938 |
TAPState *s = vc->opaque;
|
|
939 | 939 |
ssize_t len; |
940 | 940 |
|
941 | 941 |
do { |
... | ... | |
945 | 945 |
return len; |
946 | 946 |
} |
947 | 947 |
|
948 |
static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
948 |
static void tap_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
|
949 | 949 |
{ |
950 |
TAPState *s = opaque; |
|
950 |
TAPState *s = vc->opaque;
|
|
951 | 951 |
int ret; |
952 | 952 |
for(;;) { |
953 | 953 |
ret = write(s->fd, buf, size); |
... | ... | |
1311 | 1311 |
} |
1312 | 1312 |
} |
1313 | 1313 |
|
1314 |
static void vde_from_qemu(void *opaque, const uint8_t *buf, int size)
|
|
1314 |
static void vde_receive(VLANClientState *vc, const uint8_t *buf, int size)
|
|
1315 | 1315 |
{ |
1316 |
VDEState *s = opaque; |
|
1316 |
VDEState *s = vc->opaque;
|
|
1317 | 1317 |
int ret; |
1318 | 1318 |
for(;;) { |
1319 | 1319 |
ret = vde_send(s->vde, (const char *)buf, size, 0); |
... | ... | |
1352 | 1352 |
free(s); |
1353 | 1353 |
return -1; |
1354 | 1354 |
} |
1355 |
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_from_qemu,
|
|
1355 |
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_receive,
|
|
1356 | 1356 |
NULL, vde_cleanup, s); |
1357 | 1357 |
qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s); |
1358 | 1358 |
snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d", |
... | ... | |
1380 | 1380 |
} NetSocketListenState; |
1381 | 1381 |
|
1382 | 1382 |
/* XXX: we consider we can send the whole packet without blocking */ |
1383 |
static void net_socket_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
1383 |
static void net_socket_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
|
1384 | 1384 |
{ |
1385 |
NetSocketState *s = opaque; |
|
1385 |
NetSocketState *s = vc->opaque;
|
|
1386 | 1386 |
uint32_t len; |
1387 | 1387 |
len = htonl(size); |
1388 | 1388 |
|
... | ... | |
1390 | 1390 |
send_all(s->fd, buf, size); |
1391 | 1391 |
} |
1392 | 1392 |
|
1393 |
static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, size_t size)
|
|
1393 |
static void net_socket_receive_dgram(VLANClientState *vc, const uint8_t *buf, size_t size)
|
|
1394 | 1394 |
{ |
1395 |
NetSocketState *s = opaque; |
|
1395 |
NetSocketState *s = vc->opaque;
|
|
1396 | 1396 |
sendto(s->fd, buf, size, 0, |
1397 | 1397 |
(struct sockaddr *)&s->dgram_dst, sizeof(s->dgram_dst)); |
1398 | 1398 |
} |
... | ... | |
1831 | 1831 |
uint32_t len; |
1832 | 1832 |
}; |
1833 | 1833 |
|
1834 |
static void dump_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
1834 |
static void dump_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
|
|
1835 | 1835 |
{ |
1836 |
DumpState *s = opaque; |
|
1836 |
DumpState *s = vc->opaque;
|
|
1837 | 1837 |
struct pcap_sf_pkthdr hdr; |
1838 | 1838 |
int64_t ts; |
1839 | 1839 |
int caplen; |
Also available in: Unified diff