OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_channel.c versions 1.27 and 1.28
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_channel.c 1.27 -> 1.28

--- 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;

CVSTrac 2.0.1