RD
This commit is contained in:
parent
7e1549607d
commit
e18614bfec
2 changed files with 37 additions and 0 deletions
|
@ -210,6 +210,14 @@ func ParsePacket(p []byte) (Packet, error) {
|
|||
riu.Header = h
|
||||
return riu, nil
|
||||
|
||||
case CmdCodeRD:
|
||||
rd, err := parseRD(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rd.Header = h
|
||||
return rd, nil
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown routing packet command code %d", h.CommandCode)
|
||||
}
|
||||
|
|
29
aurp/router_down.go
Normal file
29
aurp/router_down.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package aurp
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
type RDPacket struct {
|
||||
Header
|
||||
|
||||
ErrorCode int16
|
||||
}
|
||||
|
||||
func (p *RDPacket) WriteTo(w io.Writer) (int64, error) {
|
||||
a := acc(w)
|
||||
a.writeTo(&p.Header)
|
||||
a.write16(uint16(p.ErrorCode))
|
||||
return a.ret()
|
||||
}
|
||||
|
||||
func parseRD(p []byte) (*RDPacket, error) {
|
||||
if len(p) < 2 {
|
||||
return nil, fmt.Errorf("insufficient input length %d for router down packet", len(p))
|
||||
}
|
||||
return &RDPacket{
|
||||
ErrorCode: int16(binary.BigEndian.Uint16(p[:2])),
|
||||
}, nil
|
||||
}
|
Loading…
Reference in a new issue