source: rubycfg_asp/trunk/asp_dcre/tinet/net/ppp_auth.c@ 313

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

ソースを追加

  • 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.3 KB
Line 
1/*
2 * TINET (TCP/IP Protocol Stack)
3 *
4 * Copyright (C) 2001-2017 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 313 2017-07-23 04:50:32Z 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_endian.h>
115#include <net/net_buf.h>
116#include <net/ppp.h>
117#include <net/ppp_var.h>
118#include <net/ppp_auth.h>
119#include <net/ppp_fsm.h>
120#include <net/ppp_lcp.h>
121#include <net/ppp_upap.h>
122
123#ifdef SUPPORT_PPP
124
125/*
126 * 定数
127 */
128
129#define PAP_PEND_SERVER UINT_C(0x01)
130#define PAP_PEND_CLIENT UINT_C(0x02)
131#define CHAP_PEND_SERVER UINT_C(0x04)
132#define CHAP_PEND_CLIENT UINT_C(0x08)
133
134/*
135 * network_phase -- コネクション確立
136 */
137
138void
139network_phase (void)
140{
141 int_t num, ix;
142 T_PPP_PROTENT *proto;
143
144 ppp_phase = PPP_PHASE_NETWORK;
145
146 /* 上位プロトコルをオープンする */
147 num = 0;
148 for (ix = 0; (proto = protocols[ix]) != NULL; ix ++)
149#if 0 /* 保留、削除禁止 */
150 if (proto->proto < 0xc000 && proto->open != NULL) {
151#else /* of #if 0 */
152 if (proto->open != NULL) {
153#endif /* of #if 0 */
154 (*proto->open)();
155 if (proto->proto != PPP_CCP)
156 num ++;
157 }
158
159 if (num == 0)
160 /* 上位プロトコルがない */
161 lcp_close();
162 else
163 syslog(LOG_NOTICE, "[PPP] up.");
164 }
165
166/*
167 * link_required -- リンクを開設する。
168 */
169
170void
171link_required (void)
172{
173 }
174
175/*
176 * link_terminated -- ログアウトして、リンクを切断する。
177 */
178
179void
180link_terminated (void)
181{
182 ppp_phase = PPP_PHASE_DEAD;
183 ppp_open_mode = PPP_OPEN_PASSIVE;
184 syslog(LOG_NOTICE, "[PPP] down.");
185 }
186
187/*
188 * link_down -- リンクを解放する。
189 */
190
191void
192link_down (void)
193{
194 int_t ix;
195 T_PPP_PROTENT *proto;
196
197 /* 上位プロトコルを解放する */
198 for (ix = 0; (proto = protocols[ix]) != NULL; ix ++) {
199 if (proto->proto != PPP_LCP && proto->lowerdown != NULL)
200 (*proto->lowerdown)();
201 if (proto->proto < 0xc000 && proto->close != NULL)
202 (*proto->close)();
203 }
204
205 if (ppp_phase != PPP_PHASE_DEAD)
206 ppp_phase = PPP_PHASE_TERMINATE;
207 }
208
209/*
210 * link_established -- リンクの接続が確立した。
211 */
212
213void
214link_established (void)
215{
216 int_t ix;
217 T_PPP_PROTENT *proto;
218
219#if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP)
220
221 int auth;
222
223#endif /* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
224
225 /* 上位プロトコルを起動する */
226 for (ix = 0; (proto = protocols[ix]) != NULL; ix ++)
227 if (proto->lowerup != NULL)
228 (*proto->lowerup)();
229
230 /* 認証オプションを確認する。【未実装
231】*/
232
233 ppp_phase = PPP_PHASE_AUTHENTICATE;
234
235#if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP)
236
237 auth = 0;
238
239#ifdef AUTH_CFG_SERVER
240
241#if defined(LCP_CFG_CHAP)
242
243 if (lcp_local_ack_cfg.options & LCP_CFG_CHAP) {
244 chap_auth_server();
245 auth |= CHAP_PEND_SERVER;
246 }
247
248#endif /* of #if defined(LCP_CFG_CHAP) */
249
250#if defined(LCP_CFG_PAP)
251
252 if (lcp_local_ack_cfg.options & LCP_CFG_PAP) {
253 upap_auth_server();
254 auth |= PAP_PEND_SERVER;
255 }
256
257#endif /* of #if defined(LCP_CFG_PAP) */
258
259#endif /* of #ifdef AUTH_CFG_SERVER */
260
261#ifdef AUTH_CFG_CLIENT
262
263#if defined(LCP_CFG_PAP)
264
265 if (lcp_remote_ack_cfg.options & LCP_CFG_PAP) {
266 upap_auth_client();
267 auth |= PAP_PEND_CLIENT;
268 }
269
270#endif /* of #if defined(LCP_CFG_PAP) */
271
272#endif /* of #ifdef AUTH_CFG_CLIENT */
273
274 if (auth == 0)
275 network_phase();
276
277#else /* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
278
279 network_phase();
280
281#endif /* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
282
283 }
284
285/*
286 * auth_reset -- 認証オプションを再確認する。
287 */
288
289void
290auth_reset (void)
291{
292 }
293
294#endif /* fo #ifdef SUPPORT_PPP */
Note: See TracBrowser for help on using the repository browser.