Index: ossp-pkg/l2/l2_channel.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v rcsdiff -q -kk '-r1.27' '-r1.28' -u '/v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v' 2>/dev/null --- l2_channel.c 2002/01/02 17:07:38 1.27 +++ l2_channel.c 2002/07/24 09:36:54 1.28 @@ -334,6 +334,7 @@ /* write to channel */ l2_result_t l2_channel_write(l2_channel_t *ch, l2_level_t level, const char *buf, size_t bufsize) { + int l, j; l2_result_t rv; l2_result_t rvD; l2_channel_t *chD; @@ -346,6 +347,17 @@ if (ch->state != L2_CHSTATE_OPENED) return L2_ERR_USE; + /* make sure only a single level is specified */ + for (l = level, j = 0; l != 0; l = (l >> 1)) + if (l & 0x1) + j++; + if (j != 1) + return L2_ERR_ARG; + + /* check whether level mask already stops processing */ + if (!(ch->levelmask & level)) + return L2_OK; + /* short circuiting */ if (bufsize == 0) return L2_OK;