[317] | 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_ccp.c 317 2017-08-03 13:14:26Z coas-nagasima $
|
---|
| 44 | */
|
---|
| 45 |
|
---|
| 46 | /*
|
---|
| 47 | * ccp.c - PPP Compression Control Protocol.
|
---|
| 48 | *
|
---|
| 49 | * Copyright (c) 1994 The Australian National University.
|
---|
| 50 | * All rights reserved.
|
---|
| 51 | *
|
---|
| 52 | * Permission to use, copy, modify, and distribute this software and its
|
---|
| 53 | * documentation is hereby granted, provided that the above copyright
|
---|
| 54 | * notice appears in all copies. This software is provided without any
|
---|
| 55 | * warranty, express or implied. The Australian National University
|
---|
| 56 | * makes no representations about the suitability of this software for
|
---|
| 57 | * any purpose.
|
---|
| 58 | *
|
---|
| 59 | * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
|
---|
| 60 | * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
---|
| 61 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
|
---|
| 62 | * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
|
---|
| 63 | * OF SUCH DAMAGE.
|
---|
| 64 | *
|
---|
| 65 | * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
---|
| 66 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
| 67 | * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
---|
| 68 | * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
|
---|
| 69 | * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
---|
| 70 | * OR MODIFICATIONS.
|
---|
| 71 | */
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * PPP Compression Control Protocol (CCP) Module
|
---|
| 75 | *
|
---|
| 76 | * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
---|
| 77 | *
|
---|
| 78 | * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
|
---|
| 79 | *
|
---|
| 80 | * Redistribution and use in source and binary forms are permitted
|
---|
| 81 | * provided that the above copyright notice and this paragraph are
|
---|
| 82 | * duplicated in all such forms and that any documentation,
|
---|
| 83 | * advertising materials, and other materials related to such
|
---|
| 84 | * distribution and use acknowledge that the software was developed
|
---|
| 85 | * by the Internet Initiative Japan, Inc. The name of the
|
---|
| 86 | * IIJ may not be used to endorse or promote products derived
|
---|
| 87 | * from this software without specific prior written permission.
|
---|
| 88 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
---|
| 89 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
---|
| 90 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 91 | *
|
---|
| 92 | * $FreeBSD: src/usr.sbin/ppp/ccp.c,v 1.54.2.2 2000/08/19 09:29:59 brian Exp $
|
---|
| 93 | *
|
---|
| 94 | * TODO:
|
---|
| 95 | * o Support other compression protocols
|
---|
| 96 | */
|
---|
| 97 |
|
---|
| 98 | /*
|
---|
| 99 | * å®è£
|
---|
| 100 | äºå®ãç¾å¨ã¯ãã¹ã¦æå¦
|
---|
| 101 | */
|
---|
| 102 |
|
---|
| 103 | #include <t_services.h>
|
---|
| 104 |
|
---|
| 105 | #include <net/if.h>
|
---|
| 106 | #include <net/if_ppp.h>
|
---|
| 107 | #include <net/net_buf.h>
|
---|
| 108 | #include <net/net_count.h>
|
---|
| 109 | #include <net/ppp.h>
|
---|
| 110 | #include <net/ppp_var.h>
|
---|
| 111 | #include <net/ppp_fsm.h>
|
---|
| 112 | #include <net/ppp_ccp.h>
|
---|
| 113 |
|
---|
| 114 | /*
|
---|
| 115 | * é¢æ°
|
---|
| 116 | */
|
---|
| 117 |
|
---|
| 118 | static void ccp_init (void);
|
---|
| 119 | static void ccp_input (T_NET_BUF *nbuf);
|
---|
| 120 | static void ccp_protrej (void);
|
---|
| 121 | static void ccp_lowerup (void);
|
---|
| 122 | static void ccp_lowerdown (void);
|
---|
| 123 | static void ccp_open (void);
|
---|
| 124 | static void ccp_close (void);
|
---|
| 125 |
|
---|
| 126 | /*
|
---|
| 127 | * FSM ããå¼åºãããã³ã¼ã«ããã¯é¢
|
---|
| 128 | */
|
---|
| 129 |
|
---|
| 130 | static int_t ccp_reqci (T_PPP_FSM *fsm, T_NET_BUF *nbuf);
|
---|
| 131 | /* ç¸æã®æ§ææ
|
---|
| 132 | å ±ã確èªããã */
|
---|
| 133 |
|
---|
| 134 | /*
|
---|
| 135 | * å
|
---|
| 136 | ¨åå¤æ°
|
---|
| 137 | */
|
---|
| 138 |
|
---|
| 139 | T_PPP_FSM_CALLBACKS ccp_callbacks = {
|
---|
| 140 | NULL, /* èªæ§ææ
|
---|
| 141 | å ±ããªã»ããããã */
|
---|
| 142 | NULL, /* æ§ææ
|
---|
| 143 | å ±ã®é·ããè¿ãã */
|
---|
| 144 | NULL, /* èªæ§ææ
|
---|
| 145 | å ±ã追å ããã */
|
---|
| 146 | NULL, /* ACK ãåä¿¡ããã¨ãã®å¦ç */
|
---|
| 147 | NULL, /* NAK ãåä¿¡ããã¨ãã®å¦ç */
|
---|
| 148 | NULL, /* REJ ãåä¿¡ããã¨ãã®å¦ç */
|
---|
| 149 | ccp_reqci, /* ç¸æã®æ§ææ
|
---|
| 150 | å ±ã確èªããã */
|
---|
| 151 | NULL, /* ãªã³ã¯æ¥ç¶ã確ç«ããã */
|
---|
| 152 | NULL, /* ãªã³ã¯æ¥ç¶ã解æ¾ããã */
|
---|
| 153 | NULL, /* ä¸ä½å±¤ãéå§ããã */
|
---|
| 154 | NULL, /* ä¸ä½å±¤ãçµäºããã */
|
---|
| 155 | NULL, /* åéããã */
|
---|
| 156 | NULL, /* ä¸æ㪠CP ãåä¿¡ããã¨ãã®å¦ç */
|
---|
| 157 | };
|
---|
| 158 |
|
---|
| 159 | T_PPP_FSM ccp_fsm = {
|
---|
| 160 | &ccp_callbacks, /* ã³ã¼ã«ããã¯é¢æ° */
|
---|
| 161 | PPP_CCP, /* ãããã³ã« */
|
---|
| 162 | };
|
---|
| 163 |
|
---|
| 164 | T_PPP_PROTENT ccp_protent = {
|
---|
| 165 | PPP_CCP,
|
---|
| 166 | ccp_init, /* åæå */
|
---|
| 167 | ccp_input, /* å
|
---|
| 168 | ¥å */
|
---|
| 169 | ccp_protrej, /* Proto-REJ åä¿¡å¦ç */
|
---|
| 170 | ccp_lowerup, /* ä¸ä½å±¤ãèµ·åãã */
|
---|
| 171 | ccp_lowerdown, /* ä¸ä½å±¤ãåæ¢ãã */
|
---|
| 172 | ccp_open, /* ãªã¼ãã³ãã */
|
---|
| 173 | ccp_close, /* ã¯ãã¼ãºãã */
|
---|
| 174 | NULL, /* ãã¼ã¿å
|
---|
| 175 | ¥å */
|
---|
| 176 | };
|
---|
| 177 |
|
---|
| 178 | /*
|
---|
| 179 | * ccp_init -- CCP ã¢ã¸ã¥ã¼ã«ã®åæå
|
---|
| 180 | */
|
---|
| 181 |
|
---|
| 182 | static void
|
---|
| 183 | ccp_init (void)
|
---|
| 184 | {
|
---|
| 185 | fsm_init(&ccp_fsm);
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | /*
|
---|
| 189 | * ccp_input -- CCP å
|
---|
| 190 | ¥å
|
---|
| 191 | */
|
---|
| 192 |
|
---|
| 193 | static void
|
---|
| 194 | ccp_input (T_NET_BUF *nbuf)
|
---|
| 195 | {
|
---|
| 196 | NET_COUNT_PPP_CCP(net_count_ppp_ccp_in_octets, nbuf->len);
|
---|
| 197 | NET_COUNT_PPP_CCP(net_count_ppp_ccp_in_packets, 1);
|
---|
| 198 | fsm_input(&ccp_fsm, nbuf);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | /*
|
---|
| 202 | * ccp_reqci -- ç¸æã®æ§ææ
|
---|
| 203 | å ±ã解æããã
|
---|
| 204 | */
|
---|
| 205 |
|
---|
| 206 | static int_t
|
---|
| 207 | ccp_reqci (T_PPP_FSM *fsm, T_NET_BUF *nbuf)
|
---|
| 208 | {
|
---|
| 209 | /*
|
---|
| 210 | * å®è£
|
---|
| 211 | äºå®ãç¾å¨ã¯ãã¹ã¦ã®ãªãã·ã§ã³ãæå¦ããã
|
---|
| 212 | */
|
---|
| 213 | return nbuf->len > (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)) ? PPP_CONFREJ : PPP_CONFACK;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | /*
|
---|
| 217 | * ccp_protrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
|
---|
| 218 | */
|
---|
| 219 |
|
---|
| 220 | static void
|
---|
| 221 | ccp_protrej (void)
|
---|
| 222 | {
|
---|
| 223 | fsm_lowerdown(&ccp_fsm);
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | /*
|
---|
| 227 | * ccp_lowerup -- CCP ä¸ä½å±¤ãèµ·åããã
|
---|
| 228 | */
|
---|
| 229 |
|
---|
| 230 | static void
|
---|
| 231 | ccp_lowerup (void)
|
---|
| 232 | {
|
---|
| 233 | fsm_lowerup(&ccp_fsm);
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | /*
|
---|
| 237 | * ccp_lowerdown -- CCP ä¸ä½å±¤ãåæ¢ããã
|
---|
| 238 | */
|
---|
| 239 |
|
---|
| 240 | static void
|
---|
| 241 | ccp_lowerdown (void)
|
---|
| 242 | {
|
---|
| 243 | fsm_lowerdown(&ccp_fsm);
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | /*
|
---|
| 247 | * ccp_open -- CCP ã®ãªã¼ã
|
---|
| 248 | */
|
---|
| 249 |
|
---|
| 250 | static void
|
---|
| 251 | ccp_open (void)
|
---|
| 252 | {
|
---|
| 253 | fsm_open(&ccp_fsm);
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | /*
|
---|
| 257 | * ccp_close -- CCP ã®ã¯ãã¼ãº
|
---|
| 258 | */
|
---|
| 259 |
|
---|
| 260 | static void
|
---|
| 261 | ccp_close (void)
|
---|
| 262 | {
|
---|
| 263 | fsm_close(&ccp_fsm);
|
---|
| 264 | }
|
---|