bundle.c (134789) | bundle.c (134833) |
---|---|
1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/ppp/bundle.c 134789 2004-09-05 01:46:52Z brian $ | 26 * $FreeBSD: head/usr.sbin/ppp/bundle.c 134833 2004-09-06 00:07:58Z marcel $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <net/if.h> 33#include <net/if_tun.h> /* For TUNS* ioctls */ 34#include <net/route.h> --- 1385 unchanged lines hidden (view full) --- 1420 1421 log_Printf(LogDEBUG, "Expecting %u scatter/gather bytes\n", 1422 (unsigned)iov[0].iov_len); 1423 1424 if ((got = recvmsg(s, &msg, MSG_WAITALL)) != (ssize_t)iov[0].iov_len) { 1425 if (got == -1) 1426 log_Printf(LogERROR, "Failed recvmsg: %s\n", strerror(errno)); 1427 else | 27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <net/if.h> 33#include <net/if_tun.h> /* For TUNS* ioctls */ 34#include <net/route.h> --- 1385 unchanged lines hidden (view full) --- 1420 1421 log_Printf(LogDEBUG, "Expecting %u scatter/gather bytes\n", 1422 (unsigned)iov[0].iov_len); 1423 1424 if ((got = recvmsg(s, &msg, MSG_WAITALL)) != (ssize_t)iov[0].iov_len) { 1425 if (got == -1) 1426 log_Printf(LogERROR, "Failed recvmsg: %s\n", strerror(errno)); 1427 else |
1428 log_Printf(LogERROR, "Failed recvmsg: Got %d, not %u\n", | 1428 log_Printf(LogERROR, "Failed recvmsg: Got %zd, not %u\n", |
1429 got, (unsigned)iov[0].iov_len); 1430 while (niov--) 1431 free(iov[niov].iov_base); 1432 return; 1433 } 1434 1435 if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { 1436 log_Printf(LogERROR, "Recvmsg: no descriptors received !\n"); --- 36 unchanged lines hidden (view full) --- 1473 * they can transfer lock ownership, and wait for them to send the 1474 * actual link data. 1475 */ 1476 pid = getpid(); 1477 if ((got = write(fd[1], &pid, sizeof pid)) != sizeof pid) { 1478 if (got == -1) 1479 log_Printf(LogERROR, "Failed write: %s\n", strerror(errno)); 1480 else | 1429 got, (unsigned)iov[0].iov_len); 1430 while (niov--) 1431 free(iov[niov].iov_base); 1432 return; 1433 } 1434 1435 if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { 1436 log_Printf(LogERROR, "Recvmsg: no descriptors received !\n"); --- 36 unchanged lines hidden (view full) --- 1473 * they can transfer lock ownership, and wait for them to send the 1474 * actual link data. 1475 */ 1476 pid = getpid(); 1477 if ((got = write(fd[1], &pid, sizeof pid)) != sizeof pid) { 1478 if (got == -1) 1479 log_Printf(LogERROR, "Failed write: %s\n", strerror(errno)); 1480 else |
1481 log_Printf(LogERROR, "Failed write: Got %d, not %d\n", got, | 1481 log_Printf(LogERROR, "Failed write: Got %zd, not %d\n", got, |
1482 (int)(sizeof pid)); 1483 while (nfd--) 1484 close(fd[nfd]); 1485 while (niov--) 1486 free(iov[niov].iov_base); 1487 return; 1488 } 1489 1490 if ((got = readv(fd[1], iov + 1, niov - 1)) != expect) { 1491 if (got == -1) 1492 log_Printf(LogERROR, "Failed write: %s\n", strerror(errno)); 1493 else | 1482 (int)(sizeof pid)); 1483 while (nfd--) 1484 close(fd[nfd]); 1485 while (niov--) 1486 free(iov[niov].iov_base); 1487 return; 1488 } 1489 1490 if ((got = readv(fd[1], iov + 1, niov - 1)) != expect) { 1491 if (got == -1) 1492 log_Printf(LogERROR, "Failed write: %s\n", strerror(errno)); 1493 else |
1494 log_Printf(LogERROR, "Failed write: Got %d, not %d\n", got, expect); | 1494 log_Printf(LogERROR, "Failed write: Got %zd, not %d\n", got, expect); |
1495 while (nfd--) 1496 close(fd[nfd]); 1497 while (niov--) 1498 free(iov[niov].iov_base); 1499 return; 1500 } 1501 close(fd[1]); 1502 --- 104 unchanged lines hidden (view full) --- 1607 log_Printf(LogDEBUG, "Sending %d descriptor%s and %u bytes in scatter" 1608 "/gather array\n", nfd, nfd == 1 ? "" : "s", 1609 (unsigned)iov[0].iov_len); 1610 1611 if ((got = sendmsg(s, &msg, 0)) == -1) 1612 log_Printf(LogERROR, "Failed sendmsg: %s: %s\n", 1613 sun->sun_path, strerror(errno)); 1614 else if (got != (ssize_t)iov[0].iov_len) | 1495 while (nfd--) 1496 close(fd[nfd]); 1497 while (niov--) 1498 free(iov[niov].iov_base); 1499 return; 1500 } 1501 close(fd[1]); 1502 --- 104 unchanged lines hidden (view full) --- 1607 log_Printf(LogDEBUG, "Sending %d descriptor%s and %u bytes in scatter" 1608 "/gather array\n", nfd, nfd == 1 ? "" : "s", 1609 (unsigned)iov[0].iov_len); 1610 1611 if ((got = sendmsg(s, &msg, 0)) == -1) 1612 log_Printf(LogERROR, "Failed sendmsg: %s: %s\n", 1613 sun->sun_path, strerror(errno)); 1614 else if (got != (ssize_t)iov[0].iov_len) |
1615 log_Printf(LogERROR, "%s: Failed initial sendmsg: Only sent %d of %u\n", | 1615 log_Printf(LogERROR, "%s: Failed initial sendmsg: Only sent %zd of %u\n", |
1616 sun->sun_path, got, (unsigned)iov[0].iov_len); 1617 else { 1618 /* We must get the ACK before closing the descriptor ! */ 1619 int res; 1620 1621 if ((got = read(reply[0], &newpid, sizeof newpid)) == sizeof newpid) { 1622 log_Printf(LogDEBUG, "Received confirmation from pid %ld\n", 1623 (long)newpid); 1624 if (lock && (res = ID0uu_lock_txfr(lock, newpid)) != UU_LOCK_OK) 1625 log_Printf(LogERROR, "uu_lock_txfr: %s\n", uu_lockerr(res)); 1626 1627 log_Printf(LogDEBUG, "Transmitting link (%d bytes)\n", expect); 1628 if ((got = writev(reply[0], iov + 1, niov - 1)) != expect) { 1629 if (got == -1) 1630 log_Printf(LogERROR, "%s: Failed writev: %s\n", 1631 sun->sun_path, strerror(errno)); 1632 else | 1616 sun->sun_path, got, (unsigned)iov[0].iov_len); 1617 else { 1618 /* We must get the ACK before closing the descriptor ! */ 1619 int res; 1620 1621 if ((got = read(reply[0], &newpid, sizeof newpid)) == sizeof newpid) { 1622 log_Printf(LogDEBUG, "Received confirmation from pid %ld\n", 1623 (long)newpid); 1624 if (lock && (res = ID0uu_lock_txfr(lock, newpid)) != UU_LOCK_OK) 1625 log_Printf(LogERROR, "uu_lock_txfr: %s\n", uu_lockerr(res)); 1626 1627 log_Printf(LogDEBUG, "Transmitting link (%d bytes)\n", expect); 1628 if ((got = writev(reply[0], iov + 1, niov - 1)) != expect) { 1629 if (got == -1) 1630 log_Printf(LogERROR, "%s: Failed writev: %s\n", 1631 sun->sun_path, strerror(errno)); 1632 else |
1633 log_Printf(LogERROR, "%s: Failed writev: Wrote %d of %d\n", | 1633 log_Printf(LogERROR, "%s: Failed writev: Wrote %zd of %d\n", |
1634 sun->sun_path, got, expect); 1635 } 1636 } else if (got == -1) 1637 log_Printf(LogERROR, "%s: Failed socketpair read: %s\n", 1638 sun->sun_path, strerror(errno)); 1639 else | 1634 sun->sun_path, got, expect); 1635 } 1636 } else if (got == -1) 1637 log_Printf(LogERROR, "%s: Failed socketpair read: %s\n", 1638 sun->sun_path, strerror(errno)); 1639 else |
1640 log_Printf(LogERROR, "%s: Failed socketpair read: Got %d of %d\n", | 1640 log_Printf(LogERROR, "%s: Failed socketpair read: Got %zd of %d\n", |
1641 sun->sun_path, got, (int)(sizeof newpid)); 1642 } 1643 1644 close(reply[0]); 1645 close(reply[1]); 1646 1647 newsid = Enabled(dl->bundle, OPT_KEEPSESSION) || 1648 tcgetpgrp(fd[0]) == getpgrp(); --- 364 unchanged lines hidden --- | 1641 sun->sun_path, got, (int)(sizeof newpid)); 1642 } 1643 1644 close(reply[0]); 1645 close(reply[1]); 1646 1647 newsid = Enabled(dl->bundle, OPT_KEEPSESSION) || 1648 tcgetpgrp(fd[0]) == getpgrp(); --- 364 unchanged lines hidden --- |