Revision cda9046b net.c
b/net.c | ||
---|---|---|
332 | 332 |
VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
333 | 333 |
const char *model, |
334 | 334 |
const char *name, |
335 |
IOCanRWHandler *fd_can_read,
|
|
336 |
IOReadHandler *fd_read,
|
|
337 |
IOReadvHandler *fd_readv,
|
|
335 |
NetCanReceive *can_receive,
|
|
336 |
NetReceive *receive,
|
|
337 |
NetReceiveIOV *receive_iov,
|
|
338 | 338 |
NetCleanup *cleanup, |
339 | 339 |
void *opaque) |
340 | 340 |
{ |
... | ... | |
345 | 345 |
vc->name = strdup(name); |
346 | 346 |
else |
347 | 347 |
vc->name = assign_name(vc, model); |
348 |
vc->fd_can_read = fd_can_read;
|
|
349 |
vc->fd_read = fd_read;
|
|
350 |
vc->fd_readv = fd_readv;
|
|
348 |
vc->can_receive = can_receive;
|
|
349 |
vc->receive = receive;
|
|
350 |
vc->receive_iov = receive_iov;
|
|
351 | 351 |
vc->cleanup = cleanup; |
352 | 352 |
vc->opaque = opaque; |
353 | 353 |
vc->vlan = vlan; |
... | ... | |
401 | 401 |
continue; |
402 | 402 |
} |
403 | 403 |
|
404 |
/* no fd_can_read() handler, they can always receive */
|
|
405 |
if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) {
|
|
404 |
/* no can_receive() handler, they can always receive */
|
|
405 |
if (!vc->can_receive || vc->can_receive(vc->opaque)) {
|
|
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->fd_read(vc->opaque, buf, size);
|
|
419 |
vc->receive(vc->opaque, buf, size);
|
|
420 | 420 |
} |
421 | 421 |
} |
422 | 422 |
} |
... | ... | |
467 | 467 |
offset += len; |
468 | 468 |
} |
469 | 469 |
|
470 |
vc->fd_read(vc->opaque, buffer, offset);
|
|
470 |
vc->receive(vc->opaque, buffer, offset);
|
|
471 | 471 |
|
472 | 472 |
return offset; |
473 | 473 |
} |
... | ... | |
519 | 519 |
} |
520 | 520 |
if (vc->link_down) { |
521 | 521 |
len = calc_iov_length(iov, iovcnt); |
522 |
} else if (vc->fd_readv) {
|
|
523 |
len = vc->fd_readv(vc->opaque, iov, iovcnt);
|
|
524 |
} else if (vc->fd_read) {
|
|
522 |
} else if (vc->receive_iov) {
|
|
523 |
len = vc->receive_iov(vc->opaque, iov, iovcnt);
|
|
524 |
} else if (vc->receive) {
|
|
525 | 525 |
len = vc_sendv_compat(vc, iov, iovcnt); |
526 | 526 |
} |
527 | 527 |
max_len = MAX(max_len, len); |
... | ... | |
593 | 593 |
return slirp_inited; |
594 | 594 |
} |
595 | 595 |
|
596 |
static void slirp_receive(void *opaque, const uint8_t *buf, int size)
|
|
596 |
static void slirp_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
597 | 597 |
{ |
598 | 598 |
#ifdef DEBUG_SLIRP |
599 | 599 |
printf("slirp input:\n"); |
... | ... | |
945 | 945 |
return len; |
946 | 946 |
} |
947 | 947 |
|
948 |
static void tap_receive(void *opaque, const uint8_t *buf, int size)
|
|
948 |
static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
949 | 949 |
{ |
950 | 950 |
TAPState *s = opaque; |
951 | 951 |
int ret; |
... | ... | |
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, int size)
|
|
1383 |
static void net_socket_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
1384 | 1384 |
{ |
1385 | 1385 |
NetSocketState *s = opaque; |
1386 | 1386 |
uint32_t len; |
... | ... | |
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, int size)
|
|
1393 |
static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, size_t size)
|
|
1394 | 1394 |
{ |
1395 | 1395 |
NetSocketState *s = opaque; |
1396 | 1396 |
sendto(s->fd, buf, size, 0, |
... | ... | |
1831 | 1831 |
uint32_t len; |
1832 | 1832 |
}; |
1833 | 1833 |
|
1834 |
static void dump_receive(void *opaque, const uint8_t *buf, int size)
|
|
1834 |
static void dump_receive(void *opaque, const uint8_t *buf, size_t size)
|
|
1835 | 1835 |
{ |
1836 | 1836 |
DumpState *s = opaque; |
1837 | 1837 |
struct pcap_sf_pkthdr hdr; |
Also available in: Unified diff