Esempio n. 1
0
func (self U8) Build(hdr syscall.NlAttr) []byte {
	length := NLA_HDRLEN + 1
	hdr.Len = uint16(length)
	ret := make([]byte, NLA_ALIGN(length))
	copy(ret, (*[syscall.SizeofNlAttr]byte)(unsafe.Pointer(&hdr))[:])
	ret[NLA_HDRLEN] = uint8(self)
	return ret
}
Esempio n. 2
0
func (self NulString) Build(hdr syscall.NlAttr) []byte {
	length := NLA_HDRLEN + len(self) + 1
	hdr.Len = uint16(length)
	ret := make([]byte, NLA_ALIGN(length))
	copy(ret, (*[syscall.SizeofNlAttr]byte)(unsafe.Pointer(&hdr))[:])
	copy(ret[NLA_HDRLEN:], []byte(self))
	return ret
}
Esempio n. 3
0
func (self Flag) Build(hdr syscall.NlAttr) []byte {
	if bool(self) {
		length := NLA_HDRLEN
		hdr.Len = uint16(length)
		ret := make([]byte, NLA_ALIGN(length))
		copy(ret, (*[syscall.SizeofNlAttr]byte)(unsafe.Pointer(&hdr))[:])
		return ret
	} else {
		return nil
	}
}
Esempio n. 4
0
func (self U32) Build(hdr syscall.NlAttr) []byte {
	length := NLA_HDRLEN + 4
	hdr.Len = uint16(length)
	ret := make([]byte, NLA_ALIGN(length))
	copy(ret, (*[syscall.SizeofNlAttr]byte)(unsafe.Pointer(&hdr))[:])
	if hdr.Type&syscall.NLA_F_NET_BYTEORDER == 0 {
		*(*uint32)(unsafe.Pointer(&ret[NLA_HDRLEN])) = uint32(self)
	} else {
		binary.BigEndian.PutUint32(ret[NLA_HDRLEN:], uint32(self))
	}
	return ret
}