Skip to content

Commit

Permalink
fix: some pad's length in UnmarshalBinary is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxiaochuang committed Jul 22, 2021
1 parent d967b14 commit 1906849
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions openflow13/multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,9 @@ func (s *TableStats) UnmarshalBinary(data []byte) error {
s.TableId = data[0]
n += 1
copy(s.pad, data[n:])
n += len(s.pad)
n += 3
copy(s.Name, data[n:])
n += len(s.Name)
n += MAX_TABLE_NAME_LEN
s.Wildcards = binary.BigEndian.Uint32(data[n:])
n += 4
s.MaxEntries = binary.BigEndian.Uint32(data[n:])
Expand Down Expand Up @@ -790,7 +790,7 @@ func (s *PortStats) UnmarshalBinary(data []byte) error {
s.PortNo = binary.BigEndian.Uint16(data[n:])
n += 2
copy(s.pad, data[n:])
n += len(s.pad)
n += 6
s.RxPackets = binary.BigEndian.Uint64(data[n:])
n += 8
s.TxPackets = binary.BigEndian.Uint64(data[n:])
Expand Down Expand Up @@ -895,7 +895,7 @@ func (s *QueueStats) UnmarshalBinary(data []byte) error {
s.PortNo = binary.BigEndian.Uint16(data[n:])
n += 2
copy(s.pad, data[n:])
n += len(s.pad)
n += 2
s.QueueId = binary.BigEndian.Uint32(data[n:])
n += 4
s.TxBytes = binary.BigEndian.Uint64(data[n:])
Expand Down Expand Up @@ -952,7 +952,7 @@ func (s *PortStatus) UnmarshalBinary(data []byte) error {
s.Reason = data[n]
n += 1
copy(s.pad, data[n:])
n += len(s.pad)
n += 7

err = s.Desc.UnmarshalBinary(data[n:])
return err
Expand Down
4 changes: 3 additions & 1 deletion openflow13/openflow13.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ func (p *PacketOut) UnmarshalBinary(data []byte) error {

n += 6 // for pad

for n < (n + p.ActionsLen) {
actionsBound := n + p.ActionsLen
for n < actionsBound {
a, err := DecodeAction(data[n:])
if err != nil {
return err
Expand Down Expand Up @@ -745,6 +746,7 @@ func (s *SwitchFeatures) UnmarshalBinary(data []byte) error {
for next < len(data) {
p := NewPhyPort()
err = p.UnmarshalBinary(data[next:])
s.Ports = append(s.Ports, *p)
next += int(p.Len())
}
return err
Expand Down

0 comments on commit 1906849

Please sign in to comment.