source: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.c@ 270

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

mruby版ECNLプロトタイピング・ツールを追加

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