o Initialise MP correctly depending on if we're the

first link in mp_Up().
o Bring MP and its CCP down when we enter phase TERMINATE,
  and ditch everything in the incoming packet queue.
o Enable MRRU negotiation.  Now, we can multilink
  mode, but only with one physical link.
o Close the link if the peer PROTO REJs PROTO_MP.
o Prepend our protocol before passing a packet to
  struct mp for fragmentation.
o Log info messages to DEBUG, not ERROR (oops).
o Align `show mp' output (again).
This commit is contained in:
Brian Somers 1998-04-23 21:50:13 +00:00
parent 6e3ef61465
commit 673903ec42
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35410
6 changed files with 87 additions and 42 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bundle.c,v 1.1.2.57 1998/04/23 03:22:44 brian Exp $
* $Id: bundle.c,v 1.1.2.58 1998/04/23 18:56:07 brian Exp $
*/
#include <sys/types.h>
@ -115,10 +115,13 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
ipcp_Setup(&bundle->ncp.ipcp);
FsmUp(&bundle->ncp.ipcp.fsm);
FsmOpen(&bundle->ncp.ipcp.fsm);
/* Fall through */
bundle->phase = new;
bundle_DisplayPrompt(bundle);
break;
case PHASE_TERMINATE:
bundle->phase = new;
mp_Down(&bundle->ncp.mp);
bundle_DisplayPrompt(bundle);
break;
}
@ -779,7 +782,6 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
}
bundle_NewPhase(bundle, PHASE_DEAD);
bundle_DisplayPrompt(bundle);
mp_Init(&bundle->ncp.mp, bundle);
}
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: command.c,v 1.131.2.67 1998/04/19 07:22:31 brian Exp $
* $Id: command.c,v 1.131.2.68 1998/04/23 03:22:47 brian Exp $
*
*/
#include <sys/types.h>
@ -513,7 +513,7 @@ static int
ShowVersion(struct cmdargs const *arg)
{
static char VarVersion[] = "PPP Version 2.0-beta";
static char VarLocalVersion[] = "$Date: 1998/04/19 07:22:31 $";
static char VarLocalVersion[] = "$Date: 1998/04/23 03:22:47 $";
prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion);
return 0;
@ -1152,7 +1152,6 @@ SetVariable(struct cmdargs const *arg)
if (bundle_Phase(arg->bundle) != PHASE_DEAD)
LogPrintf(LogWARN, "mrru: Only changable at phase DEAD\n");
else {
#ifdef notyet
ulong_val = atol(argp);
if (ulong_val < MIN_MRU)
err = "Given MRRU value (%lu) is too small.\n";
@ -1162,9 +1161,6 @@ SetVariable(struct cmdargs const *arg)
arg->bundle->ncp.mp.cfg.mrru = ulong_val;
if (err)
LogPrintf(LogWARN, err, ulong_val);
#else
LogPrintf(LogWARN, "mrru: ifdef'd out !\n");
#endif
}
break;
case VAR_MRU:

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: fsm.c,v 1.27.2.29 1998/04/19 15:24:41 brian Exp $
* $Id: fsm.c,v 1.27.2.30 1998/04/19 23:08:15 brian Exp $
*
* TODO:
*/
@ -773,6 +773,16 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
(*fp->parent->LayerFinish)(fp->parent->object, fp);
}
break;
case PROTO_MP:
if (fp->proto == PROTO_LCP) {
struct lcp *lcp = fsm2lcp(fp);
if (lcp->want_mrru && lcp->his_mrru) {
LogPrintf(LogPHASE, "MP protocol reject is fatal !\n");
FsmClose(fp);
}
}
break;
}
pfree(bp);
}

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: hdlc.c,v 1.28.2.26 1998/04/18 01:01:22 brian Exp $
* $Id: hdlc.c,v 1.28.2.27 1998/04/19 15:24:42 brian Exp $
*
* TODO:
*/
@ -142,19 +142,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
u_char *cp;
u_short fcs;
if (!p) {
/*
* This is where we multiplex the data over our available physical
* links. We don't frame our logical link data. Instead we wait
* for the logical link implementation to chop our data up and pile
* it into the physical links by re-calling this function with the
* encapsulated fragments.
*/
link_Output(l, pri, bp);
return;
}
if (Physical_IsSync(p))
if (!p || Physical_IsSync(p))
mfcs = NULL;
else
mfcs = mballoc(2, MB_HDLCOUT);
@ -162,7 +150,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
mhp = mballoc(4, MB_HDLCOUT);
mhp->cnt = 0;
cp = MBUF_CTOP(mhp);
if (proto == PROTO_LCP || p->link.lcp.his_acfcomp == 0) {
if (p && (proto == PROTO_LCP || l->lcp.his_acfcomp == 0)) {
*cp++ = HDLC_ADDR;
*cp++ = HDLC_UI;
mhp->cnt += 2;
@ -171,7 +159,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
/*
* If possible, compress protocol field.
*/
if (p->link.lcp.his_protocomp && (proto & 0xff00) == 0) {
if (l->lcp.his_protocomp && (proto & 0xff00) == 0) {
*cp++ = proto;
mhp->cnt++;
} else {
@ -180,8 +168,21 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
mhp->cnt += 2;
}
/* Tack mfcs onto the end and set bp back to the start of the data */
mhp->next = bp;
if (!p) {
/*
* This is where we multiplex the data over our available physical
* links. We don't frame our logical link data. Instead we wait
* for the logical link implementation to chop our data up and pile
* it into the physical links by re-calling this function with the
* encapsulated fragments.
*/
link_Output(l, pri, mhp);
return;
}
/* Tack mfcs onto the end, then set bp back to the start of the data */
while (bp->next != NULL)
bp = bp->next;
bp->next = mfcs;

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp.c,v 1.1.2.8 1998/04/23 18:56:21 brian Exp $
* $Id: mp.c,v 1.1.2.9 1998/04/23 18:58:04 brian Exp $
*/
#include <sys/types.h>
@ -187,6 +187,15 @@ mp_Up(struct mp *mp, u_short local_mrru, u_short peer_mrru,
mp->local_is12bit = local_shortseq;
mp->peer_is12bit = peer_shortseq;
throughput_init(&mp->link.throughput);
memset(mp->link.Queue, '\0', sizeof mp->link.Queue);
memset(mp->link.proto_in, '\0', sizeof mp->link.proto_in);
memset(mp->link.proto_out, '\0', sizeof mp->link.proto_out);
mp->seq.out = 0;
mp->seq.min_in = 0;
mp->seq.next_in = 0;
/* Re-point our IPCP layer at our MP link */
ipcp_SetLink(&mp->bundle->ncp.ipcp, &mp->link);
@ -200,6 +209,27 @@ mp_Up(struct mp *mp, u_short local_mrru, u_short peer_mrru,
return 1;
}
void
mp_Down(struct mp *mp)
{
if (mp->active) {
struct mbuf *next;
/* CCP goes down with a bank */
FsmDown(&mp->link.ccp.fsm);
FsmClose(&mp->link.ccp.fsm);
/* Received fragments go in the bit-bucket */
while (mp->inbufs) {
next = mp->inbufs->pnext;
pfree(mp->inbufs);
mp->inbufs = next;
}
mp->active = 0;
}
}
void
mp_linkInit(struct mp_link *mplink)
{
@ -312,8 +342,6 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
/* We've got something, reassemble */
struct mbuf **frag = &q;
int len;
u_short proto = 0;
u_char ch;
u_long first = -1;
do {
@ -351,13 +379,19 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
} while (!h.end);
if (q) {
do {
u_short proto;
u_char ch;
q = mbread(q, &ch, 1);
proto = ch;
if (!(proto & 1)) {
q = mbread(q, &ch, 1);
proto = proto << 8;
proto <<= 8;
proto += ch;
} while (!(proto & 1));
LogPrintf(LogERROR, "MP: Reassembled frags %ld-%lu\n",
first, (u_long)h.seq);
}
if (LogIsKept(LogDEBUG))
LogPrintf(LogDEBUG, "MP: Reassembled frags %ld-%lu, length %d\n",
first, (u_long)h.seq, plength(q));
hdlc_DecodePacket(mp->bundle, proto, q, &mp->link);
}
@ -411,8 +445,9 @@ mp_Output(struct mp *mp, struct link *l, struct mbuf *m, int begin, int end)
*seq32 = htonl((begin << 31) | (end << 30) | (u_int32_t)mp->seq.out);
mo->cnt = 4;
}
LogPrintf(LogERROR, "MP[frag %d]: Send %d bytes on %s\n",
mp->seq.out, plength(mo), l->name);
if (LogIsKept(LogDEBUG))
LogPrintf(LogDEBUG, "MP[frag %d]: Send %d bytes on %s\n",
mp->seq.out, plength(mo), l->name);
mp->seq.out = inc_seq(mp, mp->seq.out);
HdlcOutput(l, PRI_NORMAL, PROTO_MP, mo);
@ -510,7 +545,7 @@ mp_ShowStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, " Short Seq: %s\n",
mp->local_is12bit ? "on" : "off");
}
prompt_Printf(arg->prompt, " End Disc: %s\n",
prompt_Printf(arg->prompt, " End Disc: %s\n",
mp_Enddisc(mp->cfg.enddisc.class, mp->cfg.enddisc.address,
mp->cfg.enddisc.len));
@ -521,18 +556,18 @@ mp_ShowStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, " Short Seq: %s\n",
mp->peer_is12bit ? "on" : "off");
}
prompt_Printf(arg->prompt, " End Disc: %s\n",
prompt_Printf(arg->prompt, " End Disc: %s\n",
mp_Enddisc(mp->peer_enddisc.class, mp->peer_enddisc.address,
mp->peer_enddisc.len));
prompt_Printf(arg->prompt, "\nDefaults:\n");
prompt_Printf(arg->prompt, " MRRU: ");
prompt_Printf(arg->prompt, " MRRU: ");
if (mp->cfg.mrru)
prompt_Printf(arg->prompt, "%d (multilink enabled)\n", mp->cfg.mrru);
else
prompt_Printf(arg->prompt, "disabled\n");
prompt_Printf(arg->prompt, " Short Seq: %s\n",
prompt_Printf(arg->prompt, " Short Seq: %s\n",
command_ShowNegval(mp->cfg.shortseq));
return 0;

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: mp.h,v 1.1.2.2 1998/04/07 00:54:11 brian Exp $
* $Id: mp.h,v 1.1.2.3 1998/04/23 03:23:00 brian Exp $
*/
struct mbuf;
@ -81,6 +81,7 @@ struct mp_header {
extern void mp_Init(struct mp *, struct bundle *);
extern void mp_linkInit(struct mp_link *);
extern int mp_Up(struct mp *, u_short, u_short, int, int);
extern void mp_Down(struct mp *);
extern void mp_Input(struct mp *, struct mbuf *, struct physical *);
extern int mp_FillQueues(struct bundle *);
extern int mp_SetDatalinkWeight(struct cmdargs const *);