Deleted Added
full compact
mp.c (64670) mp.c (64780)
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/mp.c 64670 2000-08-15 10:25:42Z brian $
26 * $FreeBSD: head/usr.sbin/ppp/mp.c 64780 2000-08-17 14:14:54Z brian $
27 */
28
29#include <sys/param.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33#include <arpa/inet.h>
34#include <net/if_dl.h>

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

688 if (dl->state != DATALINK_OPEN)
689 continue;
690
691 if (dl->physical->out)
692 /* this link has suffered a short write. Let it continue */
693 continue;
694
695 add = link_QueueLen(&dl->physical->link);
27 */
28
29#include <sys/param.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33#include <arpa/inet.h>
34#include <net/if_dl.h>

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

688 if (dl->state != DATALINK_OPEN)
689 continue;
690
691 if (dl->physical->out)
692 /* this link has suffered a short write. Let it continue */
693 continue;
694
695 add = link_QueueLen(&dl->physical->link);
696 total += add;
697 if (add)
696 if (add) {
698 /* this link has got stuff already queued. Let it continue */
697 /* this link has got stuff already queued. Let it continue */
698 total += add;
699 continue;
699 continue;
700 }
700
701
701 if (!link_QueueLen(&mp->link) && !ip_PushPacket(&mp->link, bundle))
702 /* Nothing else to send */
703 break;
702 if (!link_QueueLen(&mp->link)) {
703 struct datalink *other;
704 int mrutoosmall;
704
705
705 m = link_Dequeue(&mp->link);
706 len = m_length(m);
707 begin = 1;
708 end = 0;
706 /*
707 * If there's only a single open link in our bundle and we haven't got
708 * MP level link compression, queue outbound traffic directly via that
709 * link's protocol stack rather than using the MP link. This results
710 * in the outbound traffic going out as PROTO_IP rather than PROTO_MP.
711 */
712 for (other = dl->next; other; other = other->next)
713 if (other->state == DATALINK_OPEN)
714 break;
709
715
710 while (!end) {
711 if (dl->state == DATALINK_OPEN) {
712 /* Write at most his_mru bytes to the physical link */
713 if (len <= dl->physical->link.lcp.his_mru) {
714 mo = m;
715 end = 1;
716 m_settype(mo, MB_MPOUT);
717 } else {
718 /* It's > his_mru, chop the packet (`m') into bits */
719 mo = m_get(dl->physical->link.lcp.his_mru, MB_MPOUT);
720 len -= mo->m_len;
721 m = mbuf_Read(m, MBUF_CTOP(mo), mo->m_len);
716 mrutoosmall = 0;
717 if (!other) {
718 if (dl->physical->link.lcp.his_mru < mp->peer_mrru) {
719 /*
720 * Actually, forget it. This test is done against the MRRU rather
721 * than the packet size so that we don't end up sending some data
722 * in MP fragments and some data in PROTO_IP packets. That's just
723 * too likely to upset some ppp implementations.
724 */
725 mrutoosmall = 1;
726 other = dl;
722 }
727 }
723 mp_Output(mp, bundle, &dl->physical->link, mo, begin, end);
724 begin = 0;
725 }
726
728 }
729
727 if (!end) {
728 nlinks--;
729 dl = dl->next;
730 if (!dl) {
731 dl = bundle->links;
732 thislink = 0;
733 } else
734 thislink++;
730 if (!ip_PushPacket(other ? &mp->link : &dl->physical->link, bundle))
731 /* Nothing else to send */
732 break;
733
734 if (mrutoosmall)
735 log_Printf(LogDEBUG, "Don't send data as PROTO_IP, MRU < MRRU\n");
736 else if (!other)
737 log_Printf(LogDEBUG, "Sending data as PROTO_IP, not PROTO_MP\n");
738
739 if (!other) {
740 add = link_QueueLen(&dl->physical->link);
741 if (add) {
742 /* this link has got stuff already queued. Let it continue */
743 total += add;
744 continue;
745 }
735 }
736 }
746 }
747 }
748
749 m = link_Dequeue(&mp->link);
750 if (m) {
751 len = m_length(m);
752 begin = 1;
753 end = 0;
754
755 while (!end) {
756 if (dl->state == DATALINK_OPEN) {
757 /* Write at most his_mru bytes to the physical link */
758 if (len <= dl->physical->link.lcp.his_mru) {
759 mo = m;
760 end = 1;
761 m_settype(mo, MB_MPOUT);
762 } else {
763 /* It's > his_mru, chop the packet (`m') into bits */
764 mo = m_get(dl->physical->link.lcp.his_mru, MB_MPOUT);
765 len -= mo->m_len;
766 m = mbuf_Read(m, MBUF_CTOP(mo), mo->m_len);
767 }
768 mp_Output(mp, bundle, &dl->physical->link, mo, begin, end);
769 begin = 0;
770 }
771
772 if (!end) {
773 nlinks--;
774 dl = dl->next;
775 if (!dl) {
776 dl = bundle->links;
777 thislink = 0;
778 } else
779 thislink++;
780 }
781 }
782 }
737 }
738 mp->out.link = thislink; /* Start here next time */
739
740 return total;
741}
742
743int
744mp_SetDatalinkBandwidth(struct cmdargs const *arg)
745{
746 int val;
747
748 if (arg->argc != arg->argn+1)
749 return -1;
783 }
784 mp->out.link = thislink; /* Start here next time */
785
786 return total;
787}
788
789int
790mp_SetDatalinkBandwidth(struct cmdargs const *arg)
791{
792 int val;
793
794 if (arg->argc != arg->argn+1)
795 return -1;
750
796
751 val = atoi(arg->argv[arg->argn]);
752 if (val <= 0) {
753 log_Printf(LogWARN, "The link bandwidth must be greater than zero\n");
754 return 1;
755 }
756 arg->cx->mp.bandwidth = val;
757
758 if (arg->cx->state == DATALINK_OPEN)

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

813 prompt_Printf(arg->prompt, " Short Seq: %s\n",
814 mp->peer_is12bit ? "on" : "off");
815 }
816 prompt_Printf(arg->prompt, " Discriminator: %s\n",
817 mp_Enddisc(mp->peer.enddisc.class, mp->peer.enddisc.address,
818 mp->peer.enddisc.len));
819
820 prompt_Printf(arg->prompt, "\nDefaults:\n");
797 val = atoi(arg->argv[arg->argn]);
798 if (val <= 0) {
799 log_Printf(LogWARN, "The link bandwidth must be greater than zero\n");
800 return 1;
801 }
802 arg->cx->mp.bandwidth = val;
803
804 if (arg->cx->state == DATALINK_OPEN)

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

859 prompt_Printf(arg->prompt, " Short Seq: %s\n",
860 mp->peer_is12bit ? "on" : "off");
861 }
862 prompt_Printf(arg->prompt, " Discriminator: %s\n",
863 mp_Enddisc(mp->peer.enddisc.class, mp->peer.enddisc.address,
864 mp->peer.enddisc.len));
865
866 prompt_Printf(arg->prompt, "\nDefaults:\n");
821
867
822 prompt_Printf(arg->prompt, " MRRU: ");
823 if (mp->cfg.mrru)
824 prompt_Printf(arg->prompt, "%d (multilink enabled)\n", mp->cfg.mrru);
825 else
826 prompt_Printf(arg->prompt, "disabled\n");
827 prompt_Printf(arg->prompt, " Short Seq: %s\n",
828 command_ShowNegval(mp->cfg.shortseq));
829 prompt_Printf(arg->prompt, " Discriminator: %s\n",

--- 319 unchanged lines hidden ---
868 prompt_Printf(arg->prompt, " MRRU: ");
869 if (mp->cfg.mrru)
870 prompt_Printf(arg->prompt, "%d (multilink enabled)\n", mp->cfg.mrru);
871 else
872 prompt_Printf(arg->prompt, "disabled\n");
873 prompt_Printf(arg->prompt, " Short Seq: %s\n",
874 command_ShowNegval(mp->cfg.shortseq));
875 prompt_Printf(arg->prompt, " Discriminator: %s\n",

--- 319 unchanged lines hidden ---