forked from contiv/libOpenflow
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix the ARP packet parsing code to adapt to the scenario where t…
…he switch adds extra padding bytes to ARP packets to meet the 64-byte minimum frame size. Signed-off-by: jiasheng.yu <[email protected]>
- Loading branch information
jiasheng.yu
committed
Jan 14, 2025
1 parent
009740f
commit 9d77e4f
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package protocol | ||
|
||
import ( | ||
"encoding/hex" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_ARPUnmarshalBinary(t *testing.T) { | ||
data, err := hex.DecodeString("00010800060400027057bf301a03c0a8ac01525400ec4b98c0a8accc0000000000000000000000000000") | ||
assert.Nil(t, err) | ||
arp := new(ARP) | ||
err = arp.UnmarshalBinary(data) | ||
assert.Nil(t, err) | ||
assert.Equal(t, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, arp.Padding) | ||
assert.Equal(t, 42, arp.Len()) | ||
} |