aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/sideband/common.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-11-30 17:24:11 +0100
committerGitHub <noreply@github.com>2016-11-30 17:24:11 +0100
commitbd3dd4d421299699854bfe0353aae312bcf8c97c (patch)
tree60f22b556b929143955bd54e6ac7ae69563308ed /plumbing/protocol/packp/sideband/common.go
parentb0d756c93d8deb5d4c6a129c5bd3163dddd10132 (diff)
downloadgo-git-bd3dd4d421299699854bfe0353aae312bcf8c97c.tar.gz
protocol/packp: sideband muxer and demuxer (#143)
* format/pakp: sideband demuxer * format/pakp: sideband muxer * format/pakp: sideband demuxer and muxer * protocol/pakp: sideband demuxer and muxer * documentation and improvements * improvements * handle scan errors properly
Diffstat (limited to 'plumbing/protocol/packp/sideband/common.go')
-rw-r--r--plumbing/protocol/packp/sideband/common.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/sideband/common.go b/plumbing/protocol/packp/sideband/common.go
new file mode 100644
index 0000000..de50012
--- /dev/null
+++ b/plumbing/protocol/packp/sideband/common.go
@@ -0,0 +1,33 @@
+package sideband
+
+// Type sideband type "side-band" or "side-band-64k"
+type Type int8
+
+const (
+ // Sideband legacy sideband type up to 1000-byte messages
+ Sideband Type = iota
+ // Sideband64k sideband type up to 65519-byte messages
+ Sideband64k Type = iota
+
+ // MaxPackedSize for Sideband type
+ MaxPackedSize = 1000
+ // MaxPackedSize64k for Sideband64k type
+ MaxPackedSize64k = 65520
+)
+
+// Channel sideband channel
+type Channel byte
+
+// WithPayload encode the payload as a message
+func (ch Channel) WithPayload(payload []byte) []byte {
+ return append([]byte{byte(ch)}, payload...)
+}
+
+const (
+ // PackData packfile content
+ PackData Channel = 1
+ // ProgressMessage progress messages
+ ProgressMessage Channel = 2
+ // ErrorMessage fatal error message just before stream aborts
+ ErrorMessage Channel = 3
+)