source: rubycfg_asp/trunk/asp_dcre/tinet/net/ppp_hdlc.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: 15.6 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_hdlc.c 313 2017-07-23 04:50:32Z coas-nagasima $
44 */
45
46/*
47 * PPP High Level Link Control (HDLC) Module
48 *
49 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
50 *
51 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
52 *
53 * Redistribution and use in source and binary forms are permitted
54 * provided that the above copyright notice and this paragraph are
55 * duplicated in all such forms and that any documentation,
56 * advertising materials, and other materials related to such
57 * distribution and use acknowledge that the software was developed
58 * by the Internet Initiative Japan, Inc. The name of the
59 * IIJ may not be used to endorse or promote products derived
60 * from this software without specific prior written permission.
61 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
62 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
63 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
64 *
65 * $FreeBSD: src/usr.sbin/ppp/hdlc.c,v 1.46 1999/12/20 20:29:42 brian Exp $
66 *
67 * TODO:
68 */
69
70#include <s_services.h>
71#include <t_services.h>
72
73#include <tinet_defs.h>
74#include <tinet_config.h>
75
76#include <net/if.h>
77#include <net/if_ppp.h>
78#include <net/net.h>
79#include <net/net_endian.h>
80#include <net/net_buf.h>
81#include <net/net_count.h>
82#include <net/ppp.h>
83#include <net/ppp_var.h>
84#include <net/ppp_hdlc.h>
85#include <net/ppp_fsm.h>
86#include <net/ppp_lcp.h>
87#include <net/ppp_modem.h>
88
89#ifdef SUPPORT_PPP
90
91/*
92 * RFC1171 (PPP) の HDLC 部の定義
93 */
94
95/*
96 * 変数
97 */
98
99uint32_t remote_ACCM = DEF_REMOTE_ACCM;
100
101/*
102 * 関数
103 */
104
105static ER HDLC_putoctet (uint8_t octet);
106static ER HDLC_getoctet (uint8_t *octet);
107
108/*
109 * genfcstab.c により作成した FCS のルックアップ表
110 * RFC1171 参ç…
111§
112 */
113
114static uint16_t fcstab[256] = {
115 UINT_C(0x0000), UINT_C(0x1189), UINT_C(0x2312), UINT_C(0x329b),
116 UINT_C(0x4624), UINT_C(0x57ad), UINT_C(0x6536), UINT_C(0x74bf),
117 UINT_C(0x8c48), UINT_C(0x9dc1), UINT_C(0xaf5a), UINT_C(0xbed3),
118 UINT_C(0xca6c), UINT_C(0xdbe5), UINT_C(0xe97e), UINT_C(0xf8f7),
119 UINT_C(0x1081), UINT_C(0x0108), UINT_C(0x3393), UINT_C(0x221a),
120 UINT_C(0x56a5), UINT_C(0x472c), UINT_C(0x75b7), UINT_C(0x643e),
121 UINT_C(0x9cc9), UINT_C(0x8d40), UINT_C(0xbfdb), UINT_C(0xae52),
122 UINT_C(0xdaed), UINT_C(0xcb64), UINT_C(0xf9ff), UINT_C(0xe876),
123 UINT_C(0x2102), UINT_C(0x308b), UINT_C(0x0210), UINT_C(0x1399),
124 UINT_C(0x6726), UINT_C(0x76af), UINT_C(0x4434), UINT_C(0x55bd),
125 UINT_C(0xad4a), UINT_C(0xbcc3), UINT_C(0x8e58), UINT_C(0x9fd1),
126 UINT_C(0xeb6e), UINT_C(0xfae7), UINT_C(0xc87c), UINT_C(0xd9f5),
127 UINT_C(0x3183), UINT_C(0x200a), UINT_C(0x1291), UINT_C(0x0318),
128 UINT_C(0x77a7), UINT_C(0x662e), UINT_C(0x54b5), UINT_C(0x453c),
129 UINT_C(0xbdcb), UINT_C(0xac42), UINT_C(0x9ed9), UINT_C(0x8f50),
130 UINT_C(0xfbef), UINT_C(0xea66), UINT_C(0xd8fd), UINT_C(0xc974),
131 UINT_C(0x4204), UINT_C(0x538d), UINT_C(0x6116), UINT_C(0x709f),
132 UINT_C(0x0420), UINT_C(0x15a9), UINT_C(0x2732), UINT_C(0x36bb),
133 UINT_C(0xce4c), UINT_C(0xdfc5), UINT_C(0xed5e), UINT_C(0xfcd7),
134 UINT_C(0x8868), UINT_C(0x99e1), UINT_C(0xab7a), UINT_C(0xbaf3),
135 UINT_C(0x5285), UINT_C(0x430c), UINT_C(0x7197), UINT_C(0x601e),
136 UINT_C(0x14a1), UINT_C(0x0528), UINT_C(0x37b3), UINT_C(0x263a),
137 UINT_C(0xdecd), UINT_C(0xcf44), UINT_C(0xfddf), UINT_C(0xec56),
138 UINT_C(0x98e9), UINT_C(0x8960), UINT_C(0xbbfb), UINT_C(0xaa72),
139 UINT_C(0x6306), UINT_C(0x728f), UINT_C(0x4014), UINT_C(0x519d),
140 UINT_C(0x2522), UINT_C(0x34ab), UINT_C(0x0630), UINT_C(0x17b9),
141 UINT_C(0xef4e), UINT_C(0xfec7), UINT_C(0xcc5c), UINT_C(0xddd5),
142 UINT_C(0xa96a), UINT_C(0xb8e3), UINT_C(0x8a78), UINT_C(0x9bf1),
143 UINT_C(0x7387), UINT_C(0x620e), UINT_C(0x5095), UINT_C(0x411c),
144 UINT_C(0x35a3), UINT_C(0x242a), UINT_C(0x16b1), UINT_C(0x0738),
145 UINT_C(0xffcf), UINT_C(0xee46), UINT_C(0xdcdd), UINT_C(0xcd54),
146 UINT_C(0xb9eb), UINT_C(0xa862), UINT_C(0x9af9), UINT_C(0x8b70),
147 UINT_C(0x8408), UINT_C(0x9581), UINT_C(0xa71a), UINT_C(0xb693),
148 UINT_C(0xc22c), UINT_C(0xd3a5), UINT_C(0xe13e), UINT_C(0xf0b7),
149 UINT_C(0x0840), UINT_C(0x19c9), UINT_C(0x2b52), UINT_C(0x3adb),
150 UINT_C(0x4e64), UINT_C(0x5fed), UINT_C(0x6d76), UINT_C(0x7cff),
151 UINT_C(0x9489), UINT_C(0x8500), UINT_C(0xb79b), UINT_C(0xa612),
152 UINT_C(0xd2ad), UINT_C(0xc324), UINT_C(0xf1bf), UINT_C(0xe036),
153 UINT_C(0x18c1), UINT_C(0x0948), UINT_C(0x3bd3), UINT_C(0x2a5a),
154 UINT_C(0x5ee5), UINT_C(0x4f6c), UINT_C(0x7df7), UINT_C(0x6c7e),
155 UINT_C(0xa50a), UINT_C(0xb483), UINT_C(0x8618), UINT_C(0x9791),
156 UINT_C(0xe32e), UINT_C(0xf2a7), UINT_C(0xc03c), UINT_C(0xd1b5),
157 UINT_C(0x2942), UINT_C(0x38cb), UINT_C(0x0a50), UINT_C(0x1bd9),
158 UINT_C(0x6f66), UINT_C(0x7eef), UINT_C(0x4c74), UINT_C(0x5dfd),
159 UINT_C(0xb58b), UINT_C(0xa402), UINT_C(0x9699), UINT_C(0x8710),
160 UINT_C(0xf3af), UINT_C(0xe226), UINT_C(0xd0bd), UINT_C(0xc134),
161 UINT_C(0x39c3), UINT_C(0x284a), UINT_C(0x1ad1), UINT_C(0x0b58),
162 UINT_C(0x7fe7), UINT_C(0x6e6e), UINT_C(0x5cf5), UINT_C(0x4d7c),
163 UINT_C(0xc60c), UINT_C(0xd785), UINT_C(0xe51e), UINT_C(0xf497),
164 UINT_C(0x8028), UINT_C(0x91a1), UINT_C(0xa33a), UINT_C(0xb2b3),
165 UINT_C(0x4a44), UINT_C(0x5bcd), UINT_C(0x6956), UINT_C(0x78df),
166 UINT_C(0x0c60), UINT_C(0x1de9), UINT_C(0x2f72), UINT_C(0x3efb),
167 UINT_C(0xd68d), UINT_C(0xc704), UINT_C(0xf59f), UINT_C(0xe416),
168 UINT_C(0x90a9), UINT_C(0x8120), UINT_C(0xb3bb), UINT_C(0xa232),
169 UINT_C(0x5ac5), UINT_C(0x4b4c), UINT_C(0x79d7), UINT_C(0x685e),
170 UINT_C(0x1ce1), UINT_C(0x0d68), UINT_C(0x3ff3), UINT_C(0x2e7a),
171 UINT_C(0xe70e), UINT_C(0xf687), UINT_C(0xc41c), UINT_C(0xd595),
172 UINT_C(0xa12a), UINT_C(0xb0a3), UINT_C(0x8238), UINT_C(0x93b1),
173 UINT_C(0x6b46), UINT_C(0x7acf), UINT_C(0x4854), UINT_C(0x59dd),
174 UINT_C(0x2d62), UINT_C(0x3ceb), UINT_C(0x0e70), UINT_C(0x1ff9),
175 UINT_C(0xf78f), UINT_C(0xe606), UINT_C(0xd49d), UINT_C(0xc514),
176 UINT_C(0xb1ab), UINT_C(0xa022), UINT_C(0x92b9), UINT_C(0x8330),
177 UINT_C(0x7bc7), UINT_C(0x6a4e), UINT_C(0x58d5), UINT_C(0x495c),
178 UINT_C(0x3de3), UINT_C(0x2c6a), UINT_C(0x1ef1), UINT_C(0x0f78),
179 };
180
181/*
182 * インライン関数
183 */
184
185Inline uint16_t Next_FCS (uint16_t FCS, uint8_t Octet) {
186 return (FCS >> 8) ^ fcstab[(FCS ^ Octet) & 0xff];
187 };
188
189/*
190 * HDLC_putoctet -- HDLC オクテット出力
191 */
192
193static
194ER HDLC_putoctet (uint8_t octet)
195{
196 static uint8_t escape[2] = { HDLC_CNTL_ESC };
197
198 ER error;
199
200 NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, 1);
201
202 if ((octet < 0x20 && ((1 << octet) & lcp_remote_ack_cfg.ACCM)) ||
203 octet == HDLC_CNTL_ESC || octet == HDLC_FLAG_SEQ) {
204 escape[1] = octet ^ HDLC_ESC_MASK;
205 error = serial_wri_dat(HDLC_PORTID, escape, sizeof(escape));
206 }
207 else
208 error = serial_wri_dat(HDLC_PORTID, &octet, sizeof(octet));
209
210 return error > 0 ? E_OK : error;
211 }
212
213/*
214 * HDLC_wirte -- HDLC 出力
215 */
216
217ER HDLC_write (T_NET_BUF *nbuf)
218{
219 static char flag_seq_ac[4] = {
220 HDLC_FLAG_SEQ,
221 HDLC_ADDR_ALL,
222 HDLC_CNTL_ESC,
223 HDLC_CNTL_UI ^ HDLC_ESC_MASK,
224 };
225
226#ifdef LCP_CFG_ACCOMP
227
228 static char flag_seq = HDLC_FLAG_SEQ;
229
230#endif /* of #ifdef LCP_CFG_ACCOMP */
231
232 ER error;
233 uint32_t fcs;
234 uint16_t len;
235 uint8_t *buf;
236
237 NET_COUNT_PPP_HDLC(net_count_hdlc.out_packets, 1);
238
239#ifdef LCP_CFG_ACCOMP
240
241 if (lcp_local_ack_cfg.options & LCP_CFG_ACCOMP) {
242 NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, sizeof(flag_seq));
243 /* フレーム開始フラグシーケンス を送信する */
244 if ((error = serial_wri_dat(HDLC_PORTID, &flag_seq, sizeof(flag_seq))) < 0) {
245 goto err_ret;
246 }
247 fcs = HDLC_INIT_FCS;
248 }
249 else {
250
251 NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, sizeof(flag_seq_ac));
252 /* フレーム開始フラグシーケンス、Address と Control を送信する */
253 if ((error = serial_wri_dat(HDLC_PORTID, flag_seq_ac, sizeof(flag_seq_ac))) < 0) {
254 goto err_ret;
255 }
256 /* Address と Control の FCS の計算は HDLC_INIT_FCS_AC に含めている */
257 fcs = HDLC_INIT_FCS_AC;
258 }
259
260#else /* of #ifdef LCP_CFG_ACCOMP */
261
262 NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, sizeof(flag_seq_ac));
263 /* フレーム開始フラグシーケンス、Address と Control を送信する */
264 if ((error = serial_wri_dat(HDLC_PORTID, flag_seq_ac, sizeof(flag_seq_ac))) < 0) {
265 goto err_ret;
266 }
267 /* Address と Control の FCS の計算は HDLC_INIT_FCS_AC に含めている */
268 fcs = HDLC_INIT_FCS_AC;
269
270#endif /* of #ifdef LCP_CFG_ACCOMP */
271
272 buf = nbuf->buf;
273 len = nbuf->len;
274
275#ifdef LCP_CFG_PCOMP
276
277 if ((lcp_local_ack_cfg.options & LCP_CFG_ACCOMP) && *buf == 0 && *(buf + 1) < 0xff) {
278 buf ++;
279 len --;
280 }
281
282#endif /* of #ifdef LCP_CFG_PCOMP */
283
284 /* データを送信する */
285 while (len -- > 0) {
286
287 if ((error = HDLC_putoctet(*buf)) != E_OK)
288 goto err_ret;
289 fcs = Next_FCS(fcs, *buf);
290 buf ++;
291 }
292
293 /* FCS を送信する */
294 fcs = ~fcs;
295 if ((error = HDLC_putoctet(fcs & 0xff)) != E_OK)
296 goto err_ret;
297 if ((error = HDLC_putoctet(fcs >> 8)) != E_OK)
298 goto err_ret;
299
300 /* フレーム終了フラグシーケンスを送信する */
301 if ((error = serial_wri_dat(HDLC_PORTID, &flag_seq_ac[0], sizeof(char))) < 0)
302 goto err_ret;
303
304 return E_OK;
305
306err_ret:
307 NET_COUNT_PPP_HDLC(net_count_hdlc.out_err_packets, 1);
308 return error;
309 }
310
311/*
312 * HDLC_getoctet -- HDLC オクテットå…
313¥åŠ›
314 *
315 * 戻り値が true ならフラグシーケンス
316 */
317
318static
319ER_BOOL HDLC_getoctet (uint8_t *octet)
320{
321 ER error;
322
323 /* 1オクテットå…
324¥åŠ›ã™ã‚‹ */
325 if ((error = serial_rea_dat(HDLC_PORTID, octet, sizeof(uint8_t))) <= 0) {
326 return error;
327 }
328
329 /* å…
330¥åŠ›ã—たオクテットがフラグシーケンスなら true を返す */
331 if (*octet == HDLC_FLAG_SEQ)
332 return true;
333
334 /* å…
335¥åŠ›ã—たオクテットがエスケープなら、もう1オクテットå…
336¥åŠ›ã—マスクを解除する */
337 if (*octet == HDLC_CNTL_ESC) {
338 if ((error = serial_rea_dat(HDLC_PORTID, octet, sizeof(uint8_t))) <= 0)
339 return error;
340 *octet ^= HDLC_ESC_MASK;
341 }
342
343 NET_COUNT_PPP_HDLC(net_count_hdlc.in_octets, 1);
344 return E_OK;
345 }
346
347/*
348 * HDLC_read -- HDLC å…
349¥åŠ›
350 *
351 * HDLC フレームをå…
352¥åŠ›ã™ã‚‹ã€‚
353 */
354
355ER HDLC_read (T_NET_BUF *nbuf, uint16_t size)
356{
357 ER error;
358 uint32_t fcs = 0;
359 uint16_t olen = 0;
360 uint8_t *buf, octet;
361
362 buf = nbuf->buf;
363
364 /* フレーム開始フラグシーケンスまでå…
365¥åŠ›ã‚’読み飛ばす */
366 while ((error = HDLC_getoctet(&octet)) != true) {
367
368 if (error != E_OK)
369 goto err_ret;
370
371#ifdef PPP_CFG_MODEM
372
373 else if (octet == '\n') {
374 /* モデム制御を呼び出す。*/
375 modem_cntl(modem_getline(nbuf, size));
376 /* 一度、この関数を終了する。*/
377 nbuf->len = 0;
378 return E_OK;
379 }
380
381#endif/* of #ifdef PPP_CFG_MODEM */
382
383 }
384
385 /* フレーム開始フラグシーケンスの間はå…
386¥åŠ›ã‚’読み飛ばす */
387 while (1) {
388 if ((error = HDLC_getoctet(&octet)) == E_OK)
389 break;
390 else if (error != true)
391 goto err_ret;
392 }
393
394 NET_COUNT_PPP_HDLC(net_count_hdlc.in_packets, 1);
395
396 /* å…
397¥åŠ›ã—たオクテットは Address: All-Stations か */
398 if (octet == HDLC_ADDR_ALL) {
399
400 /* 次は Control: UI */
401 if ((error = HDLC_getoctet(&octet)) != E_OK || octet != HDLC_CNTL_UI) {
402 error = E_SYS;
403 goto err_ret;
404 }
405 if ((error = HDLC_getoctet(&octet)) != E_OK)
406 goto err_ret;
407 /* Address と Control の FCS の計算は HDLC_INIT_FCS_AC に含めている */
408 fcs = HDLC_INIT_FCS_AC;
409 }
410
411#ifdef LCP_CFG_ACCOMP
412
413 else if (lcp_remote_ack_cfg.options & LCP_CFG_ACCOMP) {
414 fcs = HDLC_INIT_FCS;
415 }
416
417#endif/* of #ifdef LCP_CFG_ACCOMP */
418
419 else {
420 error = E_SYS;
421 goto err_ret;
422 }
423
424 nbuf->len = 0;
425
426#ifdef LCP_CFG_PCOMP
427
428 if ((lcp_remote_ack_cfg.options & LCP_CFG_PCOMP) && (octet & 0x01) != 0) {
429 *buf ++ = 0x00;
430 size --;
431 nbuf->len ++;
432 }
433
434#endif /* of #ifdef LCP_CFG_PCOMP */
435
436 fcs = Next_FCS(fcs, octet);
437 *buf ++ = octet;
438 size --;
439 nbuf->len ++;
440
441 /* SUD + FCS をå…
442¥åŠ›ã™ã‚‹ */
443 while ((error = HDLC_getoctet(&octet)) == E_OK) {
444 fcs = Next_FCS(fcs, octet);
445 if (size > 0) {
446 *buf ++ = octet;
447 size --;
448 }
449 else
450 olen ++;
451 nbuf->len ++;
452 }
453
454 if (error == true) {
455 if (size > 0)
456 nbuf->len -= 2;
457 else if (olen <= 2)
458 nbuf->len -= olen;
459 else {
460 error = E_BOVR;
461 goto err_ret;
462 }
463 }
464 else
465 goto err_ret;
466
467 /* FCS をチェックする */
468 if (fcs != HDLC_GOOD_FCS) {
469 error = E_SYS;
470 goto err_ret;
471 }
472
473 return E_OK;
474
475err_ret:
476 NET_COUNT_PPP_HDLC(net_count_hdlc.in_err_packets, 1);
477 return error;
478 }
479
480/*
481 * HDLC_dummy_read -- HDLC å…
482¥åŠ› (空読み)
483 *
484 * HDLC フレームを空読みする。
485 */
486
487void
488HDLC_dummy_read (void)
489{
490 uint8_t octet;
491 ER error;
492
493 /* フレーム開始フラグシーケンスまでå…
494¥åŠ›ã‚’読み飛ばす */
495 while ((error = HDLC_getoctet(&octet)) != true) {
496 if (error != E_OK)
497 return;
498 }
499
500 /* フレーム開始フラグシーケンスの間はå…
501¥åŠ›ã‚’読み飛ばす */
502 while (octet == HDLC_FLAG_SEQ)
503 if (HDLC_getoctet(&octet) != E_OK)
504 return;
505
506 /* å…
507¥åŠ›ã—たオクテットは Address: All-Stations か */
508 if (octet == HDLC_ADDR_ALL) {
509
510 /* 次は Control: UI */
511 if (HDLC_getoctet(&octet) != E_OK || octet != HDLC_CNTL_UI)
512 return;
513 if (HDLC_getoctet(&octet) != E_OK)
514 return;
515 }
516
517#ifdef LCP_CFG_ACCOMP
518
519 else if (lcp_remote_ack_cfg.options & LCP_CFG_ACCOMP)
520 ;
521
522#endif/* of #ifdef LCP_CFG_ACCOMP */
523
524 else
525 return;
526
527 while (HDLC_getoctet(&octet) == E_OK)
528 ;
529 }
530
531#ifdef PPP_CFG_MODEM
532
533/*
534 * HDLC_raw_getoctet -- HDLC オクテット (Raw) å…
535¥åŠ›
536 */
537
538int HDLC_raw_getoctet (void)
539{
540 uint8_t ch;
541
542 /* 1オクテットå…
543¥åŠ›ã™ã‚‹ */
544 if (serial_rea_dat(HDLC_PORTID, &ch, sizeof(ch)) <= 0)
545 return '\0';
546
547 NET_COUNT_PPP_HDLC(net_count_hdlc.in_octets, 1);
548 return ch;
549 }
550
551/*
552 * HDLC_raw_putoctet -- HDLC オクテット (Raw) 出力
553 */
554
555void HDLC_raw_putoctet (uint8_t ch)
556{
557 NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, 1);
558 /* 1オクテット出力する */
559 serial_wri_dat(HDLC_PORTID, &ch, sizeof(ch));
560 }
561
562#endif /* of #ifdef PPP_CFG_MODEM */
563
564#endif /* fo #ifdef SUPPORT_PPP */
Note: See TracBrowser for help on using the repository browser.