o Add ipcp_SetLink() for attaching IPCP to the correct link, and

call it after link authentication.
o Pretty print our bundle MTU.
o Correct MP header encoding and decoding (should be network byte order).
o Add some debug diagnostics so that we can see MP fragment sending and
  re-assembly.
This commit is contained in:
Brian Somers 1998-04-23 18:56:21 +00:00
parent 789de69642
commit ce828a6ecc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35406
5 changed files with 49 additions and 30 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.56 1998/04/20 00:21:24 brian Exp $
* $Id: bundle.c,v 1.1.2.57 1998/04/23 03:22:44 brian Exp $
*/
#include <sys/types.h>
@ -780,8 +780,6 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
bundle_NewPhase(bundle, PHASE_DEAD);
bundle_DisplayPrompt(bundle);
mp_Init(&bundle->ncp.mp, bundle);
ipcp_Init(&bundle->ncp.ipcp, bundle, &bundle->links->physical->link,
&bundle->fsm);
}
}
@ -873,7 +871,11 @@ bundle_ShowStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "\n");
} else
prompt_Printf(arg->prompt, "disabled\n");
prompt_Printf(arg->prompt, " MTU: %d\n", arg->bundle->cfg.mtu);
prompt_Printf(arg->prompt, " MTU: ");
if (arg->bundle->cfg.mtu)
prompt_Printf(arg->prompt, "%d\n", arg->bundle->cfg.mtu);
else
prompt_Printf(arg->prompt, "unspecified\n");
prompt_Printf(arg->prompt, " ID check: %s\n",
optval(arg->bundle, OPT_IDCHECK));

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: datalink.c,v 1.1.2.43 1998/04/23 03:22:48 brian Exp $
* $Id: datalink.c,v 1.1.2.44 1998/04/23 18:55:48 brian Exp $
*/
#include <sys/types.h>
@ -457,7 +457,8 @@ datalink_AuthOk(struct datalink *dl)
LogPrintf(LogPHASE, "%s: Already in NETWORK phase\n", dl->name);
datalink_AuthNotOk(dl);
return;
}
} else
ipcp_SetLink(&dl->bundle->ncp.ipcp, &dl->physical->link);
FsmUp(&dl->physical->link.ccp.fsm);
FsmOpen(&dl->physical->link.ccp.fsm);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.c,v 1.50.2.41 1998/04/21 01:02:15 brian Exp $
* $Id: ipcp.c,v 1.50.2.42 1998/04/23 03:22:52 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@ -376,6 +376,12 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l,
ipcp_Setup(ipcp);
}
void
ipcp_SetLink(struct ipcp *ipcp, struct link *l)
{
ipcp->fsm.link = l;
}
void
ipcp_Setup(struct ipcp *ipcp)
{

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.h,v 1.18.2.22 1998/04/16 00:26:05 brian Exp $
* $Id: ipcp.h,v 1.18.2.23 1998/04/17 22:05:29 brian Exp $
*
* TODO:
*/
@ -96,9 +96,10 @@ struct bundle;
struct link;
struct cmdargs;
extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *l,
extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *,
const struct fsm_parent *);
extern void ipcp_Setup(struct ipcp *);
extern void ipcp_SetLink(struct ipcp *, struct link *);
extern int ReportIpcpStatus(struct cmdargs const *);
extern void IpcpInput(struct ipcp *, struct mbuf *);

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.6 1998/04/20 00:20:40 brian Exp $
* $Id: mp.c,v 1.1.2.7 1998/04/23 03:22:59 brian Exp $
*/
#include <sys/types.h>
@ -82,23 +82,23 @@ static int
mp_ReadHeader(struct mp *mp, struct mbuf *m, struct mp_header *header)
{
if (mp->local_is12bit) {
header->seq = *(u_int16_t *)MBUF_CTOP(m);
header->seq = ntohs(*(u_int16_t *)MBUF_CTOP(m));
if (header->seq & 0x3000) {
LogPrintf(LogWARN, "Oops - MP header without required zero bits\n");
return 0;
}
header->begin = header->seq & 0x8000;
header->end = header->seq & 0x4000;
header->begin = header->seq & 0x8000 ? 1 : 0;
header->end = header->seq & 0x4000 ? 1 : 0;
header->seq &= 0x0fff;
return 2;
} else {
header->seq = *(u_int32_t *)MBUF_CTOP(m);
header->seq = ntohl(*(u_int32_t *)MBUF_CTOP(m));
if (header->seq & 0x3f000000) {
LogPrintf(LogWARN, "Oops - MP header without required zero bits\n");
return 0;
}
header->begin = header->seq & 0x80000000;
header->end = header->seq & 0x40000000;
header->begin = header->seq & 0x80000000 ? 1 : 0;
header->end = header->seq & 0x40000000 ? 1 : 0;
header->seq &= 0x00ffffff;
return 4;
}
@ -188,7 +188,7 @@ mp_Up(struct mp *mp, u_short local_mrru, u_short peer_mrru,
mp->peer_is12bit = peer_shortseq;
/* Re-point our IPCP layer at our MP link */
ipcp_Init(&mp->bundle->ncp.ipcp, mp->bundle, &mp->link, &mp->bundle->fsm);
ipcp_SetLink(&mp->bundle->ncp.ipcp, &mp->link);
/* Our lcp's already up 'cos of the NULL parent */
FsmUp(&mp->link.ccp.fsm);
@ -270,6 +270,7 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
/* Zap all older fragments */
while (mp->inbufs != q) {
LogPrintf(LogDEBUG, "Drop frag\n");
next = mp->inbufs->pnext;
pfree(mp->inbufs);
mp->inbufs = next;
@ -283,13 +284,15 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
do {
mp_ReadHeader(mp, mp->inbufs, &h);
if (h.begin) {
/* We might be able to process this ! */
h.seq--; /* We're gonna look for fragment with h.seq+1 */
break;
}
next = mp->inbufs->pnext;
LogPrintf(LogDEBUG, "Drop frag %u\n", h.seq);
pfree(mp->inbufs);
mp->inbufs = next;
} while (h.seq >= mp->seq.min_in || h.end);
} while (mp->inbufs && (h.seq >= mp->seq.min_in || h.end));
/*
* Continue processing things from here.
@ -311,11 +314,14 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
int len;
u_short proto = 0;
u_char ch;
u_long first = -1;
do {
*frag = mp->inbufs;
mp->inbufs = mp->inbufs->pnext;
len = mp_ReadHeader(mp, *frag, &h);
if (first == -1)
first = h.seq;
(*frag)->offset += len;
(*frag)->cnt -= len;
(*frag)->pnext = NULL;
@ -341,7 +347,7 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
} else
do
frag = &(*frag)->next;
while ((*frag)->next != NULL);
while (*frag != NULL);
} while (!h.end);
if (q) {
@ -350,6 +356,8 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
proto = proto << 8;
proto += ch;
} while (!(proto & 1));
LogPrintf(LogERROR, "MP: Reassembled frags %ld-%lu\n",
first, (u_long)h.seq);
hdlc_DecodePacket(mp->bundle, proto, q, &mp->link);
}
@ -386,24 +394,25 @@ static void
mp_Output(struct mp *mp, struct link *l, struct mbuf *m, int begin, int end)
{
struct mbuf *mo;
u_char *cp;
u_int32_t *seq32;
u_int16_t *seq16;
/* Stuff an MP header on the front of our packet and send it */
mo = mballoc(4, MB_MP);
mo->next = m;
cp = MBUF_CTOP(mo);
seq32 = (u_int32_t *)cp;
seq16 = (u_int16_t *)cp;
*seq32 = 0;
*cp = (begin << 7) | (end << 6);
if (mp->peer_is12bit) {
*seq16 |= (u_int16_t)mp->seq.out;
u_int16_t *seq16;
seq16 = (u_int16_t *)MBUF_CTOP(mo);
*seq16 = htons((begin << 15) | (end << 14) | (u_int16_t)mp->seq.out);
mo->cnt = 2;
} else {
*seq32 |= (u_int32_t)mp->seq.out;
u_int32_t *seq32;
seq32 = (u_int32_t *)MBUF_CTOP(mo);
*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);
mp->seq.out = inc_seq(mp, mp->seq.out);
HdlcOutput(l, PRI_NORMAL, PROTO_MP, mo);
@ -463,7 +472,7 @@ mp_FillQueues(struct bundle *bundle)
mp_Output(mp, &dl->physical->link, mo, begin, end);
begin = 0;
}
if (looped)
if (!dl || looped)
break;
}