diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/drivers/slip_proto.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/um/drivers/slip_proto.h')
-rw-r--r-- | arch/um/drivers/slip_proto.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/arch/um/drivers/slip_proto.h b/arch/um/drivers/slip_proto.h new file mode 100644 index 000000000000..7206361ace45 --- /dev/null +++ b/arch/um/drivers/slip_proto.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __UM_SLIP_PROTO_H__ | ||
7 | #define __UM_SLIP_PROTO_H__ | ||
8 | |||
9 | /* SLIP protocol characters. */ | ||
10 | #define SLIP_END 0300 /* indicates end of frame */ | ||
11 | #define SLIP_ESC 0333 /* indicates byte stuffing */ | ||
12 | #define SLIP_ESC_END 0334 /* ESC ESC_END means END 'data' */ | ||
13 | #define SLIP_ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */ | ||
14 | |||
15 | static inline int slip_unesc(unsigned char c,char *buf,int *pos, int *esc) | ||
16 | { | ||
17 | int ret; | ||
18 | |||
19 | switch(c){ | ||
20 | case SLIP_END: | ||
21 | *esc = 0; | ||
22 | ret=*pos; | ||
23 | *pos=0; | ||
24 | return(ret); | ||
25 | case SLIP_ESC: | ||
26 | *esc = 1; | ||
27 | return(0); | ||
28 | case SLIP_ESC_ESC: | ||
29 | if(*esc){ | ||
30 | *esc = 0; | ||
31 | c = SLIP_ESC; | ||
32 | } | ||
33 | break; | ||
34 | case SLIP_ESC_END: | ||
35 | if(*esc){ | ||
36 | *esc = 0; | ||
37 | c = SLIP_END; | ||
38 | } | ||
39 | break; | ||
40 | } | ||
41 | buf[(*pos)++] = c; | ||
42 | return(0); | ||
43 | } | ||
44 | |||
45 | static inline int slip_esc(unsigned char *s, unsigned char *d, int len) | ||
46 | { | ||
47 | unsigned char *ptr = d; | ||
48 | unsigned char c; | ||
49 | |||
50 | /* | ||
51 | * Send an initial END character to flush out any | ||
52 | * data that may have accumulated in the receiver | ||
53 | * due to line noise. | ||
54 | */ | ||
55 | |||
56 | *ptr++ = SLIP_END; | ||
57 | |||
58 | /* | ||
59 | * For each byte in the packet, send the appropriate | ||
60 | * character sequence, according to the SLIP protocol. | ||
61 | */ | ||
62 | |||
63 | while (len-- > 0) { | ||
64 | switch(c = *s++) { | ||
65 | case SLIP_END: | ||
66 | *ptr++ = SLIP_ESC; | ||
67 | *ptr++ = SLIP_ESC_END; | ||
68 | break; | ||
69 | case SLIP_ESC: | ||
70 | *ptr++ = SLIP_ESC; | ||
71 | *ptr++ = SLIP_ESC_ESC; | ||
72 | break; | ||
73 | default: | ||
74 | *ptr++ = c; | ||
75 | break; | ||
76 | } | ||
77 | } | ||
78 | *ptr++ = SLIP_END; | ||
79 | return (ptr - d); | ||
80 | } | ||
81 | |||
82 | #endif | ||
83 | |||
84 | /* | ||
85 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
86 | * Emacs will notice this stuff at the end of the file and automatically | ||
87 | * adjust the settings for this buffer only. This must remain at the end | ||
88 | * of the file. | ||
89 | * --------------------------------------------------------------------------- | ||
90 | * Local variables: | ||
91 | * c-file-style: "linux" | ||
92 | * End: | ||
93 | */ | ||