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 | * 上記著作権者は,以下の (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: ppp_fsm.h 315 2017-07-23 05:29:40Z coas-nagasima $
|
---|
32 | */
|
---|
33 |
|
---|
34 | /*
|
---|
35 | * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
---|
36 | *
|
---|
37 | * Copyright (c) 1989 Carnegie Mellon 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 Carnegie Mellon University. The name of the
|
---|
46 | * University may not be used to endorse or promote products derived
|
---|
47 | * from this 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 | * $FreeBSD: src/usr.sbin/pppd/fsm.h,v 1.6.2.1 1999/08/29 15:47:00 peter Exp $
|
---|
53 | */
|
---|
54 |
|
---|
55 | /*
|
---|
56 | * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
---|
57 | *
|
---|
58 | * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
|
---|
59 | *
|
---|
60 | * Redistribution and use in source and binary forms are permitted
|
---|
61 | * provided that the above copyright notice and this paragraph are
|
---|
62 | * duplicated in all such forms and that any documentation,
|
---|
63 | * advertising materials, and other materials related to such
|
---|
64 | * distribution and use acknowledge that the software was developed
|
---|
65 | * by the Internet Initiative Japan. The name of the
|
---|
66 | * IIJ may not be used to endorse or promote products derived
|
---|
67 | * from this software without specific prior written permission.
|
---|
68 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
---|
69 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
---|
70 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
71 | *
|
---|
72 | * $FreeBSD: src/usr.sbin/ppp/fsm.h,v 1.23 1999/12/27 11:54:53 brian Exp $
|
---|
73 | *
|
---|
74 | * TODO:
|
---|
75 | */
|
---|
76 |
|
---|
77 | #ifndef _PPP_FSM_H_
|
---|
78 | #define _PPP_FSM_H_
|
---|
79 |
|
---|
80 | #ifdef SUPPORT_PPP
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * 状態管理構造体
|
---|
84 | */
|
---|
85 |
|
---|
86 | struct t_ppp_fsm_callbacks;
|
---|
87 |
|
---|
88 | typedef struct t_fsm {
|
---|
89 | struct t_ppp_fsm_callbacks *callbacks; /* コールバック関数*/
|
---|
90 | uint16_t proto; /* プロトコル */
|
---|
91 | uint8_t state; /* FSM の状態 */
|
---|
92 | uint8_t id; /* 現在の ID */
|
---|
93 | uint8_t reqid; /* 要求 ID */
|
---|
94 | uint8_t seen_ack; /* 要求に対し正常な ACK/NAK/REJ を受信 */
|
---|
95 | int8_t failures; /* 黙認した NAK 数 */
|
---|
96 | int8_t retrans; /* Configure-Request または、 */
|
---|
97 | /* Terminate-Request の再送回数 */
|
---|
98 | } T_PPP_FSM;
|
---|
99 |
|
---|
100 | #define T_PPP_FSM_DEFINED
|
---|
101 |
|
---|
102 | /*
|
---|
103 | * コールバック関数構造体
|
---|
104 | */
|
---|
105 |
|
---|
106 | typedef struct t_ppp_fsm_callbacks {
|
---|
107 | void (*resetci) (T_PPP_FSM *); /* 自構成情報をリセットする。 */
|
---|
108 | int_t (*cilen) (T_PPP_FSM *); /* 構成情報の長さを返す。 */
|
---|
109 | void (*addci) (T_PPP_FSM *, T_NET_BUF *);
|
---|
110 | /* 自構成情報を追加する。 */
|
---|
111 | bool_t (*ackci) (T_PPP_FSM *, T_NET_BUF *);
|
---|
112 | /* ACK を受信したときの処理 */
|
---|
113 | int_t (*nakci) (T_PPP_FSM *, T_NET_BUF *);
|
---|
114 | /* NAK を受信したときの処理 */
|
---|
115 | int_t (*rejci) (T_PPP_FSM *, T_NET_BUF *);
|
---|
116 | /* REJ を受信したときの処理 */
|
---|
117 | int_t (*reqci) (T_PPP_FSM *, T_NET_BUF *, T_NET_BUF *);
|
---|
118 | /* 相手の構成情報を確認する。 */
|
---|
119 | void (*up) (T_PPP_FSM *); /* リンクの接続を確立する。 */
|
---|
120 | void (*down) (T_PPP_FSM *); /* リンクの接続を解放する。 */
|
---|
121 | void (*starting)(T_PPP_FSM *); /* 下位層を開始する。 */
|
---|
122 | void (*finished)(T_PPP_FSM *); /* 下位層を終了する。 */
|
---|
123 | void (*retrans) (T_PPP_FSM *); /* 再送する。 */
|
---|
124 | /* 不明な CP を受信したときの処理 */
|
---|
125 | bool_t (*extcode)(T_PPP_FSM *, uint8_t, uint8_t, T_NET_BUF *);
|
---|
126 | } T_PPP_FSM_CALLBACKS;
|
---|
127 |
|
---|
128 | /*
|
---|
129 | * FSM の状態
|
---|
130 | */
|
---|
131 |
|
---|
132 | #define PPP_FSM_INITIAL 0 /* 未接続、未オープン */
|
---|
133 | #define PPP_FSM_STARTING 1 /* 未接続、オープン */
|
---|
134 | #define PPP_FSM_CLOSED 2 /* 接続、 未オープン */
|
---|
135 | #define PPP_FSM_STOPPED 3 /* オープン、切断待ち */
|
---|
136 | #define PPP_FSM_CLOSING 4 /* 切断中、未オープン */
|
---|
137 | #define PPP_FSM_STOPPING 5 /* 切断中、オープン */
|
---|
138 | #define PPP_FSM_REQSENT 6 /* Config REQ 送信済み */
|
---|
139 | #define PPP_FSM_ACKRCVD 7 /* Config ACK 受信済み */
|
---|
140 | #define PPP_FSM_ACKSENT 8 /* Config ACK 送信済み */
|
---|
141 | #define PPP_FSM_OPENED 9 /* 接続、通信可能 */
|
---|
142 |
|
---|
143 | /*
|
---|
144 | * オープン時の動作モード
|
---|
145 | */
|
---|
146 |
|
---|
147 | #define PPP_OPEN_PASSIVE false /* 受動オープン */
|
---|
148 | #define PPP_OPEN_ACTIVE true /* 能動オープン */
|
---|
149 |
|
---|
150 | /*
|
---|
151 | * 再送、タイムアウトの既定値
|
---|
152 | */
|
---|
153 |
|
---|
154 | #define DEF_PPP_TIMEOUT (3*NET_TIMER_HZ)
|
---|
155 | /* RFC1661 では 3 秒 */
|
---|
156 | #define MAX_PPP_TERMINATES 2 /* Terminate-Requests の最大再送回数 */
|
---|
157 | /* RFC1661 では 2 回 */
|
---|
158 | #define MAX_PPP_CONFIGURES 10 /* Configure-Requests の最大再送回数 */
|
---|
159 | /* RFC1661 では 10 回 */
|
---|
160 | #define MAX_PPP_FAILURES 5 /* Configure-NAK の最大黙認回数 */
|
---|
161 | /* RFC1661 では 5 回 */
|
---|
162 |
|
---|
163 | /*
|
---|
164 | * 関数
|
---|
165 | */
|
---|
166 |
|
---|
167 | extern void fsm_init (T_PPP_FSM *fsm);
|
---|
168 | extern void fsm_lowerup (T_PPP_FSM *fsm);
|
---|
169 | extern void fsm_lowerdown(T_PPP_FSM *fsm);
|
---|
170 | extern void fsm_open (T_PPP_FSM *fsm);
|
---|
171 | extern void fsm_close (T_PPP_FSM *fsm);
|
---|
172 | extern void fsm_input (T_PPP_FSM *fsm, T_NET_BUF *data);
|
---|
173 | extern void fsm_protreject(T_PPP_FSM *fsm);
|
---|
174 |
|
---|
175 | /*
|
---|
176 | * 変数
|
---|
177 | */
|
---|
178 |
|
---|
179 | extern uint8_t ppp_open_mode;
|
---|
180 |
|
---|
181 | #endif /* of #ifdef SUPPORT_PPP */
|
---|
182 |
|
---|
183 | #endif /* of #ifndef _PPP_FSM_H_ */
|
---|