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

ndp: initial Conn implementation #2

Merged
merged 2 commits into from
Dec 20, 2017
Merged

ndp: initial Conn implementation #2

merged 2 commits into from
Dec 20, 2017

Conversation

mdlayher
Copy link
Owner

No tests as of now because this is going to need some more thought, but it's a start.

/cc @miekg @danderson

}

// Dial dials a NDP connection using the specified interface. It returns
// a Conn and the link-local IPv6 address of the interface.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the caller need to know the lladdr? From my reading of NDP, it's only needed to source the packets, so could stay internal to this package?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useful, at least for now, until we have more specialized methods available. Then I can consider dropping it.

client.go Outdated
}

// Calculate and place ICMPv6 checksum at correct offset in all messages.
if err := pc.SetChecksum(true, 2); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number 2. Make it an internal const?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

client.go Outdated
// The default control message used when none is specified.
cm: &ipv6.ControlMessage{
// Note that hop limit is always 255 in NDP.
HopLimit: 255,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fascinating, I would have expected it to be 1, to force it to stay link-local. TIL.

client.go Outdated
//
// If cm is nil, a default control message will be sent. If dst is nil, the
// message will be sent to the IPv6 link-local all nodes address for the Conn.
func (c *Conn) WriteTo(m Message, cm *ipv6.ControlMessage, dst net.IP) error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does dst==nil need to be special? Can't you make the caller pass in the all-nodes multicast address if that's what they want to send to?

Just thinking of that because it makes the API surface more regular, rather than "nil is magic".

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

client.go Outdated
continue
}

if !linkLocalPrefix.Contains(ipn.IP) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mdlayher mdlayher merged commit b62dbe5 into master Dec 20, 2017
@mdlayher mdlayher deleted the mdl-client branch December 20, 2017 14:57
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

Successfully merging this pull request may close these issues.

None yet

2 participants