ppforge/protocol/field.go

22 lines
505 B
Go

package protocol
import "encoding/json"
type Field struct {
Name string // Name of the Field
Desc string // Lengthy description
Regex string // Regex to recognize values
Size uint // Size in bits!
SubFields []Field // Possible sub-fields
Optional bool // Is this field required?
Payload bool // Is this field the payload or next protocol level?
}
func (f *Field) ToJson() string {
b, err := json.Marshal(*f)
if err != nil {
return ""
}
return string(b)
}