From 63ee83b038e98e5716bfdd1a94178718cff506d2 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Thu, 6 Nov 2014 13:18:00 +0900 Subject: [PATCH] go.net/ipv4: update TODOs TODOs for stub files are unnecessary because they are stubs. Also adds TODOs that need to be treated for spurious word boundary access on some CPU architecture such as ARM, Power. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/171110043 --- ipv4/control_stub.go | 4 ---- ipv4/control_windows.go | 8 ++++---- ipv4/dgramopt_stub.go | 8 -------- ipv4/genericopt_stub.go | 4 ---- ipv4/header.go | 3 +++ ipv4/helper_stub.go | 4 ---- 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/ipv4/control_stub.go b/ipv4/control_stub.go index f626de6d..4d850719 100644 --- a/ipv4/control_stub.go +++ b/ipv4/control_stub.go @@ -7,21 +7,17 @@ package ipv4 func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error { - // TODO(mikio): Implement this return errOpNoSupport } func newControlMessage(opt *rawOpt) []byte { - // TODO(mikio): Implement this return nil } func parseControlMessage(b []byte) (*ControlMessage, error) { - // TODO(mikio): Implement this return nil, errOpNoSupport } func marshalControlMessage(cm *ControlMessage) []byte { - // TODO(mikio): Implement this return nil } diff --git a/ipv4/control_windows.go b/ipv4/control_windows.go index 5a68a55a..800f6377 100644 --- a/ipv4/control_windows.go +++ b/ipv4/control_windows.go @@ -7,21 +7,21 @@ package ipv4 import "syscall" func setControlMessage(fd syscall.Handle, opt *rawOpt, cf ControlFlags, on bool) error { - // TODO(mikio): Implement this + // TODO(mikio): implement this return syscall.EWINDOWS } func newControlMessage(opt *rawOpt) []byte { - // TODO(mikio): Implement this + // TODO(mikio): implement this return nil } func parseControlMessage(b []byte) (*ControlMessage, error) { - // TODO(mikio): Implement this + // TODO(mikio): implement this return nil, syscall.EWINDOWS } func marshalControlMessage(cm *ControlMessage) []byte { - // TODO(mikio): Implement this + // TODO(mikio): implement this return nil } diff --git a/ipv4/dgramopt_stub.go b/ipv4/dgramopt_stub.go index bee9e040..a4688d92 100644 --- a/ipv4/dgramopt_stub.go +++ b/ipv4/dgramopt_stub.go @@ -9,41 +9,33 @@ package ipv4 import "net" func (c *dgramOpt) MulticastTTL() (int, error) { - // TODO(mikio): Implement this return 0, errOpNoSupport } func (c *dgramOpt) SetMulticastTTL(ttl int) error { - // TODO(mikio): Implement this return errOpNoSupport } func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - // TODO(mikio): Implement this return nil, errOpNoSupport } func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - // TODO(mikio): Implement this return errOpNoSupport } func (c *dgramOpt) MulticastLoopback() (bool, error) { - // TODO(mikio): Implement this return false, errOpNoSupport } func (c *dgramOpt) SetMulticastLoopback(on bool) error { - // TODO(mikio): Implement this return errOpNoSupport } func (c *dgramOpt) JoinGroup(ifi *net.Interface, grp net.Addr) error { - // TODO(mikio): Implement this return errOpNoSupport } func (c *dgramOpt) LeaveGroup(ifi *net.Interface, grp net.Addr) error { - // TODO(mikio): Implement this return errOpNoSupport } diff --git a/ipv4/genericopt_stub.go b/ipv4/genericopt_stub.go index b202744d..93192b39 100644 --- a/ipv4/genericopt_stub.go +++ b/ipv4/genericopt_stub.go @@ -7,21 +7,17 @@ package ipv4 func (c *genericOpt) TOS() (int, error) { - // TODO(mikio): Implement this return 0, errOpNoSupport } func (c *genericOpt) SetTOS(tos int) error { - // TODO(mikio): Implement this return errOpNoSupport } func (c *genericOpt) TTL() (int, error) { - // TODO(mikio): Implement this return 0, errOpNoSupport } func (c *genericOpt) SetTTL(ttl int) error { - // TODO(mikio): Implement this return errOpNoSupport } diff --git a/ipv4/header.go b/ipv4/header.go index 672f2d34..58b131c4 100644 --- a/ipv4/header.go +++ b/ipv4/header.go @@ -100,6 +100,7 @@ func (h *Header) Marshal() ([]byte, error) { b[posTotalLen], b[posTotalLen+1] = byte(h.TotalLen>>8), byte(h.TotalLen) b[posFragOff], b[posFragOff+1] = byte(flagsAndFragOff>>8), byte(flagsAndFragOff) } else { + // TODO(mikio): fix spurious word boundary access *(*uint16)(unsafe.Pointer(&b[posTotalLen : posTotalLen+1][0])) = uint16(h.TotalLen) *(*uint16)(unsafe.Pointer(&b[posFragOff : posFragOff+1][0])) = uint16(flagsAndFragOff) } @@ -141,10 +142,12 @@ func ParseHeader(b []byte) (*Header, error) { h.TotalLen = int(b[posTotalLen])<<8 | int(b[posTotalLen+1]) h.FragOff = int(b[posFragOff])<<8 | int(b[posFragOff+1]) } else { + // TODO(mikio): fix spurious word boundary access h.TotalLen = int(*(*uint16)(unsafe.Pointer(&b[posTotalLen : posTotalLen+1][0]))) if runtime.GOOS != "freebsd" || freebsdVersion < 1000000 { h.TotalLen += hdrlen } + // TODO(mikio): fix spurious word boundary access h.FragOff = int(*(*uint16)(unsafe.Pointer(&b[posFragOff : posFragOff+1][0]))) } h.Flags = HeaderFlags(h.FragOff&0xe000) >> 13 diff --git a/ipv4/helper_stub.go b/ipv4/helper_stub.go index 314d4d5f..dc2120cf 100644 --- a/ipv4/helper_stub.go +++ b/ipv4/helper_stub.go @@ -7,21 +7,17 @@ package ipv4 func (c *genericOpt) sysfd() (int, error) { - // TODO(mikio): Implement this return 0, errOpNoSupport } func (c *dgramOpt) sysfd() (int, error) { - // TODO(mikio): Implement this return 0, errOpNoSupport } func (c *payloadHandler) sysfd() (int, error) { - // TODO(mikio): Implement this return 0, errOpNoSupport } func (c *packetHandler) sysfd() (int, error) { - // TODO(mikio): Implement this return 0, errOpNoSupport }