libnl: /data/src/libnl3/lib/idiag/idiag_vegasinfo_obj.c Source File

libnl 3.7.0

idiag_vegasinfo_obj.c
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3 * Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
4 */
5
6 #include <netlink-private/netlink.h>
7 #include <netlink/idiag/vegasinfo.h>
8
9 /**
10 * @ingroup idiag
11 * @defgroup idiagnl_vegasinfo Inet Diag TCP Vegas Info
12 *
13 * @details
14 * @idiagnl_doc{idiagnl_vegasinfo, Inet Diag TCP Vegas Info Documentation}
15 * @{
16 */
17 struct idiagnl_vegasinfo *idiagnl_vegasinfo_alloc(void)
18 {
19 return (struct idiagnl_vegasinfo *) nl_object_alloc(&idiagnl_vegasinfo_obj_ops);
20 }
21
22 void idiagnl_vegasinfo_get(struct idiagnl_vegasinfo *vinfo)
23 {
24 nl_object_get((struct nl_object *) vinfo);
25 }
26
27 void idiagnl_vegasinfo_put(struct idiagnl_vegasinfo *vinfo)
28 {
29 nl_object_put((struct nl_object *) vinfo);
30 }
31
32 /**
33 * @name Attributes
34 * @{
35 */
36 uint32_t idiagnl_vegasinfo_get_enabled(const struct idiagnl_vegasinfo *vinfo)
37 {
38 return vinfo->tcpv_enabled;
39 }
40
41 void idiagnl_vegasinfo_set_enabled(struct idiagnl_vegasinfo *vinfo, uint32_t
42 enabled)
43 {
44 vinfo->tcpv_enabled = enabled;
45 }
46
47 uint32_t idiagnl_vegasinfo_get_rttcnt(const struct idiagnl_vegasinfo *vinfo)
48 {
49 return vinfo->tcpv_rttcnt;
50 }
51
52 void idiagnl_vegasinfo_set_rttcnt(struct idiagnl_vegasinfo *vinfo, uint32_t
53 rttcnt)
54 {
55 vinfo->tcpv_rttcnt = rttcnt;
56 }
57
58 uint32_t idiagnl_vegasinfo_get_rtt(const struct idiagnl_vegasinfo *vinfo)
59 {
60 return vinfo->tcpv_rtt;
61 }
62
63 void idiagnl_vegasinfo_set_rtt(struct idiagnl_vegasinfo *vinfo, uint32_t rtt)
64 {
65 vinfo->tcpv_rtt = rtt;
66 }
67
68 uint32_t idiagnl_vegasinfo_get_minrtt(const struct idiagnl_vegasinfo *vinfo)
69 {
70 return vinfo->tcpv_minrtt;
71 }
72
73 void idiagnl_vegasinfo_set_minrtt(struct idiagnl_vegasinfo *vinfo, uint32_t
74 minrtt)
75 {
76 vinfo->tcpv_minrtt = minrtt;
77 }
78 /** @} */
79
80 /** @cond SKIP */
81 static uint64_t idiagnl_vegasinfo_compare(struct nl_object *_a, struct nl_object *_b,
82 uint64_t attrs, int flags)
83 {
84 struct idiagnl_vegasinfo *a = (struct idiagnl_vegasinfo *) _a;
85 struct idiagnl_vegasinfo *b = (struct idiagnl_vegasinfo *) _b;
86
87 /* vegasinfo is a very simple object. It has no attribe flags (ce_mask),
88 * hence compare just returns 0 or 1, not a bit mask of attributes. */
89 return a->tcpv_enabled != b->tcpv_enabled ||
90 a->tcpv_rttcnt != b->tcpv_rttcnt ||
91 a->tcpv_rtt != b->tcpv_rtt ||
92 a->tcpv_minrtt != b->tcpv_minrtt;
93 }
94
95 struct nl_object_ops idiagnl_vegasinfo_obj_ops = {
96 .oo_name = "idiag/idiag_vegasinfo",
97 .oo_size = sizeof(struct idiagnl_vegasinfo),
98 .oo_compare = idiagnl_vegasinfo_compare,
99 };
100 /** @endcond */
101 /** @} */
nl_object_put
void nl_object_put(struct nl_object *obj)
Release a reference from an object.
Definition: object.c:214
nl_object_alloc
struct nl_object * nl_object_alloc(struct nl_object_ops *ops)
Allocate a new object of kind specified by the operations handle.
Definition: object.c:48
nl_object_get
void nl_object_get(struct nl_object *obj)
Acquire a reference on a object.
Definition: object.c:203