forked from sandia-minimega/minimega
-
Notifications
You must be signed in to change notification settings - Fork 1
/
message.go
81 lines (67 loc) · 1.26 KB
/
message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2015-2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain
// rights in this software.
package ron
type Type int
// Message types to inform the mux on either end how to route the message
const (
MESSAGE_COMMAND Type = iota
MESSAGE_CLIENT
MESSAGE_TUNNEL
MESSAGE_FILE
MESSAGE_PIPE
MESSAGE_UFS
MESSAGE_HEARTBEAT
)
// Pipe modes
const (
PIPE_NEW_READER = iota
PIPE_NEW_WRITER
PIPE_CLOSE_READER
PIPE_CLOSE_WRITER
PIPE_DATA
)
// UFS modes
const (
UFS_OPEN = iota
UFS_CLOSE
UFS_DATA
)
type Message struct {
Type Type
UUID string
Error string
// MESSAGE_COMMAND
Commands map[int]*Command
// MESSAGE_CLIENT
Client *Client
// MESSAGE_FILE
File *File
// MESSAGE_TUNNEL and MESSAGE_UFS
Tunnel []byte
// MESSAGE_PIPE
Pipe string
PipeMode int
PipeData string
// MESSAGE_UFS
UfsMode int
}
func (t Type) String() string {
switch t {
case MESSAGE_COMMAND:
return "COMMAND"
case MESSAGE_CLIENT:
return "CLIENT"
case MESSAGE_TUNNEL:
return "TUNNEL"
case MESSAGE_FILE:
return "FILE"
case MESSAGE_PIPE:
return "PIPE"
case MESSAGE_UFS:
return "UFS"
case MESSAGE_HEARTBEAT:
return "HEARTBEAT"
}
return "UNKNOWN"
}