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