source: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.c@ 270

Last change on this file since 270 was 270, checked in by coas-nagasima, 7 years ago

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 8.2 KB
Line 
1/*
2 * TINET (TCP/IP Protocol Stack)
3 *
4 * Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
5 * Tomakomai National College of Technology, JAPAN
6 *
7 * 上記著作権者
8は,以下の (1)~(4) の条件か,Free Software Foundation
9 * によってå…
10¬è¡¨ã•ã‚Œã¦ã„ã‚‹ GNU General Public License の Version 2 に記
11 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
12 * を改変したものを含む.以下同じ)を使用・複製・改変・再é…
13å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
14 * 利用と呼ぶ)することを無償で許諾する.
15 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
16 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
17 * スコード中に含まれていること.
18 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
19 * 用できる形で再é…
20å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
21å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
22 * 者
23マニュアルなど)に,上記の著作権表示,この利用条件および下記
24 * の無保証規定を掲載すること.
25 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
26 * 用できない形で再é…
27å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®æ¡ä»¶ã‚’満たすこと.
28 * (a) 再é…
29å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
30マニュアルなど)に,上記の著
31 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
32 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
33 * 害からも,上記著作権者
34およびTOPPERSプロジェクトをå…
35è²¬ã™ã‚‹ã“と.
36 *
37 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
38お
39 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
40 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
41 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
42 *
43 * @(#) $Id: ppp_auth.c 270 2017-02-09 04:03:47Z coas-nagasima $
44 */
45
46/*
47 * auth.c - PPP authentication and phase control.
48 *
49 * Copyright (c) 1993 The Australian National University.
50 * All rights reserved.
51 *
52 * Redistribution and use in source and binary forms are permitted
53 * provided that the above copyright notice and this paragraph are
54 * duplicated in all such forms and that any documentation,
55 * advertising materials, and other materials related to such
56 * distribution and use acknowledge that the software was developed
57 * by the Australian National University. The name of the University
58 * may not be used to endorse or promote products derived from this
59 * software without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
61 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
62 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63 *
64 * Copyright (c) 1989 Carnegie Mellon University.
65 * All rights reserved.
66 *
67 * Redistribution and use in source and binary forms are permitted
68 * provided that the above copyright notice and this paragraph are
69 * duplicated in all such forms and that any documentation,
70 * advertising materials, and other materials related to such
71 * distribution and use acknowledge that the software was developed
72 * by Carnegie Mellon University. The name of the
73 * University may not be used to endorse or promote products derived
74 * from this software without specific prior written permission.
75 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
76 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
77 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
78 */
79
80/*
81 * PPP Secret Key Module
82 *
83 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
84 *
85 * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
86 *
87 * Redistribution and use in source and binary forms are permitted
88 * provided that the above copyright notice and this paragraph are
89 * duplicated in all such forms and that any documentation,
90 * advertising materials, and other materials related to such
91 * distribution and use acknowledge that the software was developed
92 * by the Internet Initiative Japan, Inc. The name of the
93 * IIJ may not be used to endorse or promote products derived
94 * from this software without specific prior written permission.
95 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
96 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
97 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
98 *
99 * $FreeBSD: src/usr.sbin/ppp/auth.c,v 1.50 1999/12/27 11:43:30 brian Exp $
100 *
101 * TODO:
102 * o Implement check against with registered IP addresses.
103 */
104
105#include <s_services.h>
106#include <t_services.h>
107
108#include <tinet_defs.h>
109#include <tinet_config.h>
110
111#include <net/if.h>
112#include <net/if_ppp.h>
113#include <net/net.h>
114#include <net/net_buf.h>
115#include <net/ppp.h>
116#include <net/ppp_var.h>
117#include <net/ppp_auth.h>
118#include <net/ppp_fsm.h>
119#include <net/ppp_lcp.h>
120#include <net/ppp_upap.h>
121
122#ifdef SUPPORT_PPP
123
124/*
125 * 定数
126 */
127
128#define PAP_PEND_SERVER UINT_C(0x01)
129#define PAP_PEND_CLIENT UINT_C(0x02)
130#define CHAP_PEND_SERVER UINT_C(0x04)
131#define CHAP_PEND_CLIENT UINT_C(0x08)
132
133/*
134 * network_phase -- コネクション確立
135 */
136
137void
138network_phase (void)
139{
140 int_t num, ix;
141 T_PPP_PROTENT *proto;
142
143 ppp_phase = PPP_PHASE_NETWORK;
144
145 /* 上位プロトコルをオープンする */
146 num = 0;
147 for (ix = 0; (proto = protocols[ix]) != NULL; ix ++)
148#if 0 /* 保留、削除禁止 */
149 if (proto->proto < 0xc000 && proto->open != NULL) {
150#else /* of #if 0 */
151 if (proto->open != NULL) {
152#endif /* of #if 0 */
153 (*proto->open)();
154 if (proto->proto != PPP_CCP)
155 num ++;
156 }
157
158 if (num == 0)
159 /* 上位プロトコルがない */
160 lcp_close();
161 else
162 syslog(LOG_NOTICE, "[PPP] up.");
163 }
164
165/*
166 * link_required -- リンクを開設する。
167 */
168
169void
170link_required (void)
171{
172 }
173
174/*
175 * link_terminated -- ログアウトして、リンクを切断する。
176 */
177
178void
179link_terminated (void)
180{
181 ppp_phase = PPP_PHASE_DEAD;
182 ppp_open_mode = PPP_OPEN_PASSIVE;
183 syslog(LOG_NOTICE, "[PPP] down.");
184 }
185
186/*
187 * link_down -- リンクを解放する。
188 */
189
190void
191link_down (void)
192{
193 int_t ix;
194 T_PPP_PROTENT *proto;
195
196 /* 上位プロトコルを解放する */
197 for (ix = 0; (proto = protocols[ix]) != NULL; ix ++) {
198 if (proto->proto != PPP_LCP && proto->lowerdown != NULL)
199 (*proto->lowerdown)();
200 if (proto->proto < 0xc000 && proto->close != NULL)
201 (*proto->close)();
202 }
203
204 if (ppp_phase != PPP_PHASE_DEAD)
205 ppp_phase = PPP_PHASE_TERMINATE;
206 }
207
208/*
209 * link_established -- リンクの接続が確立した。
210 */
211
212void
213link_established (void)
214{
215 int_t ix;
216 T_PPP_PROTENT *proto;
217
218#if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP)
219
220 int auth;
221
222#endif /* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
223
224 /* 上位プロトコルを起動する */
225 for (ix = 0; (proto = protocols[ix]) != NULL; ix ++)
226 if (proto->lowerup != NULL)
227 (*proto->lowerup)();
228
229 /* 認証オプションを確認する。【未実装
230】*/
231
232 ppp_phase = PPP_PHASE_AUTHENTICATE;
233
234#if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP)
235
236 auth = 0;
237
238#ifdef AUTH_CFG_SERVER
239
240#if defined(LCP_CFG_CHAP)
241
242 if (lcp_local_ack_cfg.options & LCP_CFG_CHAP) {
243 chap_auth_server();
244 auth |= CHAP_PEND_SERVER;
245 }
246
247#endif /* of #if defined(LCP_CFG_CHAP) */
248
249#if defined(LCP_CFG_PAP)
250
251 if (lcp_local_ack_cfg.options & LCP_CFG_PAP) {
252 upap_auth_server();
253 auth |= PAP_PEND_SERVER;
254 }
255
256#endif /* of #if defined(LCP_CFG_PAP) */
257
258#endif /* of #ifdef AUTH_CFG_SERVER */
259
260#ifdef AUTH_CFG_CLIENT
261
262#if defined(LCP_CFG_PAP)
263
264 if (lcp_remote_ack_cfg.options & LCP_CFG_PAP) {
265 upap_auth_client();
266 auth |= PAP_PEND_CLIENT;
267 }
268
269#endif /* of #if defined(LCP_CFG_PAP) */
270
271#endif /* of #ifdef AUTH_CFG_CLIENT */
272
273 if (auth == 0)
274 network_phase();
275
276#else /* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
277
278 network_phase();
279
280#endif /* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
281
282 }
283
284/*
285 * auth_reset -- 認証オプションを再確認する。
286 */
287
288void
289auth_reset (void)
290{
291 }
292
293#endif /* fo #ifdef SUPPORT_PPP */
Note: See TracBrowser for help on using the repository browser.