1 #ifndef __UM_SLIP_COMMON_H
2 #define __UM_SLIP_COMMON_H
5 /* two bytes each for a (pathological) max packet of escaped chars + *
6 * terminating END char + initial END char */
7 #define ENC_BUF_SIZE (2 * BUF_SIZE + 2)
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' */
15 static inline int slip_unesc(unsigned char c, unsigned char *buf, int *pos,
46 static inline int slip_esc(unsigned char *s, unsigned char *d, int len)
48 unsigned char *ptr = d;
52 * Send an initial END character to flush out any
53 * data that may have accumulated in the receiver
60 * For each byte in the packet, send the appropriate
61 * character sequence, according to the SLIP protocol.
68 *ptr++ = SLIP_ESC_END;
72 *ptr++ = SLIP_ESC_ESC;
84 unsigned char ibuf[ENC_BUF_SIZE];
85 unsigned char obuf[ENC_BUF_SIZE];
86 int more; /* more data: do not read fd until ibuf has been drained */
91 static inline void slip_proto_init(struct slip_proto * slip)
93 memset(slip->ibuf, 0, sizeof(slip->ibuf));
94 memset(slip->obuf, 0, sizeof(slip->obuf));
100 extern int slip_proto_read(int fd, void *buf, int len,
101 struct slip_proto *slip);
102 extern int slip_proto_write(int fd, void *buf, int len,
103 struct slip_proto *slip);