Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need explanation about util.Buffer #45

Open
shi0rik0 opened this issue Jul 10, 2023 · 1 comment
Open

Need explanation about util.Buffer #45

shi0rik0 opened this issue Jul 10, 2023 · 1 comment

Comments

@shi0rik0
Copy link

shi0rik0 commented Jul 10, 2023

I can't figure out why util.Buffer should exist. Take the ipv4 for example.

type IPv4 struct {
	Version        uint8 //4-bits
	IHL            uint8 //4-bits
	DSCP           uint8 //6-bits
	ECN            uint8 //2-bits
	Length         uint16
	Id             uint16
	Flags          uint16 //3-bits
	FragmentOffset uint16 //13-bits
	TTL            uint8
	Protocol       uint8
	Checksum       uint16
	NWSrc          net.IP
	NWDst          net.IP
	Options        util.Buffer
	Data           util.Message
}

Why should the type of "Options" field be util.Buffer?

@shi0rik0
Copy link
Author

I think a simple []byte is enough for "Options". If we want to support Marshal and Unmarshal on it, we can just let it be util.Message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant