|
|
@@ -20,15 +20,13 @@ func marshalTrafficClass(b []byte, cm *ControlMessage) []byte {
|
|
|
m.SetLen(syscall.CmsgLen(4))
|
|
|
if cm != nil {
|
|
|
data := b[syscall.CmsgLen(0):]
|
|
|
- // TODO(mikio): fix potential misaligned memory access
|
|
|
- *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.TrafficClass)
|
|
|
+ nativeEndian.PutUint32(data[:4], uint32(cm.TrafficClass))
|
|
|
}
|
|
|
return b[syscall.CmsgSpace(4):]
|
|
|
}
|
|
|
|
|
|
func parseTrafficClass(cm *ControlMessage, b []byte) {
|
|
|
- // TODO(mikio): fix potential misaligned memory access
|
|
|
- cm.TrafficClass = int(*(*int32)(unsafe.Pointer(&b[:4][0])))
|
|
|
+ cm.TrafficClass = int(nativeEndian.Uint32(b[:4]))
|
|
|
}
|
|
|
|
|
|
func marshalHopLimit(b []byte, cm *ControlMessage) []byte {
|
|
|
@@ -38,15 +36,13 @@ func marshalHopLimit(b []byte, cm *ControlMessage) []byte {
|
|
|
m.SetLen(syscall.CmsgLen(4))
|
|
|
if cm != nil {
|
|
|
data := b[syscall.CmsgLen(0):]
|
|
|
- // TODO(mikio): fix potential misaligned memory access
|
|
|
- *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.HopLimit)
|
|
|
+ nativeEndian.PutUint32(data[:4], uint32(cm.HopLimit))
|
|
|
}
|
|
|
return b[syscall.CmsgSpace(4):]
|
|
|
}
|
|
|
|
|
|
func parseHopLimit(cm *ControlMessage, b []byte) {
|
|
|
- // TODO(mikio): fix potential misaligned memory access
|
|
|
- cm.HopLimit = int(*(*int32)(unsafe.Pointer(&b[:4][0])))
|
|
|
+ cm.HopLimit = int(nativeEndian.Uint32(b[:4]))
|
|
|
}
|
|
|
|
|
|
func marshalPacketInfo(b []byte, cm *ControlMessage) []byte {
|