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