Deleted Added
full compact
bundle.c (85991) bundle.c (93418)
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 85991 2001-11-03 21:45:32Z brian $
26 * $FreeBSD: head/usr.sbin/ppp/bundle.c 93418 2002-03-30 12:30:09Z 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 <net/route.h>

--- 9 unchanged lines hidden (view full) ---

44#include <libutil.h>
45#endif
46#include <paths.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>
50#include <sys/uio.h>
51#include <sys/wait.h>
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>

--- 9 unchanged lines hidden (view full) ---

44#include <libutil.h>
45#endif
46#include <paths.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>
50#include <sys/uio.h>
51#include <sys/wait.h>
52#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
53#ifdef NOSUID
54#include <sys/linker.h>
55#endif
56#include <sys/module.h>
57#endif
58#include <termios.h>
59#include <unistd.h>
60
61#include "layer.h"
62#include "defs.h"
63#include "command.h"
64#include "mbuf.h"
65#include "log.h"

--- 29 unchanged lines hidden (view full) ---

95#include "tun.h"
96#include "prompt.h"
97#include "chat.h"
98#include "cbcp.h"
99#include "datalink.h"
100#include "iface.h"
101#include "server.h"
102#include "probe.h"
52#include <termios.h>
53#include <unistd.h>
54
55#include "layer.h"
56#include "defs.h"
57#include "command.h"
58#include "mbuf.h"
59#include "log.h"

--- 29 unchanged lines hidden (view full) ---

89#include "tun.h"
90#include "prompt.h"
91#include "chat.h"
92#include "cbcp.h"
93#include "datalink.h"
94#include "iface.h"
95#include "server.h"
96#include "probe.h"
103#ifdef HAVE_DES
97#ifndef NODES
104#include "mppe.h"
105#endif
106
107#define SCATTER_SEGMENTS 7 /* version, datalink, name, physical,
108 throughput, throughput, device */
109
110#define SEND_MAXFD 3 /* Max file descriptors passed through
111 the local domain socket */

--- 18 unchanged lines hidden (view full) ---

130 return;
131
132 if (new <= PHASE_TERMINATE)
133 log_Printf(LogPHASE, "bundle: %s\n", PhaseNames[new]);
134
135 switch (new) {
136 case PHASE_DEAD:
137 bundle->phase = new;
98#include "mppe.h"
99#endif
100
101#define SCATTER_SEGMENTS 7 /* version, datalink, name, physical,
102 throughput, throughput, device */
103
104#define SEND_MAXFD 3 /* Max file descriptors passed through
105 the local domain socket */

--- 18 unchanged lines hidden (view full) ---

124 return;
125
126 if (new <= PHASE_TERMINATE)
127 log_Printf(LogPHASE, "bundle: %s\n", PhaseNames[new]);
128
129 switch (new) {
130 case PHASE_DEAD:
131 bundle->phase = new;
138#ifdef HAVE_DES
132#ifndef NODES
139 MPPE_MasterKeyValid = 0;
140#endif
141 log_DisplayPrompts();
142 break;
143
144 case PHASE_ESTABLISH:
145 bundle->phase = new;
146 break;

--- 473 unchanged lines hidden (view full) ---

620bundle_DescriptorWrite(struct fdescriptor *d, struct bundle *bundle,
621 const fd_set *fdset)
622{
623 struct datalink *dl;
624 int result = 0;
625
626 /* This is not actually necessary as struct mpserver doesn't Write() */
627 if (descriptor_IsSet(&bundle->ncp.mp.server.desc, fdset))
133 MPPE_MasterKeyValid = 0;
134#endif
135 log_DisplayPrompts();
136 break;
137
138 case PHASE_ESTABLISH:
139 bundle->phase = new;
140 break;

--- 473 unchanged lines hidden (view full) ---

614bundle_DescriptorWrite(struct fdescriptor *d, struct bundle *bundle,
615 const fd_set *fdset)
616{
617 struct datalink *dl;
618 int result = 0;
619
620 /* This is not actually necessary as struct mpserver doesn't Write() */
621 if (descriptor_IsSet(&bundle->ncp.mp.server.desc, fdset))
628 descriptor_Write(&bundle->ncp.mp.server.desc, bundle, fdset);
622 if (descriptor_Write(&bundle->ncp.mp.server.desc, bundle, fdset) == 1)
623 result++;
629
630 for (dl = bundle->links; dl; dl = dl->next)
631 if (descriptor_IsSet(&dl->desc, fdset))
624
625 for (dl = bundle->links; dl; dl = dl->next)
626 if (descriptor_IsSet(&dl->desc, fdset))
632 result += descriptor_Write(&dl->desc, bundle, fdset);
627 switch (descriptor_Write(&dl->desc, bundle, fdset)) {
628 case -1:
629 datalink_ComeDown(dl, CLOSE_NORMAL);
630 break;
631 case 1:
632 result++;
633 }
633
634 return result;
635}
636
637void
638bundle_LockTun(struct bundle *bundle)
639{
640 FILE *lockfile;

--- 59 unchanged lines hidden (view full) ---

700 break;
701 else if (errno == ENXIO || errno == ENOENT) {
702#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
703 if (bundle.unit == minunit && !kldtried++) {
704 /*
705 * Attempt to load the tunnel interface KLD if it isn't loaded
706 * already.
707 */
634
635 return result;
636}
637
638void
639bundle_LockTun(struct bundle *bundle)
640{
641 FILE *lockfile;

--- 59 unchanged lines hidden (view full) ---

701 break;
702 else if (errno == ENXIO || errno == ENOENT) {
703#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
704 if (bundle.unit == minunit && !kldtried++) {
705 /*
706 * Attempt to load the tunnel interface KLD if it isn't loaded
707 * already.
708 */
708 if (modfind("if_tun") == -1) {
709 if (ID0kldload("if_tun") != -1) {
710 bundle.unit--;
711 continue;
712 }
713 log_Printf(LogWARN, "kldload: if_tun: %s\n", strerror(errno));
714 }
709 loadmodules(LOAD_VERBOSLY, "if_tun", NULL);
710 continue;
715 }
716#endif
717 if (errno != ENOENT || ++enoentcount > 2) {
718 err = errno;
719 break;
720 }
721 } else
722 err = errno;

--- 1214 unchanged lines hidden ---
711 }
712#endif
713 if (errno != ENOENT || ++enoentcount > 2) {
714 err = errno;
715 break;
716 }
717 } else
718 err = errno;

--- 1214 unchanged lines hidden ---