instance Maskable Octet where
- apply_mask _ Maskbits.None = Octet.None
- apply_mask Octet.None _ = Octet.None
- apply_mask oct mask
+ apply_mask _ Maskbits.None _ = Octet.None
+ apply_mask Octet.None _ _ = Octet.None
+ apply_mask oct mask bit
| mask == Eight = oct
- | mask == Seven = oct { b8 = B.Zero }
- | mask == Six = oct { b8 = B.Zero, b7 = B.Zero }
- | mask == Five = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero }
- | mask == Four = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero }
- | mask == Three = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero }
- | mask == Two = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero, b3 = B.Zero }
- | mask == Maskbits.One = oct { b8 = B.Zero, b7 = B.Zero, b6 = B.Zero, b5 = B.Zero, b4 = B.Zero, b3 = B.Zero, b2 = B.Zero }
+ | mask == Seven = oct { b8 = bit }
+ | mask == Six = oct { b8 = bit, b7 = bit }
+ | mask == Five = oct { b8 = bit, b7 = bit, b6 = bit }
+ | mask == Four = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit }
+ | mask == Three = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit }
+ | mask == Two = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit, b3 = bit }
+ | mask == Maskbits.One = oct { b8 = bit, b7 = bit, b6 = bit, b5 = bit, b4 = bit, b3 = bit, b2 = bit }
| mask == Maskbits.Zero = min_octet
| otherwise = Octet.None
test_octet_mask1 :: Test
test_octet_mask1 =
- TestCase $ assertEqual "The network bits of 255/4 should equal 240" oct2 (apply_mask oct1 Four)
+ TestCase $ assertEqual "The network bits of 255/4 should equal 240" oct2 (apply_mask oct1 Four B.Zero)
where
oct1 = octet_from_int 255
oct2 = octet_from_int 240
test_octet_mask2 :: Test
test_octet_mask2 =
- TestCase $ assertEqual "The network bits of 255/1 should equal 128" oct2 (apply_mask oct1 Maskbits.One)
+ TestCase $ assertEqual "The network bits of 255/1 should equal 128" oct2 (apply_mask oct1 Maskbits.One B.Zero)
where
oct1 = octet_from_int 255
oct2 = octet_from_int 128