1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel.uring;
17
18 import io.netty.util.internal.PlatformDependent;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 final class MsgHdr {
34
35 private MsgHdr() { }
36
37 static void write(long memoryAddress, long address, int addressSize, long iovAddress, int iovLength,
38 long msgControlAddr, long cmsgHdrDataAddress, short segmentSize) {
39 PlatformDependent.putInt(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_NAMELEN, addressSize);
40
41 int msgControlLen = 0;
42 if (segmentSize > 0) {
43 msgControlLen = Native.CMSG_LEN;
44 CmsgHdr.write(msgControlAddr, cmsgHdrDataAddress, Native.CMSG_LEN, Native.SOL_UDP,
45 Native.UDP_SEGMENT, segmentSize);
46 } else {
47
48 msgControlAddr = 0;
49 }
50 if (Native.SIZEOF_SIZE_T == 4) {
51 PlatformDependent.putInt(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_NAME, (int) address);
52 PlatformDependent.putInt(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_IOV, (int) iovAddress);
53 PlatformDependent.putInt(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_IOVLEN, iovLength);
54 PlatformDependent.putInt(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_CONTROL, (int) msgControlAddr);
55 PlatformDependent.putInt(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_CONTROLLEN, msgControlLen);
56 } else {
57 assert Native.SIZEOF_SIZE_T == 8;
58 PlatformDependent.putLong(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_NAME, address);
59 PlatformDependent.putLong(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_IOV, iovAddress);
60 PlatformDependent.putLong(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_IOVLEN, iovLength);
61 PlatformDependent.putLong(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_CONTROL, msgControlAddr);
62 PlatformDependent.putLong(memoryAddress + Native.MSGHDR_OFFSETOF_MSG_CONTROLLEN, msgControlLen);
63 }
64
65 }
66 }