[270] | 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 |
|
---|
| 137 | void
|
---|
| 138 | network_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 |
|
---|
| 169 | void
|
---|
| 170 | link_required (void)
|
---|
| 171 | {
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | /*
|
---|
| 175 | * link_terminated -- ãã°ã¢ã¦ããã¦ããªã³ã¯ãåæããã
|
---|
| 176 | */
|
---|
| 177 |
|
---|
| 178 | void
|
---|
| 179 | link_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 |
|
---|
| 190 | void
|
---|
| 191 | link_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 |
|
---|
| 212 | void
|
---|
| 213 | link_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 |
|
---|
| 288 | void
|
---|
| 289 | auth_reset (void)
|
---|
| 290 | {
|
---|
| 291 | }
|
---|
| 292 |
|
---|
| 293 | #endif /* fo #ifdef SUPPORT_PPP */
|
---|