Deleted Added
full compact
chap.c (46686) chap.c (47695)
1/*
2 * PPP CHAP Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * PPP CHAP Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: chap.c,v 1.49 1999/04/21 08:03:51 brian Exp $
20 * $Id: chap.c,v 1.50 1999/05/08 11:06:15 brian Exp $
21 *
22 * TODO:
23 */
24#include <sys/param.h>
25#include <netinet/in.h>
26#include <netinet/in_systm.h>
27#include <netinet/ip.h>
28#include <sys/un.h>

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

88 int plen;
89 struct fsmheader lh;
90 struct mbuf *bp;
91
92 plen = sizeof(struct fsmheader) + count;
93 lh.code = code;
94 lh.id = id;
95 lh.length = htons(plen);
21 *
22 * TODO:
23 */
24#include <sys/param.h>
25#include <netinet/in.h>
26#include <netinet/in_systm.h>
27#include <netinet/ip.h>
28#include <sys/un.h>

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

88 int plen;
89 struct fsmheader lh;
90 struct mbuf *bp;
91
92 plen = sizeof(struct fsmheader) + count;
93 lh.code = code;
94 lh.id = id;
95 lh.length = htons(plen);
96 bp = mbuf_Alloc(plen, MB_FSM);
96 bp = mbuf_Alloc(plen, MB_CHAPOUT);
97 memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
98 if (count)
99 memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count);
100 log_DumpBp(LogDEBUG, "ChapOutput", bp);
101 if (text == NULL)
102 log_Printf(LogPHASE, "Chap Output: %s\n", chapcodes[code]);
103 else
104 log_Printf(LogPHASE, "Chap Output: %s (%s)\n", chapcodes[code], text);

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

554
555 if (bundle_Phase(bundle) != PHASE_NETWORK &&
556 bundle_Phase(bundle) != PHASE_AUTHENTICATE) {
557 log_Printf(LogPHASE, "Unexpected chap input - dropped !\n");
558 mbuf_Free(bp);
559 return NULL;
560 }
561
97 memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
98 if (count)
99 memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count);
100 log_DumpBp(LogDEBUG, "ChapOutput", bp);
101 if (text == NULL)
102 log_Printf(LogPHASE, "Chap Output: %s\n", chapcodes[code]);
103 else
104 log_Printf(LogPHASE, "Chap Output: %s (%s)\n", chapcodes[code], text);

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

554
555 if (bundle_Phase(bundle) != PHASE_NETWORK &&
556 bundle_Phase(bundle) != PHASE_AUTHENTICATE) {
557 log_Printf(LogPHASE, "Unexpected chap input - dropped !\n");
558 mbuf_Free(bp);
559 return NULL;
560 }
561
562 mbuf_SetType(bp, MB_CHAPIN);
562 if ((bp = auth_ReadHeader(&chap->auth, bp)) == NULL &&
563 ntohs(chap->auth.in.hdr.length) == 0)
564 log_Printf(LogWARN, "Chap Input: Truncated header !\n");
565 else if (chap->auth.in.hdr.code == 0 || chap->auth.in.hdr.code > MAXCHAPCODE)
566 log_Printf(LogPHASE, "Chap Input: %d: Bad CHAP code !\n",
567 chap->auth.in.hdr.code);
568 else {
569 len = mbuf_Length(bp);

--- 204 unchanged lines hidden ---
563 if ((bp = auth_ReadHeader(&chap->auth, bp)) == NULL &&
564 ntohs(chap->auth.in.hdr.length) == 0)
565 log_Printf(LogWARN, "Chap Input: Truncated header !\n");
566 else if (chap->auth.in.hdr.code == 0 || chap->auth.in.hdr.code > MAXCHAPCODE)
567 log_Printf(LogPHASE, "Chap Input: %d: Bad CHAP code !\n",
568 chap->auth.in.hdr.code);
569 else {
570 len = mbuf_Length(bp);

--- 204 unchanged lines hidden ---