Deleted Added
sdiff udiff text old ( 31171 ) new ( 31272 )
full compact
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
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: ipcp.c,v 1.36 1997/11/14 15:39:14 brian Exp $
21 *
22 * TODO:
23 * o More RFC1772 backwoard compatibility
24 */
25#include <sys/param.h>
26#include <netinet/in_systm.h>
27#include <netinet/in.h>
28#include <netinet/ip.h>
29#include <arpa/inet.h>
30#include <sys/socket.h>
31#include <netdb.h>
32
33#include <limits.h>
34#include <stdio.h>
35#include <string.h>
36#include <time.h>
37#include <unistd.h>
38
39#include "mbuf.h"
40#include "log.h"
41#include "defs.h"
42#include "timer.h"
43#include "fsm.h"
44#include "lcpproto.h"
45#include "lcp.h"
46#include "ipcp.h"
47#include "slcompress.h"
48#include "os.h"
49#include "phase.h"
50#include "loadalias.h"
51#include "command.h"
52#include "vars.h"
53#include "vjcomp.h"
54#include "ip.h"
55#include "throughput.h"
56
57#ifndef NOMSEXT
58struct in_addr ns_entries[2];
59struct in_addr nbns_entries[2];
60#endif
61
62struct ipcpstate IpcpInfo;
63struct in_range DefMyAddress;
64struct in_range DefHisAddress;
65struct in_addr TriggerAddress;
66int HaveTriggerAddress;
67
68static void IpcpSendConfigReq(struct fsm *);
69static void IpcpSendTerminateAck(struct fsm *);
70static void IpcpSendTerminateReq(struct fsm *);
71static void IpcpDecodeConfig(u_char *, int, int);
72static void IpcpLayerStart(struct fsm *);
73static void IpcpLayerFinish(struct fsm *);
74static void IpcpLayerUp(struct fsm *);
75static void IpcpLayerDown(struct fsm *);
76static void IpcpInitRestartCounter(struct fsm *);
77
78#define REJECTED(p, x) (p->his_reject & (1<<x))
79
80struct fsm IpcpFsm = {
81 "IPCP",
82 PROTO_IPCP,
83 IPCP_MAXCODE,
84 OPEN_ACTIVE,
85 ST_INITIAL,

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

117 "PRIDNS", /* 129: Primary DNS Server Address */
118 "PRINBNS", /* 130: Primary NBNS Server Address */
119 "SECDNS", /* 131: Secondary DNS Server Address */
120 "SECNBNS", /* 132: Secondary NBNS Server Address */
121};
122
123#define NCFTYPES128 (sizeof(cftypes)/sizeof(char *))
124
125struct pppThroughput throughput;
126
127void
128IpcpAddInOctets(int n)
129{
130 throughput_addin(&throughput, n);
131}
132
133void
134IpcpAddOutOctets(int n)
135{
136 throughput_addout(&throughput, n);
137}
138
139int
140ReportIpcpStatus()
141{
142 struct ipcpstate *icp = &IpcpInfo;
143 struct fsm *fp = &IpcpFsm;
144
145 if (!VarTerm)
146 return 1;
147 fprintf(VarTerm, "%s [%s]\n", fp->name, StateNames[fp->state]);
148 fprintf(VarTerm, " his side: %s, %lx\n",
149 inet_ntoa(icp->his_ipaddr), icp->his_compproto);
150 fprintf(VarTerm, " my side: %s, %lx\n",
151 inet_ntoa(icp->want_ipaddr), icp->want_compproto);
152
153 fprintf(VarTerm, "Defaults:\n");
154 fprintf(VarTerm, " My Address: %s/%d\n",
155 inet_ntoa(DefMyAddress.ipaddr), DefMyAddress.width);
156 fprintf(VarTerm, " His Address: %s/%d\n",
157 inet_ntoa(DefHisAddress.ipaddr), DefHisAddress.width);
158 if (HaveTriggerAddress)
159 fprintf(VarTerm, " Negotiation(trigger): %s\n", inet_ntoa(TriggerAddress));
160 else
161 fprintf(VarTerm, " Negotiation(trigger): MYADDR\n");
162
163 fprintf(VarTerm, "\n");
164 throughput_disp(&throughput, VarTerm);
165
166 return 0;
167}
168
169void
170IpcpDefAddress()
171{
172 struct hostent *hp;
173 char name[200];

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

208 LogPrintf(LogIPCP, "Using trigger address %s\n", inet_ntoa(TriggerAddress));
209 }
210 if (Enabled(ConfVjcomp))
211 icp->want_compproto = (PROTO_VJCOMP << 16) | ((MAX_STATES - 1) << 8) | 1;
212 else
213 icp->want_compproto = 0;
214 icp->heis1172 = 0;
215 IpcpFsm.maxconfig = 10;
216 throughput_init(&throughput);
217}
218
219static void
220IpcpInitRestartCounter(struct fsm * fp)
221{
222 fp->FsmTimer.load = VarRetryTimeout * SECTICKS;
223 fp->restart = 5;
224}

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

267IpcpLayerFinish(struct fsm * fp)
268{
269 LogPrintf(LogIPCP, "IpcpLayerFinish.\n");
270 reconnect(RECON_FALSE);
271 LcpClose();
272 NewPhase(PHASE_TERMINATE);
273}
274
275static void
276IpcpLayerDown(struct fsm * fp)
277{
278 LogPrintf(LogIPCP, "IpcpLayerDown.\n");
279 throughput_stop(&throughput);
280 throughput_log(&throughput, LogIPCP, NULL);
281}
282
283/*
284 * Called when IPCP has reached to OPEN state
285 */
286static void
287IpcpLayerUp(struct fsm * fp)
288{

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

301 if (OsSetIpaddress(IpcpInfo.want_ipaddr, IpcpInfo.his_ipaddr, ifnetmask) < 0) {
302 if (VarTerm)
303 LogPrintf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
304 return;
305 }
306 if (mode & MODE_ALIAS)
307 VarPacketAliasSetAddress(IpcpInfo.want_ipaddr);
308 OsLinkup();
309 throughput_start(&throughput);
310 StartIdleTimer();
311}
312
313void
314IpcpUp()
315{
316 FsmUp(&IpcpFsm);
317 LogPrintf(LogIPCP, "IPCP Up event!!\n");

--- 282 unchanged lines hidden ---