Introduce a new ST_MASK which masks off the state-machine bits. Use this
when reading SL_END or when setting ST_EOF, so as to preserve any other
state bits which might happen to have been set. Not that I'm promising
anything...
unsigned st; /* Current parser state */
# define ST_ESC 1u /* Last saw an escape character */
# define ST_BAD 2u /* This packet is malformed */
unsigned st; /* Current parser state */
# define ST_ESC 1u /* Last saw an escape character */
# define ST_BAD 2u /* This packet is malformed */
+# define ST_MASK 3u /* Mask for the above bits */
# define ST_EOF 4u /* File descriptor reported EOF */
size_t n; /* Number of bytes used in buffer */
octet buf[PKBUFSZ]; /* Buffer for incoming data */
# define ST_EOF 4u /* File descriptor reported EOF */
size_t n; /* Number of bytes used in buffer */
octet buf[PKBUFSZ]; /* Buffer for incoming data */
}
if (!n) {
a_warn("TUN", "%s", p_ifname(t->p), "slip", "eof", A_END);
}
if (!n) {
a_warn("TUN", "%s", p_ifname(t->p), "slip", "eof", A_END);
+ t->st = (t->st & ~ST_MASK) | ST_EOF;
sel_rmfile(&t->f);
return;
}
sel_rmfile(&t->f);
return;
}
p_tun(t->p, &b);
}
q = t->buf;
p_tun(t->p, &b);
}
q = t->buf;
- st &= ~(ST_ESC | ST_BAD);
break;
case SL_ESC:
if ((st & ST_ESC) && !(st & ST_BAD)) {
break;
case SL_ESC:
if ((st & ST_ESC) && !(st & ST_BAD)) {