Deleted Added
full compact
ipcp.c (6060) ipcp.c (6735)
1/*
2 * PPP IP Control Protocol (IPCP) 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

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

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:$
1/*
2 * PPP IP Control Protocol (IPCP) 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

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

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:$
21 *
21 *
22 * TODO:
23 * o More RFC1772 backwoard compatibility
24 */
25#include "fsm.h"
26#include "lcpproto.h"
27#include "lcp.h"
28#include "ipcp.h"
29#include <netdb.h>

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

38
39extern void PutConfValue();
40extern void Prompt();
41extern struct in_addr ifnetmask;
42
43struct ipcpstate IpcpInfo;
44struct in_range DefMyAddress, DefHisAddress;
45
22 * TODO:
23 * o More RFC1772 backwoard compatibility
24 */
25#include "fsm.h"
26#include "lcpproto.h"
27#include "lcp.h"
28#include "ipcp.h"
29#include <netdb.h>

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

38
39extern void PutConfValue();
40extern void Prompt();
41extern struct in_addr ifnetmask;
42
43struct ipcpstate IpcpInfo;
44struct in_range DefMyAddress, DefHisAddress;
45
46static void IpcpSendConfigReq(struct fsm *);
47static void IpcpSendTerminateAck(struct fsm *);
48static void IpcpSendTerminateReq(struct fsm *);
49static void IpcpDecodeConfig();
50static void IpcpLayerStart(struct fsm *);
51static void IpcpLayerFinish(struct fsm *);
52static void IpcpLayerUp(struct fsm *);
53static void IpcpLayerDown(struct fsm *);
54static void IpcpInitRestartCounter(struct fsm *);
46static void IpcpSendConfigReq __P((struct fsm *));
47static void IpcpSendTerminateAck __P((struct fsm *));
48static void IpcpSendTerminateReq __P((struct fsm *));
49static void IpcpDecodeConfig __P((u_char *, int, int));
50static void IpcpLayerStart __P((struct fsm *));
51static void IpcpLayerFinish __P((struct fsm *));
52static void IpcpLayerUp __P((struct fsm *));
53static void IpcpLayerDown __P((struct fsm *));
54static void IpcpInitRestartCounter __P((struct fsm *));
55
56static struct pppTimer IpcpReportTimer;
57
58static int lastInOctets, lastOutOctets;
59
60#define REJECTED(p, x) (p->his_reject & (1<<x))
61
62struct fsm IpcpFsm = {

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

169 icp->heis1172 = 0;
170 IpcpFsm.maxconfig = 10;
171}
172
173static void
174IpcpInitRestartCounter(fp)
175struct fsm *fp;
176{
55
56static struct pppTimer IpcpReportTimer;
57
58static int lastInOctets, lastOutOctets;
59
60#define REJECTED(p, x) (p->his_reject & (1<<x))
61
62struct fsm IpcpFsm = {

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

169 icp->heis1172 = 0;
170 IpcpFsm.maxconfig = 10;
171}
172
173static void
174IpcpInitRestartCounter(fp)
175struct fsm *fp;
176{
177 fp->FsmTimer.load = 3 * SECTICKS;
177 fp->FsmTimer.load = VarRetryTimeout * SECTICKS;
178 fp->restart = 5;
179}
180
181static void
182IpcpSendConfigReq(fp)
183struct fsm *fp;
184{
185 u_char *cp;
186 struct ipcpstate *icp = &IpcpInfo;
187
188 cp = ReqBuff;
189 LogPrintf(LOG_LCP, "%s: SendConfigReq\n", fp->name);
178 fp->restart = 5;
179}
180
181static void
182IpcpSendConfigReq(fp)
183struct fsm *fp;
184{
185 u_char *cp;
186 struct ipcpstate *icp = &IpcpInfo;
187
188 cp = ReqBuff;
189 LogPrintf(LOG_LCP, "%s: SendConfigReq\n", fp->name);
190 PutConfValue(&cp, cftypes, TY_IPADDR, 6, ntohl(icp->want_ipaddr.s_addr));
190 if (!DEV_IS_SYNC || !REJECTED(icp, TY_IPADDR))
191 PutConfValue(&cp, cftypes, TY_IPADDR, 6, ntohl(icp->want_ipaddr.s_addr));
191 if (icp->want_compproto && !REJECTED(icp, TY_COMPPROTO)) {
192 if (icp->heis1172)
193 PutConfValue(&cp, cftypes, TY_COMPPROTO, 4, icp->want_compproto >> 16);
194 else
195 PutConfValue(&cp, cftypes, TY_COMPPROTO, 6, icp->want_compproto);
196 }
197 FsmOutput(fp, CODE_CONFIGREQ, fp->reqid++, ReqBuff, cp - ReqBuff);
198}

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

283 logprintf("%x, %x\n", htonl(prange->ipaddr.s_addr & prange->mask.s_addr),
284 htonl(ipaddr.s_addr & prange->mask.s_addr));
285#endif
286 return((prange->ipaddr.s_addr & prange->mask.s_addr) ==
287 (ipaddr.s_addr & prange->mask.s_addr));
288}
289
290static void
192 if (icp->want_compproto && !REJECTED(icp, TY_COMPPROTO)) {
193 if (icp->heis1172)
194 PutConfValue(&cp, cftypes, TY_COMPPROTO, 4, icp->want_compproto >> 16);
195 else
196 PutConfValue(&cp, cftypes, TY_COMPPROTO, 6, icp->want_compproto);
197 }
198 FsmOutput(fp, CODE_CONFIGREQ, fp->reqid++, ReqBuff, cp - ReqBuff);
199}

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

284 logprintf("%x, %x\n", htonl(prange->ipaddr.s_addr & prange->mask.s_addr),
285 htonl(ipaddr.s_addr & prange->mask.s_addr));
286#endif
287 return((prange->ipaddr.s_addr & prange->mask.s_addr) ==
288 (ipaddr.s_addr & prange->mask.s_addr));
289}
290
291static void
291IpcpDecodeConfig(bp, mode)
292struct mbuf *bp;
292IpcpDecodeConfig(cp, plen, mode)
293u_char *cp;
294int plen;
293int mode;
294{
295int mode;
296{
295 u_char *cp;
296 int plen, type, length;
297 int type, length;
297 u_long *lp, compproto;
298 struct compreq *pcomp;
299 struct in_addr ipaddr, dstipaddr;
300 char tbuff[100];
301
298 u_long *lp, compproto;
299 struct compreq *pcomp;
300 struct in_addr ipaddr, dstipaddr;
301 char tbuff[100];
302
302 plen = plength(bp);
303
304 cp = MBUF_CTOP(bp);
305 ackp = AckBuff;
306 nakp = NakBuff;
307 rejp = RejBuff;
308
309 while (plen >= sizeof(struct fsmconfig)) {
310 if (plen < 0)
311 break;
312 type = *cp;

--- 147 unchanged lines hidden ---
303 ackp = AckBuff;
304 nakp = NakBuff;
305 rejp = RejBuff;
306
307 while (plen >= sizeof(struct fsmconfig)) {
308 if (plen < 0)
309 break;
310 type = *cp;

--- 147 unchanged lines hidden ---