2023-01-02 20:02:50 +01:00
|
|
|
package protocol
|
|
|
|
|
2023-01-03 13:34:32 +01:00
|
|
|
import "encoding/json"
|
|
|
|
|
2023-01-02 20:02:50 +01:00
|
|
|
type Field struct {
|
|
|
|
Name string // Name of the Field
|
|
|
|
Desc string // Lengthy description
|
|
|
|
Regex string // Regex to recognize values
|
2023-01-04 13:38:16 +01:00
|
|
|
Size int // Size in bits!
|
2023-01-02 20:02:50 +01:00
|
|
|
SubFields []Field // Possible sub-fields
|
|
|
|
Optional bool // Is this field required?
|
|
|
|
Payload bool // Is this field the payload or next protocol level?
|
|
|
|
}
|
2023-01-03 13:34:32 +01:00
|
|
|
|
|
|
|
func (f *Field) ToJson() string {
|
|
|
|
b, err := json.Marshal(*f)
|
|
|
|
if err != nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return string(b)
|
|
|
|
}
|