Deleted Added
full compact
bundle.c (43313) bundle.c (43693)
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 * $Id: bundle.c,v 1.43 1999/01/06 00:08:03 brian Exp $
26 * $Id: bundle.c,v 1.44 1999/01/28 01:56:30 brian Exp $
27 */
28
29#include <sys/param.h>
30#include <sys/socket.h>
31#include <netinet/in.h>
32#include <net/if.h>
33#include <arpa/inet.h>
34#include <net/route.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 <arpa/inet.h>
34#include <net/route.h>
35#include <net/if_dl.h>
36#include <netinet/in_systm.h>
37#include <netinet/ip.h>
38#include <sys/un.h>
39
40#include <errno.h>
41#include <fcntl.h>
42#include <paths.h>
43#include <stdio.h>

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

553 bundle->choked.timer.name = "output choke";
554 bundle->choked.timer.load = bundle->cfg.choked.timeout * SECTICKS;
555 bundle->choked.timer.arg = bundle;
556 timer_Start(&bundle->choked.timer);
557 }
558 }
559 }
560
35#include <netinet/in_systm.h>
36#include <netinet/ip.h>
37#include <sys/un.h>
38
39#include <errno.h>
40#include <fcntl.h>
41#include <paths.h>
42#include <stdio.h>

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

552 bundle->choked.timer.name = "output choke";
553 bundle->choked.timer.load = bundle->cfg.choked.timeout * SECTICKS;
554 bundle->choked.timer.arg = bundle;
555 timer_Start(&bundle->choked.timer);
556 }
557 }
558 }
559
560#ifndef NORADIUS
561 result += descriptor_UpdateSet(&bundle->radius.desc, r, w, e, n);
562#endif
563
561 /* Which links need a select() ? */
562 for (dl = bundle->links; dl; dl = dl->next)
563 result += descriptor_UpdateSet(&dl->desc, r, w, e, n);
564
565 /*
566 * This *MUST* be called after the datalink UpdateSet()s as it
567 * might be ``holding'' one of the datalinks (death-row) and
568 * wants to be able to de-select() it from the descriptor set.

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

577{
578 struct bundle *bundle = descriptor2bundle(d);
579 struct datalink *dl;
580
581 for (dl = bundle->links; dl; dl = dl->next)
582 if (descriptor_IsSet(&dl->desc, fdset))
583 return 1;
584
564 /* Which links need a select() ? */
565 for (dl = bundle->links; dl; dl = dl->next)
566 result += descriptor_UpdateSet(&dl->desc, r, w, e, n);
567
568 /*
569 * This *MUST* be called after the datalink UpdateSet()s as it
570 * might be ``holding'' one of the datalinks (death-row) and
571 * wants to be able to de-select() it from the descriptor set.

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

580{
581 struct bundle *bundle = descriptor2bundle(d);
582 struct datalink *dl;
583
584 for (dl = bundle->links; dl; dl = dl->next)
585 if (descriptor_IsSet(&dl->desc, fdset))
586 return 1;
587
588#ifndef NORADIUS
589 if (descriptor_IsSet(&bundle->radius.desc, fdset))
590 return 1;
591#endif
592
585 if (descriptor_IsSet(&bundle->ncp.mp.server.desc, fdset))
586 return 1;
587
588 return FD_ISSET(bundle->dev.fd, fdset);
589}
590
591static void
592bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
593 const fd_set *fdset)
594{
595 struct datalink *dl;
596
597 if (descriptor_IsSet(&bundle->ncp.mp.server.desc, fdset))
598 descriptor_Read(&bundle->ncp.mp.server.desc, bundle, fdset);
599
600 for (dl = bundle->links; dl; dl = dl->next)
601 if (descriptor_IsSet(&dl->desc, fdset))
602 descriptor_Read(&dl->desc, bundle, fdset);
603
593 if (descriptor_IsSet(&bundle->ncp.mp.server.desc, fdset))
594 return 1;
595
596 return FD_ISSET(bundle->dev.fd, fdset);
597}
598
599static void
600bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
601 const fd_set *fdset)
602{
603 struct datalink *dl;
604
605 if (descriptor_IsSet(&bundle->ncp.mp.server.desc, fdset))
606 descriptor_Read(&bundle->ncp.mp.server.desc, bundle, fdset);
607
608 for (dl = bundle->links; dl; dl = dl->next)
609 if (descriptor_IsSet(&dl->desc, fdset))
610 descriptor_Read(&dl->desc, bundle, fdset);
611
612#ifndef NORADIUS
613 if (descriptor_IsSet(&bundle->radius.desc, fdset))
614 descriptor_Read(&bundle->radius.desc, bundle, fdset);
615#endif
616
604 if (FD_ISSET(bundle->dev.fd, fdset)) {
605 struct tun_data tun;
606 int n, pri;
607
608 /* something to read from tun */
609 n = read(bundle->dev.fd, &tun, sizeof tun);
610 if (n < 0) {
611 log_Printf(LogWARN, "read from %s: %s\n", TUN_NAME, strerror(errno));

--- 1150 unchanged lines hidden ---
617 if (FD_ISSET(bundle->dev.fd, fdset)) {
618 struct tun_data tun;
619 int n, pri;
620
621 /* something to read from tun */
622 n = read(bundle->dev.fd, &tun, sizeof tun);
623 if (n < 0) {
624 log_Printf(LogWARN, "read from %s: %s\n", TUN_NAME, strerror(errno));

--- 1150 unchanged lines hidden ---