bundle.c (59070) | bundle.c (59084) |
---|---|
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 59070 2000-04-06 10:03:48Z brian $ | 26 * $FreeBSD: head/usr.sbin/ppp/bundle.c 59084 2000-04-07 23:46:14Z brian $ |
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 <arpa/inet.h> --- 120 unchanged lines hidden (view full) --- 155 156static void 157bundle_LayerStart(void *v, struct fsm *fp) 158{ 159 /* The given FSM is about to start up ! */ 160} 161 162 | 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 <arpa/inet.h> --- 120 unchanged lines hidden (view full) --- 155 156static void 157bundle_LayerStart(void *v, struct fsm *fp) 158{ 159 /* The given FSM is about to start up ! */ 160} 161 162 |
163static void | 163void |
164bundle_Notify(struct bundle *bundle, char c) 165{ 166 if (bundle->notify.fd != -1) { | 164bundle_Notify(struct bundle *bundle, char c) 165{ 166 if (bundle->notify.fd != -1) { |
167 if (write(bundle->notify.fd, &c, 1) == 1) 168 log_Printf(LogPHASE, "Parent notified of %s\n", 169 c == EX_NORMAL ? "success" : "failure"); | 167 int ret; 168 169 ret = write(bundle->notify.fd, &c, 1); 170 if (c != EX_REDIAL && c != EX_RECONNECT) { 171 if (ret == 1) 172 log_Printf(LogCHAT, "Parent notified of %s\n", 173 c == EX_NORMAL ? "success" : "failure"); 174 else 175 log_Printf(LogERROR, "Failed to notify parent of success\n"); 176 close(bundle->notify.fd); 177 bundle->notify.fd = -1; 178 } else if (ret == 1) 179 log_Printf(LogCHAT, "Parent notified of %s\n", ex_desc(c)); |
170 else | 180 else |
171 log_Printf(LogPHASE, "Failed to notify parent of success.\n"); 172 close(bundle->notify.fd); 173 bundle->notify.fd = -1; | 181 log_Printf(LogERROR, "Failed to notify parent of %s\n", ex_desc(c)); |
174 } 175} 176 177static void 178bundle_ClearQueues(void *v) 179{ 180 struct bundle *bundle = (struct bundle *)v; 181 struct datalink *dl; --- 1033 unchanged lines hidden (view full) --- 1215 return 0; 1216} 1217 1218static void 1219bundle_IdleTimeout(void *v) 1220{ 1221 struct bundle *bundle = (struct bundle *)v; 1222 | 182 } 183} 184 185static void 186bundle_ClearQueues(void *v) 187{ 188 struct bundle *bundle = (struct bundle *)v; 189 struct datalink *dl; --- 1033 unchanged lines hidden (view full) --- 1223 return 0; 1224} 1225 1226static void 1227bundle_IdleTimeout(void *v) 1228{ 1229 struct bundle *bundle = (struct bundle *)v; 1230 |
1223 log_Printf(LogPHASE, "Idle timer expired.\n"); | 1231 log_Printf(LogPHASE, "Idle timer expired\n"); |
1224 bundle_StopIdleTimer(bundle); 1225 bundle_Close(bundle, NULL, CLOSE_STAYDOWN); 1226} 1227 1228/* 1229 * Start Idle timer. If timeout is reached, we call bundle_Close() to 1230 * close LCP and link. 1231 */ --- 406 unchanged lines hidden (view full) --- 1638 else { 1639 /* We must get the ACK before closing the descriptor ! */ 1640 int res; 1641 1642 if ((got = read(reply[0], &newpid, sizeof newpid)) == sizeof newpid) { 1643 log_Printf(LogDEBUG, "Received confirmation from pid %d\n", 1644 (int)newpid); 1645 if (lock && (res = ID0uu_lock_txfr(lock, newpid)) != UU_LOCK_OK) | 1232 bundle_StopIdleTimer(bundle); 1233 bundle_Close(bundle, NULL, CLOSE_STAYDOWN); 1234} 1235 1236/* 1237 * Start Idle timer. If timeout is reached, we call bundle_Close() to 1238 * close LCP and link. 1239 */ --- 406 unchanged lines hidden (view full) --- 1646 else { 1647 /* We must get the ACK before closing the descriptor ! */ 1648 int res; 1649 1650 if ((got = read(reply[0], &newpid, sizeof newpid)) == sizeof newpid) { 1651 log_Printf(LogDEBUG, "Received confirmation from pid %d\n", 1652 (int)newpid); 1653 if (lock && (res = ID0uu_lock_txfr(lock, newpid)) != UU_LOCK_OK) |
1646 log_Printf(LogPHASE, "uu_lock_txfr: %s\n", uu_lockerr(res)); | 1654 log_Printf(LogERROR, "uu_lock_txfr: %s\n", uu_lockerr(res)); |
1647 1648 log_Printf(LogDEBUG, "Transmitting link (%d bytes)\n", expect); 1649 if ((got = writev(reply[0], iov + 1, niov - 1)) != expect) { 1650 if (got == -1) 1651 log_Printf(LogERROR, "%s: Failed writev: %s\n", 1652 sun->sun_path, strerror(errno)); 1653 else 1654 log_Printf(LogERROR, "%s: Failed writev: Wrote %d of %d\n", --- 121 unchanged lines hidden (view full) --- 1776 return; 1777 case 0: 1778 close(fds[1]); 1779 bundle_LockTun(bundle); /* update pid */ 1780 read(fds[0], &done, 1); /* uu_locks are mine ! */ 1781 close(fds[0]); 1782 setsid(); 1783 bundle_ChangedPID(bundle); | 1655 1656 log_Printf(LogDEBUG, "Transmitting link (%d bytes)\n", expect); 1657 if ((got = writev(reply[0], iov + 1, niov - 1)) != expect) { 1658 if (got == -1) 1659 log_Printf(LogERROR, "%s: Failed writev: %s\n", 1660 sun->sun_path, strerror(errno)); 1661 else 1662 log_Printf(LogERROR, "%s: Failed writev: Wrote %d of %d\n", --- 121 unchanged lines hidden (view full) --- 1784 return; 1785 case 0: 1786 close(fds[1]); 1787 bundle_LockTun(bundle); /* update pid */ 1788 read(fds[0], &done, 1); /* uu_locks are mine ! */ 1789 close(fds[0]); 1790 setsid(); 1791 bundle_ChangedPID(bundle); |
1784 log_Printf(LogPHASE, "%d -> %d: %s session control\n", | 1792 log_Printf(LogDEBUG, "%d -> %d: %s session control\n", |
1785 (int)orig, (int)getpid(), 1786 holdsession ? "Passed" : "Dropped"); 1787 timer_InitService(0); /* Start the Timer Service */ 1788 break; 1789 default: 1790 close(fds[0]); 1791 /* Give away all our physical locks (to the final process) */ 1792 for (dl = bundle->links; dl; dl = dl->next) --- 210 unchanged lines hidden --- | 1793 (int)orig, (int)getpid(), 1794 holdsession ? "Passed" : "Dropped"); 1795 timer_InitService(0); /* Start the Timer Service */ 1796 break; 1797 default: 1798 close(fds[0]); 1799 /* Give away all our physical locks (to the final process) */ 1800 for (dl = bundle->links; dl; dl = dl->next) --- 210 unchanged lines hidden --- |