diff --git a/aurp/aurp.go b/aurp/aurp.go index 0382595..036d620 100644 --- a/aurp/aurp.go +++ b/aurp/aurp.go @@ -403,6 +403,27 @@ func parseOpenRsp(p []byte) (*OpenRspPacket, error) { }, nil } +type RIReqPacket struct { + *Header +} + +type RIRspPacket struct { + *Header + + RTMPData []byte +} + +func (p *RIRspPacket) WriteTo(w io.Writer) (int64, error) { + a := acc(w) + a.writeTo(p.Header) + a.write(p.RTMPData) + return a.ret() +} + +type RIAckPacket struct { + *Header +} + // ParsePacket parses the body of a UDP packet for a domain header, and then // based on the packet type, an AURP-Tr header, an AURP routing header, and // then a particular packet type. @@ -452,6 +473,22 @@ func ParsePacket(p []byte) (Packet, error) { orsp.Header = h return orsp, nil + case CmdCodeRIReq: + return &RIReqPacket{ + Header: h, + }, nil + + case CmdCodeRIRsp: + return &RIRspPacket{ + Header: h, + RTMPData: p, + }, nil + + case CmdCodeRIAck: + return &RIAckPacket{ + Header: h, + }, nil + default: return nil, fmt.Errorf("unknown routing packet command code %d", h.CommandCode) } diff --git a/main.go b/main.go index 35f0e6b..92d98b7 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,5 @@ func main() { log.Printf("Failed to read packet: %v", readErr) continue } - } }