• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.netlink;
18 
19 import static android.net.netlink.StructNlAttr.findNextAttrOfType;
20 import static android.net.netlink.StructNlAttr.makeNestedType;
21 import static android.net.netlink.StructNlMsgHdr.NLM_F_ACK;
22 import static android.net.netlink.StructNlMsgHdr.NLM_F_REPLACE;
23 import static android.net.netlink.StructNlMsgHdr.NLM_F_REQUEST;
24 import static android.system.OsConstants.IPPROTO_TCP;
25 import static android.system.OsConstants.IPPROTO_UDP;
26 
27 import static java.nio.ByteOrder.BIG_ENDIAN;
28 
29 import android.annotation.NonNull;
30 import android.annotation.Nullable;
31 import android.system.OsConstants;
32 
33 import com.android.internal.annotations.VisibleForTesting;
34 
35 import java.net.Inet4Address;
36 import java.net.InetAddress;
37 import java.nio.ByteBuffer;
38 import java.nio.ByteOrder;
39 import java.util.Objects;
40 
41 
42 /**
43  * A NetlinkMessage subclass for netlink conntrack messages.
44  *
45  * see also: <linux_src>/include/uapi/linux/netfilter/nfnetlink_conntrack.h
46  *
47  * @hide
48  */
49 public class ConntrackMessage extends NetlinkMessage {
50     public static final int STRUCT_SIZE = StructNlMsgHdr.STRUCT_SIZE + StructNfGenMsg.STRUCT_SIZE;
51 
52     // enum ctattr_type
53     public static final short CTA_TUPLE_ORIG  = 1;
54     public static final short CTA_TUPLE_REPLY = 2;
55     public static final short CTA_STATUS      = 3;
56     public static final short CTA_TIMEOUT     = 7;
57 
58     // enum ctattr_tuple
59     public static final short CTA_TUPLE_IP    = 1;
60     public static final short CTA_TUPLE_PROTO = 2;
61 
62     // enum ctattr_ip
63     public static final short CTA_IP_V4_SRC = 1;
64     public static final short CTA_IP_V4_DST = 2;
65 
66     // enum ctattr_l4proto
67     public static final short CTA_PROTO_NUM      = 1;
68     public static final short CTA_PROTO_SRC_PORT = 2;
69     public static final short CTA_PROTO_DST_PORT = 3;
70 
71     // enum ip_conntrack_status
72     public static final int IPS_EXPECTED      = 0x00000001;
73     public static final int IPS_SEEN_REPLY    = 0x00000002;
74     public static final int IPS_ASSURED       = 0x00000004;
75     public static final int IPS_CONFIRMED     = 0x00000008;
76     public static final int IPS_SRC_NAT       = 0x00000010;
77     public static final int IPS_DST_NAT       = 0x00000020;
78     public static final int IPS_SEQ_ADJUST    = 0x00000040;
79     public static final int IPS_SRC_NAT_DONE  = 0x00000080;
80     public static final int IPS_DST_NAT_DONE  = 0x00000100;
81     public static final int IPS_DYING         = 0x00000200;
82     public static final int IPS_FIXED_TIMEOUT = 0x00000400;
83     public static final int IPS_TEMPLATE      = 0x00000800;
84     public static final int IPS_UNTRACKED     = 0x00001000;
85     public static final int IPS_HELPER        = 0x00002000;
86     public static final int IPS_OFFLOAD       = 0x00004000;
87     public static final int IPS_HW_OFFLOAD    = 0x00008000;
88 
89     // ip_conntrack_status mask
90     // Interesting on the NAT conntrack session which has already seen two direction traffic.
91     // TODO: Probably IPS_{SRC, DST}_NAT_DONE are also interesting.
92     public static final int ESTABLISHED_MASK = IPS_CONFIRMED | IPS_ASSURED | IPS_SEEN_REPLY
93             | IPS_SRC_NAT;
94     // Interesting on the established NAT conntrack session which is dying.
95     public static final int DYING_MASK = ESTABLISHED_MASK | IPS_DYING;
96 
97     /**
98      * A tuple for the conntrack connection information.
99      *
100      * see also CTA_TUPLE_ORIG and CTA_TUPLE_REPLY.
101      */
102     public static class Tuple {
103         public final Inet4Address srcIp;
104         public final Inet4Address dstIp;
105 
106         // Both port and protocol number are unsigned numbers stored in signed integers, and that
107         // callers that want to compare them to integers should either cast those integers, or
108         // convert them to unsigned using Byte.toUnsignedInt() and Short.toUnsignedInt().
109         public final short srcPort;
110         public final short dstPort;
111         public final byte protoNum;
112 
Tuple(TupleIpv4 ip, TupleProto proto)113         public Tuple(TupleIpv4 ip, TupleProto proto) {
114             this.srcIp = ip.src;
115             this.dstIp = ip.dst;
116             this.srcPort = proto.srcPort;
117             this.dstPort = proto.dstPort;
118             this.protoNum = proto.protoNum;
119         }
120 
121         @Override
122         @VisibleForTesting
equals(Object o)123         public boolean equals(Object o) {
124             if (!(o instanceof Tuple)) return false;
125             Tuple that = (Tuple) o;
126             return Objects.equals(this.srcIp, that.srcIp)
127                     && Objects.equals(this.dstIp, that.dstIp)
128                     && this.srcPort == that.srcPort
129                     && this.dstPort == that.dstPort
130                     && this.protoNum == that.protoNum;
131         }
132 
133         @Override
hashCode()134         public int hashCode() {
135             return Objects.hash(srcIp, dstIp, srcPort, dstPort, protoNum);
136         }
137 
138         @Override
toString()139         public String toString() {
140             final String srcIpStr = (srcIp == null) ? "null" : srcIp.getHostAddress();
141             final String dstIpStr = (dstIp == null) ? "null" : dstIp.getHostAddress();
142             final String protoStr = NetlinkConstants.stringForProtocol(protoNum);
143 
144             return "Tuple{"
145                     + protoStr + ": "
146                     + srcIpStr + ":" + Short.toUnsignedInt(srcPort) + " -> "
147                     + dstIpStr + ":" + Short.toUnsignedInt(dstPort)
148                     + "}";
149         }
150     }
151 
152     /**
153      * A tuple for the conntrack connection address.
154      *
155      * see also CTA_TUPLE_IP.
156      */
157     public static class TupleIpv4 {
158         public final Inet4Address src;
159         public final Inet4Address dst;
160 
TupleIpv4(Inet4Address src, Inet4Address dst)161         public TupleIpv4(Inet4Address src, Inet4Address dst) {
162             this.src = src;
163             this.dst = dst;
164         }
165     }
166 
167     /**
168      * A tuple for the conntrack connection protocol.
169      *
170      * see also CTA_TUPLE_PROTO.
171      */
172     public static class TupleProto {
173         public final byte protoNum;
174         public final short srcPort;
175         public final short dstPort;
176 
TupleProto(byte protoNum, short srcPort, short dstPort)177         public TupleProto(byte protoNum, short srcPort, short dstPort) {
178             this.protoNum = protoNum;
179             this.srcPort = srcPort;
180             this.dstPort = dstPort;
181         }
182     }
183 
newIPv4TimeoutUpdateRequest( int proto, Inet4Address src, int sport, Inet4Address dst, int dport, int timeoutSec)184     public static byte[] newIPv4TimeoutUpdateRequest(
185             int proto, Inet4Address src, int sport, Inet4Address dst, int dport, int timeoutSec) {
186         // *** STYLE WARNING ***
187         //
188         // Code below this point uses extra block indentation to highlight the
189         // packing of nested tuple netlink attribute types.
190         final StructNlAttr ctaTupleOrig = new StructNlAttr(CTA_TUPLE_ORIG,
191                 new StructNlAttr(CTA_TUPLE_IP,
192                         new StructNlAttr(CTA_IP_V4_SRC, src),
193                         new StructNlAttr(CTA_IP_V4_DST, dst)),
194                 new StructNlAttr(CTA_TUPLE_PROTO,
195                         new StructNlAttr(CTA_PROTO_NUM, (byte) proto),
196                         new StructNlAttr(CTA_PROTO_SRC_PORT, (short) sport, BIG_ENDIAN),
197                         new StructNlAttr(CTA_PROTO_DST_PORT, (short) dport, BIG_ENDIAN)));
198 
199         final StructNlAttr ctaTimeout = new StructNlAttr(CTA_TIMEOUT, timeoutSec, BIG_ENDIAN);
200 
201         final int payloadLength = ctaTupleOrig.getAlignedLength() + ctaTimeout.getAlignedLength();
202         final byte[] bytes = new byte[STRUCT_SIZE + payloadLength];
203         final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
204         byteBuffer.order(ByteOrder.nativeOrder());
205 
206         final ConntrackMessage ctmsg = new ConntrackMessage();
207         ctmsg.mHeader.nlmsg_len = bytes.length;
208         ctmsg.mHeader.nlmsg_type = (NetlinkConstants.NFNL_SUBSYS_CTNETLINK << 8)
209                 | NetlinkConstants.IPCTNL_MSG_CT_NEW;
210         ctmsg.mHeader.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_REPLACE;
211         ctmsg.mHeader.nlmsg_seq = 1;
212         ctmsg.pack(byteBuffer);
213 
214         ctaTupleOrig.pack(byteBuffer);
215         ctaTimeout.pack(byteBuffer);
216 
217         return bytes;
218     }
219 
220     /**
221      * Parses a netfilter conntrack message from a {@link ByteBuffer}.
222      *
223      * @param header the netlink message header.
224      * @param byteBuffer The buffer from which to parse the netfilter conntrack message.
225      * @return the parsed netfilter conntrack message, or {@code null} if the netfilter conntrack
226      *         message could not be parsed successfully (for example, if it was truncated).
227      */
parse(StructNlMsgHdr header, ByteBuffer byteBuffer)228     public static ConntrackMessage parse(StructNlMsgHdr header, ByteBuffer byteBuffer) {
229         // Just build the netlink header and netfilter header for now and pretend the whole message
230         // was consumed.
231         // TODO: Parse the conntrack attributes.
232         final StructNfGenMsg nfGenMsg = StructNfGenMsg.parse(byteBuffer);
233         if (nfGenMsg == null) {
234             return null;
235         }
236 
237         final int baseOffset = byteBuffer.position();
238         StructNlAttr nlAttr = findNextAttrOfType(CTA_STATUS, byteBuffer);
239         int status = 0;
240         if (nlAttr != null) {
241             status = nlAttr.getValueAsBe32(0);
242         }
243 
244         byteBuffer.position(baseOffset);
245         nlAttr = findNextAttrOfType(CTA_TIMEOUT, byteBuffer);
246         int timeoutSec = 0;
247         if (nlAttr != null) {
248             timeoutSec = nlAttr.getValueAsBe32(0);
249         }
250 
251         byteBuffer.position(baseOffset);
252         nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_ORIG), byteBuffer);
253         Tuple tupleOrig = null;
254         if (nlAttr != null) {
255             tupleOrig = parseTuple(nlAttr.getValueAsByteBuffer());
256         }
257 
258         byteBuffer.position(baseOffset);
259         nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_REPLY), byteBuffer);
260         Tuple tupleReply = null;
261         if (nlAttr != null) {
262             tupleReply = parseTuple(nlAttr.getValueAsByteBuffer());
263         }
264 
265         // Advance to the end of the message.
266         byteBuffer.position(baseOffset);
267         final int kMinConsumed = StructNlMsgHdr.STRUCT_SIZE + StructNfGenMsg.STRUCT_SIZE;
268         final int kAdditionalSpace = NetlinkConstants.alignedLengthOf(
269                 header.nlmsg_len - kMinConsumed);
270         if (byteBuffer.remaining() < kAdditionalSpace) {
271             return null;
272         }
273         byteBuffer.position(baseOffset + kAdditionalSpace);
274 
275         return new ConntrackMessage(header, nfGenMsg, tupleOrig, tupleReply, status, timeoutSec);
276     }
277 
278     /**
279      * Parses a conntrack tuple from a {@link ByteBuffer}.
280      *
281      * The attribute parsing is interesting on:
282      * - CTA_TUPLE_IP
283      *     CTA_IP_V4_SRC
284      *     CTA_IP_V4_DST
285      * - CTA_TUPLE_PROTO
286      *     CTA_PROTO_NUM
287      *     CTA_PROTO_SRC_PORT
288      *     CTA_PROTO_DST_PORT
289      *
290      * Assume that the minimum size is the sum of CTA_TUPLE_IP (size: 20) and CTA_TUPLE_PROTO
291      * (size: 28). Here is an example for an expected CTA_TUPLE_ORIG message in raw data:
292      * +--------------------------------------------------------------------------------------+
293      * | CTA_TUPLE_ORIG                                                                       |
294      * +--------------------------+-----------------------------------------------------------+
295      * | 1400                     | nla_len = 20                                              |
296      * | 0180                     | nla_type = nested CTA_TUPLE_IP                            |
297      * |     0800 0100 C0A8500C   |     nla_type=CTA_IP_V4_SRC, ip=192.168.80.12              |
298      * |     0800 0200 8C700874   |     nla_type=CTA_IP_V4_DST, ip=140.112.8.116              |
299      * | 1C00                     | nla_len = 28                                              |
300      * | 0280                     | nla_type = nested CTA_TUPLE_PROTO                         |
301      * |     0500 0100 06 000000  |     nla_type=CTA_PROTO_NUM, proto=IPPROTO_TCP (6)         |
302      * |     0600 0200 F3F1 0000  |     nla_type=CTA_PROTO_SRC_PORT, port=62449 (big endian)  |
303      * |     0600 0300 01BB 0000  |     nla_type=CTA_PROTO_DST_PORT, port=433 (big endian)    |
304      * +--------------------------+-----------------------------------------------------------+
305      *
306      * The position of the byte buffer doesn't set to the end when the function returns. It is okay
307      * because the caller ConntrackMessage#parse has passed a copy which is used for this parser
308      * only. Moreover, the parser behavior is the same as other existing netlink struct class
309      * parser. Ex: StructInetDiagMsg#parse.
310      */
311     @Nullable
parseTuple(@ullable ByteBuffer byteBuffer)312     private static Tuple parseTuple(@Nullable ByteBuffer byteBuffer) {
313         if (byteBuffer == null) return null;
314 
315         TupleIpv4 tupleIpv4 = null;
316         TupleProto tupleProto = null;
317 
318         final int baseOffset = byteBuffer.position();
319         StructNlAttr nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_IP), byteBuffer);
320         if (nlAttr != null) {
321             tupleIpv4 = parseTupleIpv4(nlAttr.getValueAsByteBuffer());
322         }
323         if (tupleIpv4 == null) return null;
324 
325         byteBuffer.position(baseOffset);
326         nlAttr = findNextAttrOfType(makeNestedType(CTA_TUPLE_PROTO), byteBuffer);
327         if (nlAttr != null) {
328             tupleProto = parseTupleProto(nlAttr.getValueAsByteBuffer());
329         }
330         if (tupleProto == null) return null;
331 
332         return new Tuple(tupleIpv4, tupleProto);
333     }
334 
335     @Nullable
castToInet4Address(@ullable InetAddress address)336     private static Inet4Address castToInet4Address(@Nullable InetAddress address) {
337         if (address == null || !(address instanceof Inet4Address)) return null;
338         return (Inet4Address) address;
339     }
340 
341     @Nullable
parseTupleIpv4(@ullable ByteBuffer byteBuffer)342     private static TupleIpv4 parseTupleIpv4(@Nullable ByteBuffer byteBuffer) {
343         if (byteBuffer == null) return null;
344 
345         Inet4Address src = null;
346         Inet4Address dst = null;
347 
348         final int baseOffset = byteBuffer.position();
349         StructNlAttr nlAttr = findNextAttrOfType(CTA_IP_V4_SRC, byteBuffer);
350         if (nlAttr != null) {
351             src = castToInet4Address(nlAttr.getValueAsInetAddress());
352         }
353         if (src == null) return null;
354 
355         byteBuffer.position(baseOffset);
356         nlAttr = findNextAttrOfType(CTA_IP_V4_DST, byteBuffer);
357         if (nlAttr != null) {
358             dst = castToInet4Address(nlAttr.getValueAsInetAddress());
359         }
360         if (dst == null) return null;
361 
362         return new TupleIpv4(src, dst);
363     }
364 
365     @Nullable
parseTupleProto(@ullable ByteBuffer byteBuffer)366     private static TupleProto parseTupleProto(@Nullable ByteBuffer byteBuffer) {
367         if (byteBuffer == null) return null;
368 
369         byte protoNum = 0;
370         short srcPort = 0;
371         short dstPort = 0;
372 
373         final int baseOffset = byteBuffer.position();
374         StructNlAttr nlAttr = findNextAttrOfType(CTA_PROTO_NUM, byteBuffer);
375         if (nlAttr != null) {
376             protoNum = nlAttr.getValueAsByte((byte) 0);
377         }
378         if (!(protoNum == IPPROTO_TCP || protoNum == IPPROTO_UDP)) return null;
379 
380         byteBuffer.position(baseOffset);
381         nlAttr = StructNlAttr.findNextAttrOfType(CTA_PROTO_SRC_PORT, byteBuffer);
382         if (nlAttr != null) {
383             srcPort = nlAttr.getValueAsBe16((short) 0);
384         }
385         if (srcPort == 0) return null;
386 
387         byteBuffer.position(baseOffset);
388         nlAttr = StructNlAttr.findNextAttrOfType(CTA_PROTO_DST_PORT, byteBuffer);
389         if (nlAttr != null) {
390             dstPort = nlAttr.getValueAsBe16((short) 0);
391         }
392         if (dstPort == 0) return null;
393 
394         return new TupleProto(protoNum, srcPort, dstPort);
395     }
396 
397     /**
398      * Netfilter header.
399      */
400     public final StructNfGenMsg nfGenMsg;
401     /**
402      * Original direction conntrack tuple.
403      *
404      * The tuple is determined by the parsed attribute value CTA_TUPLE_ORIG, or null if the
405      * tuple could not be parsed successfully (for example, if it was truncated or absent).
406      */
407     @Nullable
408     public final Tuple tupleOrig;
409     /**
410      * Reply direction conntrack tuple.
411      *
412      * The tuple is determined by the parsed attribute value CTA_TUPLE_REPLY, or null if the
413      * tuple could not be parsed successfully (for example, if it was truncated or absent).
414      */
415     @Nullable
416     public final Tuple tupleReply;
417     /**
418      * Connection status. A bitmask of ip_conntrack_status enum flags.
419      *
420      * The status is determined by the parsed attribute value CTA_STATUS, or 0 if the status could
421      * not be parsed successfully (for example, if it was truncated or absent). For the message
422      * from kernel, the valid status is non-zero. For the message from user space, the status may
423      * be 0 (absent).
424      */
425     public final int status;
426     /**
427      * Conntrack timeout.
428      *
429      * The timeout is determined by the parsed attribute value CTA_TIMEOUT, or 0 if the timeout
430      * could not be parsed successfully (for example, if it was truncated or absent). For
431      * IPCTNL_MSG_CT_NEW event, the valid timeout is non-zero. For IPCTNL_MSG_CT_DELETE event, the
432      * timeout is 0 (absent).
433      */
434     public final int timeoutSec;
435 
ConntrackMessage()436     private ConntrackMessage() {
437         super(new StructNlMsgHdr());
438         nfGenMsg = new StructNfGenMsg((byte) OsConstants.AF_INET);
439 
440         // This constructor is only used by #newIPv4TimeoutUpdateRequest which doesn't use these
441         // data member for packing message. Simply fill them to null or 0.
442         tupleOrig = null;
443         tupleReply = null;
444         status = 0;
445         timeoutSec = 0;
446     }
447 
ConntrackMessage(@onNull StructNlMsgHdr header, @NonNull StructNfGenMsg nfGenMsg, @Nullable Tuple tupleOrig, @Nullable Tuple tupleReply, int status, int timeoutSec)448     private ConntrackMessage(@NonNull StructNlMsgHdr header, @NonNull StructNfGenMsg nfGenMsg,
449             @Nullable Tuple tupleOrig, @Nullable Tuple tupleReply, int status, int timeoutSec) {
450         super(header);
451         this.nfGenMsg = nfGenMsg;
452         this.tupleOrig = tupleOrig;
453         this.tupleReply = tupleReply;
454         this.status = status;
455         this.timeoutSec = timeoutSec;
456     }
457 
pack(ByteBuffer byteBuffer)458     public void pack(ByteBuffer byteBuffer) {
459         mHeader.pack(byteBuffer);
460         nfGenMsg.pack(byteBuffer);
461     }
462 
getMessageType()463     public short getMessageType() {
464         return (short) (getHeader().nlmsg_type & ~(NetlinkConstants.NFNL_SUBSYS_CTNETLINK << 8));
465     }
466 
467     /**
468      * Convert an ip conntrack status to a string.
469      */
stringForIpConntrackStatus(int flags)470     public static String stringForIpConntrackStatus(int flags) {
471         final StringBuilder sb = new StringBuilder();
472 
473         if ((flags & IPS_EXPECTED) != 0) {
474             sb.append("IPS_EXPECTED");
475         }
476         if ((flags & IPS_SEEN_REPLY) != 0) {
477             if (sb.length() > 0) sb.append("|");
478             sb.append("IPS_SEEN_REPLY");
479         }
480         if ((flags & IPS_ASSURED) != 0) {
481             if (sb.length() > 0) sb.append("|");
482             sb.append("IPS_ASSURED");
483         }
484         if ((flags & IPS_CONFIRMED) != 0) {
485             if (sb.length() > 0) sb.append("|");
486             sb.append("IPS_CONFIRMED");
487         }
488         if ((flags & IPS_SRC_NAT) != 0) {
489             if (sb.length() > 0) sb.append("|");
490             sb.append("IPS_SRC_NAT");
491         }
492         if ((flags & IPS_DST_NAT) != 0) {
493             if (sb.length() > 0) sb.append("|");
494             sb.append("IPS_DST_NAT");
495         }
496         if ((flags & IPS_SEQ_ADJUST) != 0) {
497             if (sb.length() > 0) sb.append("|");
498             sb.append("IPS_SEQ_ADJUST");
499         }
500         if ((flags & IPS_SRC_NAT_DONE) != 0) {
501             if (sb.length() > 0) sb.append("|");
502             sb.append("IPS_SRC_NAT_DONE");
503         }
504         if ((flags & IPS_DST_NAT_DONE) != 0) {
505             if (sb.length() > 0) sb.append("|");
506             sb.append("IPS_DST_NAT_DONE");
507         }
508         if ((flags & IPS_DYING) != 0) {
509             if (sb.length() > 0) sb.append("|");
510             sb.append("IPS_DYING");
511         }
512         if ((flags & IPS_FIXED_TIMEOUT) != 0) {
513             if (sb.length() > 0) sb.append("|");
514             sb.append("IPS_FIXED_TIMEOUT");
515         }
516         if ((flags & IPS_TEMPLATE) != 0) {
517             if (sb.length() > 0) sb.append("|");
518             sb.append("IPS_TEMPLATE");
519         }
520         if ((flags & IPS_UNTRACKED) != 0) {
521             if (sb.length() > 0) sb.append("|");
522             sb.append("IPS_UNTRACKED");
523         }
524         if ((flags & IPS_HELPER) != 0) {
525             if (sb.length() > 0) sb.append("|");
526             sb.append("IPS_HELPER");
527         }
528         if ((flags & IPS_OFFLOAD) != 0) {
529             if (sb.length() > 0) sb.append("|");
530             sb.append("IPS_OFFLOAD");
531         }
532         if ((flags & IPS_HW_OFFLOAD) != 0) {
533             if (sb.length() > 0) sb.append("|");
534             sb.append("IPS_HW_OFFLOAD");
535         }
536         return sb.toString();
537     }
538 
539     @Override
toString()540     public String toString() {
541         return "ConntrackMessage{"
542                 + "nlmsghdr{"
543                 + (mHeader == null ? "" : mHeader.toString(OsConstants.NETLINK_NETFILTER))
544                 + "}, "
545                 + "nfgenmsg{" + nfGenMsg + "}, "
546                 + "tuple_orig{" + tupleOrig + "}, "
547                 + "tuple_reply{" + tupleReply + "}, "
548                 + "status{" + status + "(" + stringForIpConntrackStatus(status) + ")" + "}, "
549                 + "timeout_sec{" + Integer.toUnsignedLong(timeoutSec) + "}"
550                 + "}";
551     }
552 }
553