aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-06-24 20:43:34 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-06-24 20:43:34 +0200
commitbbf7053d521ac3cb6733234af15f6f5adf523cc3 (patch)
tree8f5e25c0f8715ad0607986b521c697d4f4ffa51e /misc
parentc3bfed21a174fd69232949fb2c4ebf92e98855a6 (diff)
Add test Go program
Diffstat (limited to 'misc')
-rw-r--r--misc/main.go116
1 files changed, 116 insertions, 0 deletions
diff --git a/misc/main.go b/misc/main.go
new file mode 100644
index 0000000..f4f6d07
--- /dev/null
+++ b/misc/main.go
@@ -0,0 +1,116 @@
+package main
+
+import (
+ "encoding/binary"
+ "encoding/hex"
+ "fmt"
+ "log"
+ "net"
+ "time"
+)
+
+const maxSize = 240
+
+var service = "192.168.240.20:33333"
+
+/* A-ASSOCIATE Request
+ *
+ * 60 23 AARQ-apdu
+ * 80 02 07 08 protocol-version { version1 }
+ * A1 07 application-context-name
+ * 06 05 2B 0C 00 81 5A { 1 3 12 0 218 }
+ * BE 14 user-information
+ * 28 12
+ * 06 07 2B 0C 00 82 1D 81 48 derect-reference { 1 3 12 0 285 200 }
+ * A0 07 single-ASN1-type
+ * (ACSEUserInfomrationForCSTA)
+ * A0 05 newDefinition
+ * 03 03 00 08 00 cSTAVersion { versionFive }
+ */
+
+var associate = []byte{
+ 0x60, 0x23,
+ 0x80, 0x02, 0x07, 0x80,
+ 0xA1, 0x07,
+ 0x06, 0x05, 0x2B, 0x0C, 0x00, 0x81, 0x5A,
+ 0xBE, 0x14,
+ 0x28, 0x12,
+ 0x06, 0x07, 0x2B, 0x0C, 0x00, 0x82, 0x1D, 0x81, 0x48,
+ 0xA0, 0x07,
+ 0xA0, 0x05,
+ 0x03, 0x03, 0x00, 0x08, 0x00,
+}
+
+/* A-ACCOCIATE Result
+ * 61 2F AARE-apdu
+ * 80 02 07 80 protocol-version { version1 }
+ * A1 07 application-context-name
+ * 06 05 2B 0C 00 81 5A { 1 3 12 0 218 }
+ * A2 03 result
+ * 02 01 00 accepted
+ * A3 05 result-source-diagnostic
+ * A1 03 acse-service-user
+ * 02 01 00 no-reason-given
+ * BE 14 user-information
+ * 28 12
+ * 06 07 2B 0C 00 82 1D 81 48 direct-reference { 1 3 120 285 200 }
+ * A0 07 single-ASN1-type
+ * (ACSEUserInformationForCSTA)
+ * A0 05 newDefinition
+ * 03 03 00 08 00 cSTAVersion { versionFive }
+ */
+
+/* A-RELEASE Request
+ *
+ * 62 00 RLRQ-apdu
+ */
+
+var release = []byte{0x62, 0x00}
+
+/* A-RELEASE Result
+ *
+ * 63 00 RLRE-apdu
+ */
+
+func msg(c net.Conn, b []byte) []byte {
+ size := int16(len(b))
+ enc := binary.BigEndian
+
+ fmt.Println(">>> Send")
+ fmt.Println(hex.Dump(b))
+
+ if err := binary.Write(c, enc, size); err != nil {
+ log.Fatal(err)
+ }
+
+ if err := binary.Write(c, enc, b); err != nil {
+ log.Fatal(err)
+ }
+
+ if err := binary.Read(c, enc, &size); err != nil {
+ log.Fatal(err)
+ }
+
+ r := make([]byte, size)
+
+ if err := binary.Read(c, enc, r); err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println("<<< Recv")
+ fmt.Println(hex.Dump(r))
+
+ return r
+}
+
+func main() {
+ c, err := net.Dial("tcp", service)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer c.Close()
+
+ msg(c, associate)
+ time.Sleep(time.Second)
+ msg(c, release)
+}