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

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

文字コードを設定

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