|
|
@@ -61,22 +61,21 @@ type FrameMetadata struct {
|
|
|
}
|
|
|
|
|
|
func (f FrameMetadata) WriteTo(b *buf.Buffer) error {
|
|
|
- common.Must2(b.WriteBytes(0x00, 0x00))
|
|
|
- lenBytes := b.Bytes()
|
|
|
+ lenBytes := b.Extend(2)
|
|
|
|
|
|
len0 := b.Len()
|
|
|
- if _, err := serial.WriteUint16(b, f.SessionID); err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
+ sessionBytes := b.Extend(2)
|
|
|
+ binary.BigEndian.PutUint16(sessionBytes, f.SessionID)
|
|
|
|
|
|
- common.Must2(b.WriteBytes(byte(f.SessionStatus), byte(f.Option)))
|
|
|
+ common.Must(b.WriteByte(byte(f.SessionStatus)))
|
|
|
+ common.Must(b.WriteByte(byte(f.Option)))
|
|
|
|
|
|
if f.SessionStatus == SessionStatusNew {
|
|
|
switch f.Target.Network {
|
|
|
case net.Network_TCP:
|
|
|
- common.Must2(b.WriteBytes(byte(TargetNetworkTCP)))
|
|
|
+ common.Must(b.WriteByte(byte(TargetNetworkTCP)))
|
|
|
case net.Network_UDP:
|
|
|
- common.Must2(b.WriteBytes(byte(TargetNetworkUDP)))
|
|
|
+ common.Must(b.WriteByte(byte(TargetNetworkUDP)))
|
|
|
}
|
|
|
|
|
|
if err := addrParser.WriteAddressPort(b, f.Target.Address, f.Target.Port); err != nil {
|