Deleted Added
full compact
async.c (31343) async.c (32663)
1/*
2 * PPP Async HDLC Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * PPP Async HDLC Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: async.c,v 1.13 1997/10/29 01:19:38 brian Exp $
20 * $Id: async.c,v 1.14 1997/11/22 03:37:23 brian Exp $
21 *
22 */
23#include <sys/param.h>
24#include <netinet/in.h>
25
26#include <stdio.h>
27#include <string.h>
28#include <termios.h>

--- 5 unchanged lines hidden (view full) ---

34#include "timer.h"
35#include "fsm.h"
36#include "hdlc.h"
37#include "lcp.h"
38#include "lcpproto.h"
39#include "modem.h"
40#include "loadalias.h"
41#include "vars.h"
21 *
22 */
23#include <sys/param.h>
24#include <netinet/in.h>
25
26#include <stdio.h>
27#include <string.h>
28#include <termios.h>

--- 5 unchanged lines hidden (view full) ---

34#include "timer.h"
35#include "fsm.h"
36#include "hdlc.h"
37#include "lcp.h"
38#include "lcpproto.h"
39#include "modem.h"
40#include "loadalias.h"
41#include "vars.h"
42#include "os.h"
43#include "async.h"
44
45#define HDLCSIZE (MAX_MRU*2+6)
46
47static struct async_state {
48 int mode;
49 int length;
50 u_char hbuff[HDLCSIZE]; /* recv buffer */

--- 84 unchanged lines hidden (view full) ---

135
136static struct mbuf *
137AsyncDecode(u_char c)
138{
139 struct async_state *hs = &AsyncState;
140 struct mbuf *bp;
141
142 if ((hs->mode & MODE_HUNT) && c != HDLC_SYN)
42#include "async.h"
43
44#define HDLCSIZE (MAX_MRU*2+6)
45
46static struct async_state {
47 int mode;
48 int length;
49 u_char hbuff[HDLCSIZE]; /* recv buffer */

--- 84 unchanged lines hidden (view full) ---

134
135static struct mbuf *
136AsyncDecode(u_char c)
137{
138 struct async_state *hs = &AsyncState;
139 struct mbuf *bp;
140
141 if ((hs->mode & MODE_HUNT) && c != HDLC_SYN)
143 return (NULLBUFF);
142 return NULL;
144
145 switch (c) {
146 case HDLC_SYN:
147 hs->mode &= ~MODE_HUNT;
148 if (hs->length) { /* packet is ready. */
149 bp = mballoc(hs->length, MB_ASYNC);
150 mbwrite(bp, hs->hbuff, hs->length);
151 hs->length = 0;
143
144 switch (c) {
145 case HDLC_SYN:
146 hs->mode &= ~MODE_HUNT;
147 if (hs->length) { /* packet is ready. */
148 bp = mballoc(hs->length, MB_ASYNC);
149 mbwrite(bp, hs->hbuff, hs->length);
150 hs->length = 0;
152 return (bp);
151 return bp;
153 }
154 break;
155 case HDLC_ESC:
156 if (!(hs->mode & MODE_ESC)) {
157 hs->mode |= MODE_ESC;
158 break;
159 }
160 /* Fall into ... */

--- 7 unchanged lines hidden (view full) ---

168 }
169 if (hs->mode & MODE_ESC) {
170 c ^= HDLC_XOR;
171 hs->mode &= ~MODE_ESC;
172 }
173 hs->hbuff[hs->length++] = c;
174 break;
175 }
152 }
153 break;
154 case HDLC_ESC:
155 if (!(hs->mode & MODE_ESC)) {
156 hs->mode |= MODE_ESC;
157 break;
158 }
159 /* Fall into ... */

--- 7 unchanged lines hidden (view full) ---

167 }
168 if (hs->mode & MODE_ESC) {
169 c ^= HDLC_XOR;
170 hs->mode &= ~MODE_ESC;
171 }
172 hs->hbuff[hs->length++] = c;
173 break;
174 }
176 return NULLBUFF;
175 return NULL;
177}
178
179void
180AsyncInput(u_char *buff, int cnt)
181{
182 struct mbuf *bp;
183
184 ModemAddInOctets(cnt);

--- 14 unchanged lines hidden ---
176}
177
178void
179AsyncInput(u_char *buff, int cnt)
180{
181 struct mbuf *bp;
182
183 ModemAddInOctets(cnt);

--- 14 unchanged lines hidden ---