aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-07 22:49:52 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-07 22:49:52 +0200
commit8b2ca579d8274fe8ce3b2d30165c99066762c73a (patch)
tree725b3f0b6f3c76f9d51c71dab4f311e62c54f6a3 /ber
parent784632de3fb2af5ee5bc279a3f9ad0fc39321824 (diff)
Add BitString
Diffstat (limited to 'ber')
-rw-r--r--ber/bits.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/ber/bits.go b/ber/bits.go
new file mode 100644
index 0000000..42474e5
--- /dev/null
+++ b/ber/bits.go
@@ -0,0 +1,18 @@
+package ber
+
+// BitString
+type Bits struct {
+ Bytes []byte
+ Length int
+}
+
+func parseBitString(b []byte) (bs Bits) {
+ padding := int(b[0])
+ bs.Length = (len(b)-1)*8 - padding
+ bs.Bytes = b[1:]
+ return
+}
+
+func UnmarshalBitString(b []byte) Bits {
+ return parseBitString(b)
+}