ppforge/protocol/field.go

27 lines
604 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 int // 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?
}
type ProtocolFieldReferencer interface {
GetProtocolField() *Field
SetProtocolField(f *Field)
}
func (f *Field) ToJson() string {
b, err := json.Marshal(*f)
if err != nil {
return ""
}
return string(b)
}