本文整理匯總了Golang中github.com/tehmaze/netflow/read.Uint16函數的典型用法代碼示例。如果您正苦於以下問題:Golang Uint16函數的具體用法?Golang Uint16怎麽用?Golang Uint16使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Uint16函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Unmarshal
func (h *PacketHeader) Unmarshal(r io.Reader) error {
if err := read.Uint16(&h.Version, r); err != nil {
return err
}
if err := read.Uint16(&h.Count, r); err != nil {
return err
}
// The spec says at most 24 flows in one packet, but reality disagrees.
if h.Count < 1 || h.Count > 32 {
return fmt.Errorf("protocol error: %d flows out of bounds", h.Count)
}
var u uint32
if err := read.Uint32(&u, r); err != nil {
return err
}
h.SysUptime = time.Duration(u)
var t uint64
if err := read.Uint64(&t, r); err != nil {
return err
}
h.Unix = time.Unix(int64(t>>32), int64(t&0xffffffff))
if err := read.Uint32(&h.FlowSequence, r); err != nil {
return err
}
if err := read.Uint8(&h.EngineType, r); err != nil {
return err
}
if err := read.Uint8(&h.EngineID, r); err != nil {
return err
}
if err := read.Uint16(&h.SamplingInterval, r); err != nil {
return err
}
return nil
}
示例2: Unmarshal
func (otr *OptionsTemplateRecord) Unmarshal(r io.Reader) error {
if err := read.Uint16(&otr.TemplateID, r); err != nil {
return err
}
if err := read.Uint16(&otr.FieldCount, r); err != nil {
return err
}
if err := read.Uint16(&otr.ScopeFieldCount, r); err != nil {
return err
}
if otr.ScopeFieldCount > otr.FieldCount {
return errProtocol(fmt.Sprintf("scope field count %d higher than field count %d", otr.ScopeFieldCount, otr.FieldCount))
}
buffer := new(bytes.Buffer)
buffer.ReadFrom(r)
if debug {
hexdump(buffer.Bytes())
}
otr.ScopeFields = make(FieldSpecifiers, otr.ScopeFieldCount)
if err := otr.ScopeFields.Unmarshal(buffer); err != nil {
return err
}
otr.Fields = make(FieldSpecifiers, otr.FieldCount-otr.ScopeFieldCount)
if err := otr.Fields.Unmarshal(buffer); err != nil {
return err
}
return nil
}
示例3: Unmarshal
func (f *FieldSpecifier) Unmarshal(r io.Reader) error {
if err := read.Uint16(&f.Type, r); err != nil {
return err
}
if err := read.Uint16(&f.Length, r); err != nil {
return err
}
return nil
}